Skip to content

πŸ›‘οΈ Sentinel: [HIGH] Fix potential SQL injection in db query#20

Open
jspann21 wants to merge 1 commit into
mainfrom
sentinel/sql-injection-fix-4421034108336006557
Open

πŸ›‘οΈ Sentinel: [HIGH] Fix potential SQL injection in db query#20
jspann21 wants to merge 1 commit into
mainfrom
sentinel/sql-injection-fix-4421034108336006557

Conversation

@jspann21
Copy link
Copy Markdown
Owner

@jspann21 jspann21 commented Jun 5, 2026

🚨 Severity: HIGH
πŸ’‘ Vulnerability: Potential SQL Injection through dynamic query string interpolation of column names (format!("SELECT {field_name} FROM books WHERE id = ?1")) in src-tauri/src/library/db.rs. While it appears that most upstream functions provide safe arguments, this architecture lacks a defense-in-depth safety mechanism making it extremely fragile to regressions.
🎯 Impact: If field_name could be manipulated by a user, an attacker could extract unauthorized information or manipulate query logic, bypassing access controls entirely.
πŸ”§ Fix: Introduced an explicit string match allowlist function (is_safe_book_column) and added anyhow::ensure! validations before injecting field_name into queries. This ensures that any invalid or unanticipated field names will instantly short-circuit and fail safely.
βœ… Verification: Verified by checking that cargo test and pnpm test still pass. Existing operations will function cleanly, but malicious inputs will fail immediately.


PR created automatically by Jules for task 4421034108336006557 started by @jspann21

Implemented an explicit string-match allowlist check for database field
retrieval functions (`get_book_field`, `get_book_i64_field`, etc.).
This ensures that only safe, known column names can be dynamically queried
and prevents the possibility of a SQL injection via field interpolation.

Co-authored-by: jspann21 <179991454+jspann21@users.noreply.github.com>
@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