FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix: Prevent SQL injection in QueueJobModel priority sorting by gr8man · Pull Request #94 · codeigniter4/queue · GitHub

Fix: Prevent SQL injection in QueueJobModel priority sorting - #94

Closed
gr8man wants to merge 2 commits into
codeigniter4:developfrom
gr8man:fix-queuejobmodel-priority-sqli
Closed

Fix: Prevent SQL injection in QueueJobModel priority sorting#94
gr8man wants to merge 2 commits into
codeigniter4:developfrom
gr8man:fix-queuejobmodel-priority-sqli

Conversation

gr8man commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This PR fixes a potential SQL injection vulnerability in the QueueJobModel by properly escaping priority values before using them in CASE and FIELD SQL statements. A unit test was also added to ensure correct behavior.

michalsn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for the PR. Could you please adjust the PR title, description, and commit message to avoid framing this as a security vulnerability?

As discussed, the affected priority list is normally controlled by the application developer/operator through config or CLI, not by untrusted end users in normal usage. This is better described as hardening the database queue ordering logic.

Comment on lines +63 to +82
public function testSetPriority(): void
{
$model = model(QueueJobModel::class);
$method = $this->getPrivateMethodInvoker($model, 'setPriority');
$builder = $model->builder();

$result = $method($builder, ['high', 'low']);

$sql = $result->getCompiledSelect();

$this->assertStringContainsString('priority', $sql);
if ($model->db->DBDriver === 'MySQLi') {
$this->assertStringContainsString('FIELD(priority, ', $sql);
} else {
$this->assertStringContainsString('CASE ', $sql);
$this->assertStringContainsString(' WHEN ', $sql);
$this->assertStringContainsString(' THEN ', $sql);
$this->assertStringContainsString(' END', $sql);
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The test seems a bit weak. It checks that SQL contains CASE/FIELD, but not that dangerous values are escaped or keys are normalized.

gr8man force-pushed the fix-queuejobmodel-priority-sqli branch from cc7c72c to c4536da Compare July 17, 2026 18:20
gr8man requested a review from michalsn July 17, 2026 18:20
michalsn closed this in #95 Jul 23, 2026

Copy link
Copy Markdown
Member

Thank you. You were credited in #95.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL