π‘οΈ Sentinel: [CRITICAL] Fix SQL injection vulnerability in jsonExtract#112
Conversation
- Replaced `sql.raw` with parameterized template strings using `::text` casting in `packages/core/src/db/database-wrapper.ts` for PostgreSQL JSON operators. - Added a security learning to `.jules/sentinel.md` outlining the SQL injection risk with `sql.raw` and PostgreSQL JSON operators. Co-authored-by: Donach <39565367+Donach@users.noreply.github.com>
|
π 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
π¨ Severity: CRITICAL
π‘ Vulnerability: A SQL injection vulnerability existed in the
jsonExtractutility function inpackages/core/src/db/database-wrapper.ts. The code usedsql.rawto dynamically insert JSON keys into PostgreSQL JSON operators (e.g.,->and->>), completely bypassing parameterization.π― Impact: If
jsonExtractreceives user-controlled input as part of thepathargument, it would allow a malicious actor to perform a SQL injection, potentially gaining unauthorized read or write access to the PostgreSQL database.π§ Fix: Replaced the
sql.rawusages with parameterized Drizzle template strings, explicitly casting the parameterized keys as::text(e.g.sql\->> (${key}::text)`) to prevent injection while allowing PostgreSQL to correctly resolve the overloaded JSON operators. β **Verification:** Verified by successfully running the workspace linters (pnpm -w run lint:fix) and@agor/core` test suite without introducing any regressions or functionally altering valid code paths.PR created automatically by Jules for task 15926952073635702236 started by @Donach