π‘οΈ Sentinel: [HIGH] Fix potential SQL injection in db query#20
π‘οΈ Sentinel: [HIGH] Fix potential SQL injection in db query#20jspann21 wants to merge 1 commit into
Conversation
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>
|
π 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: HIGH
π‘ Vulnerability: Potential SQL Injection through dynamic query string interpolation of column names (
format!("SELECT {field_name} FROM books WHERE id = ?1")) insrc-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_namecould 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 addedanyhow::ensure!validations before injectingfield_nameinto queries. This ensures that any invalid or unanticipated field names will instantly short-circuit and fail safely.β Verification: Verified by checking that
cargo testandpnpm teststill pass. Existing operations will function cleanly, but malicious inputs will fail immediately.PR created automatically by Jules for task 4421034108336006557 started by @jspann21