Repository navigation
Web ops: cast appid, workunitid and nsecs to int in db_ops.inc - #7542
Merged
Merged
Conversation
admin_show_result_summary() appended the raw appid and workunitid GET parameters to its SQL query without quoting, and used nsecs in arithmetic. A crafted value (for example "appid=1 or sleep(5)") was therefore executed as part of the query. The page requires an admin login, so this is a hardening fix rather than an exposure to ordinary users. Cast the three values to int where they are read, including the second use of nsecs in SqlQueryString. Assisted-by: Claude Code:claude-sonnet-5-5
Contributor
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="html/inc/db_ops.inc">
<violation number="1" location="html/inc/db_ops.inc:442">
P1: This cast protects only `$main_query`; `$_GET['appid']` remains raw when `$q->process_form_items()` builds links to `db_action.php`. A payload such as `1' OR SLEEP(5) -- ` can execute when an admin follows one of those links. Normalize `appid` and `workunitid` before processing the form values, or make their query construction type-safe.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
|
|
||
| if (isset($_GET['appid'])) { | ||
| $query_appid = $_GET['appid']; | ||
| $query_appid = (int)$_GET['appid']; |
Contributor
There was a problem hiding this comment.
P1: This cast protects only $main_query; $_GET['appid'] remains raw when $q->process_form_items() builds links to db_action.php. A payload such as 1' OR SLEEP(5) -- can execute when an admin follows one of those links. Normalize appid and workunitid before processing the form values, or make their query construction type-safe.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At html/inc/db_ops.inc, line 442:
<comment>This cast protects only `$main_query`; `$_GET['appid']` remains raw when `$q->process_form_items()` builds links to `db_action.php`. A payload such as `1' OR SLEEP(5) -- ` can execute when an admin follows one of those links. Normalize `appid` and `workunitid` before processing the form values, or make their query construction type-safe.</comment>
<file context>
@@ -439,17 +439,17 @@ function admin_show_result_summary() {
if (isset($_GET['appid'])) {
- $query_appid = $_GET['appid'];
+ $query_appid = (int)$_GET['appid'];
} else {
$query_appid = "";
</file context>
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.
admin_show_result_summary()inhtml/inc/db_ops.incappended the rawappidandworkunitidGET parameters to its SQL query without quoting, and usednsecsin arithmetic. A crafted value such asappid=1 or sleep(5)was executed as part of the query. The page requires an admin login, so this is a hardening fix.The three values are now cast to int where they are read, including the second use of
nsecsinSqlQueryString.AI assistance
Found and written with Claude Code (claude-sonnet-5-5). I reviewed the change.
Testing
php -lreports no syntax errors. Checked by reading the code that the three values only reach the query through these assignments.Summary by cubic
Hardens
html/inc/db_ops.incagainst SQL injection by castingappid,workunitid, andnsecstointbefore they reach the query. Previously, these GET parameters were used raw—a crafted value likeappid=1 or sleep(5)executed as part of the SQL statement.appidandworkunitidto int where they are read, andnsecsin bothadmin_show_result_summary()andSqlQueryString.Written for commit bf533c1. Summary will update on new commits.