Fix SQL injection via unguarded orderby parameter in REST API helpers#585
Draft
Fix SQL injection via unguarded orderby parameter in REST API helpers#585
orderby parameter in REST API helpers#585Conversation
…r files Co-authored-by: iftakharul-islam <88052038+iftakharul-islam@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix authenticated SQL Injection vulnerability in Project Manager plugin
Fix SQL injection via unguarded Mar 2, 2026
orderby parameter in REST API helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Authenticated users could inject arbitrary SQL through the
orderbyquery parameter on multiple REST endpoints (e.g./pm/v2/activities). The PoC:orderby=id/**/AND/**/(SELECT/**/1/**/FROM/**/(SELECT(SLEEP(5)))a)exploited the lack of input validation before the value was interpolated into theORDER BYclause.Changes
$orderguard — all 8 affected helper files unconditionally set$this->orderby = "ORDER BY " . implode(', ', $order)even when every input was rejected by the whitelist, producing syntactically invalid SQL (ORDER BYwith no columns). Wrapped the assignment inif ( !empty( $order ) )so$this->orderbyis left unset (resolved to''at query time) when no valid columns survive validation.The core injection defenses were already in place across all helpers:
in_array()'asc'/'desc'esc_sql()applied to both column and direction before interpolationAffected files
Activity,File,Milestone,Comment,Discussion_Board,Task,Task_List,Userhelpers undersrc/*/Helper/.Projecthelper already handled the empty case and was left unchanged.🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.