Skip to content

πŸ›‘οΈ Sentinel: [CRITICAL] Fix DuckDB SQL injection via f-strings - #112

Open
aperetti wants to merge 1 commit into
mainfrom
sentinel/fix-duckdb-sql-injection-4880246826587057914
Open

πŸ›‘οΈ Sentinel: [CRITICAL] Fix DuckDB SQL injection via f-strings#112
aperetti wants to merge 1 commit into
mainfrom
sentinel/fix-duckdb-sql-injection-4880246826587057914

Conversation

@aperetti

Copy link
Copy Markdown
Owner

🚨 Severity: CRITICAL
πŸ’‘ Vulnerability: User-provided inputs (start_time and end_time) were directly interpolated into DuckDB SQL queries via f-strings in DuckDBMeterDataRepository. String replacement (like .replace("'", "''")) was used in an attempt to sanitize, but this is inherently unsafe and a known vector for SQL injection.
🎯 Impact: Remote execution of arbitrary SQL commands, unauthorized data access, or denial of service by exploiting the analytical query endpoints on DuckDB instances.
πŸ”§ Fix: Refactored all DuckDB conn.execute(...) calls to use standard parameterized inputs with ? placeholders, passing variables via the parameter list array (e.g., conn.execute(..., [start_time, end_time])). Cleaned up stale, breaking test cases in test_duckdb_adapter.py. Logged finding to Sentinel security journal.
βœ… Verification: Executed test suite (test_duckdb_adapter.py) against updated query format to confirm functional correctness and parameter transmission.


PR created automatically by Jules for task 4880246826587057914 started by @aperetti

- Replaced unsafe f-string concatenation of user inputs (`start_time` and `end_time`) with standard SQL parameterization `?` in `DuckDBMeterDataRepository`.
- Applied fix across all data access methods inside the adapter, including wrapper queries like `EXPLAIN ANALYZE`.
- Refactored stale test assertions in `test_duckdb_adapter.py` that were improperly coupled to old query parameter signatures.
- Appended a critical security entry to `.jules/sentinel.md` documenting this finding and prevention protocol.

Co-authored-by: aperetti <482392+aperetti@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

πŸ‘‹ 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