Fix: Prevent SQL injection in QueueJobModel priority sorting#94
Open
gr8man wants to merge 2 commits into
Open
Conversation
michalsn
requested changes
Jul 8, 2026
michalsn
left a comment
Member
There was a problem hiding this comment.
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); | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
The test seems a bit weak. It checks that SQL contains CASE/FIELD, but not that dangerous values are escaped or keys are normalized.
5 tasks
gr8man
force-pushed
the
fix-queuejobmodel-priority-sqli
branch
from
July 17, 2026 18:20
cc7c72c to
c4536da
Compare
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.
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.