Skip to content

πŸ›‘οΈ Sentinel: [CRITICAL] Fix SQL Injection Risk in JSON Path Extraction - #155

Open
Donach wants to merge 1 commit into
cfx/android-hermes-clientfrom
fix-sqli-json-extract-15461631222607097162
Open

πŸ›‘οΈ Sentinel: [CRITICAL] Fix SQL Injection Risk in JSON Path Extraction#155
Donach wants to merge 1 commit into
cfx/android-hermes-clientfrom
fix-sqli-json-extract-15461631222607097162

Conversation

@Donach

@Donach Donach commented Jul 25, 2026

Copy link
Copy Markdown

🚨 Severity: CRITICAL
πŸ’‘ Vulnerability: The jsonExtract database helper in @agor/core/db/database-wrapper.ts dynamically constructed JSON path strings for queries. Instead of properly parameterizing the variables using Drizzle's sql string literal tag, it concatenated them manually using sql.raw(). This completely evaded SQL injection protections.
🎯 Impact: Any endpoint allowing a client to supply dynamic JSON dot paths (like nested filtering configurations or sorting orders) could be manipulated to terminate the JSON selection string early and inject arbitrary SQL payload logic.
πŸ”§ Fix: Removed sql.raw() from jsonExtract completely. Reimplemented the PostgreSQL path construction using explicit parameterized array joins and text casting (::text), matching standard Drizzle best practices without sacrificing functionality.
βœ… Verification: pnpm test and pnpm lint passed successfully without regressions. Tested explicitly with the test-drizzle.ts query rendering script to confirm the output is parameterized (e.g. -> ($1::text) ->> ($2::text)).


PR created automatically by Jules for task 15461631222607097162 started by @Donach

The `jsonExtract` helper used `sql.raw()` to interpolate dynamic JSON path arguments into queries. This completely bypassed Drizzle ORM's parameterization and introduced a severe SQL Injection risk when executing complex searches against JSON fields.
This patch replaces `sql.raw` with standard `sql` string parameterization, explicitly casting the variables as PostgreSQL text fragments (`::text`) prior to building the traversal path, satisfying both Drizzle's static checking and preventing query manipulation.
@google-labs-jules

Copy link
Copy Markdown

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

1 participant