Skip to content

Web ops: cast appid, workunitid and nsecs to int in db_ops.inc - #7542

Merged
davidpanderson merged 1 commit into
BOINC:masterfrom
alplix:fix-db-ops-int
Dec 6, 2026
Merged

davidpanderson merged 1 commit into
BOINC:masterfrom
alplix:fix-db-ops-int

Conversation

@alplix

@alplix alplix commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

admin_show_result_summary() in html/inc/db_ops.inc appended the raw appid and workunitid GET parameters to its SQL query without quoting, and used nsecs in arithmetic. A crafted value such as appid=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 nsecs in SqlQueryString.

AI assistance

Found and written with Claude Code (claude-sonnet-5-5). I reviewed the change.

Testing

php -l reports 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.inc against SQL injection by casting appid, workunitid, and nsecs to int before they reach the query. Previously, these GET parameters were used raw—a crafted value like appid=1 or sleep(5) executed as part of the SQL statement.

  • Casts appid and workunitid to int where they are read, and nsecs in both admin_show_result_summary() and SqlQueryString.
  • The page requires admin login, so this is a hardening fix rather than exposure to ordinary users.

Written for commit bf533c1. Summary will update on new commits.

View guided diff

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

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread html/inc/db_ops.inc

if (isset($_GET['appid'])) {
$query_appid = $_GET['appid'];
$query_appid = (int)$_GET['appid'];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

@AenBleidd AenBleidd added this to Server Dec 6, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in Server Dec 6, 2026
@davidpanderson
davidpanderson merged commit 929137e into BOINC:master Dec 6, 2026
68 of 183 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Server Dec 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants