🛡️ Sentinel: [CRITICAL] Fix SQL Injection in PostgresAdapter DDL operations#827
🛡️ Sentinel: [CRITICAL] Fix SQL Injection in PostgresAdapter DDL operations#827
Conversation
…ations Refactored `create_table`, `drop_table`, `migrate_table`, `create_index`, and `drop_index` in `PostgresAdapter` to use `psycopg.sql.SQL` and `psycopg.sql.Identifier` instead of unsafe f-strings, preventing SQL injection vulnerabilities. Co-authored-by: georgi <19498+georgi@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. |
…ations Refactored `create_table`, `drop_table`, `migrate_table`, `create_index`, and `drop_index` in `PostgresAdapter` to use `psycopg.sql.SQL` and `psycopg.sql.Identifier` instead of unsafe f-strings, preventing SQL injection vulnerabilities. Co-authored-by: georgi <19498+georgi@users.noreply.github.com>
…ations Refactored `create_table`, `drop_table`, `migrate_table`, `create_index`, and `drop_index` in `PostgresAdapter` to use `psycopg.sql.SQL` and `psycopg.sql.Identifier` instead of unsafe f-strings, preventing SQL injection vulnerabilities. Co-authored-by: georgi <19498+georgi@users.noreply.github.com>
…ations Refactored `create_table`, `drop_table`, `migrate_table`, `create_index`, and `drop_index` in `PostgresAdapter` to use `psycopg.sql.SQL` and `psycopg.sql.Identifier` instead of unsafe f-strings, preventing SQL injection vulnerabilities. Also fixed the CI failing from docker build referring to missing api package. Co-authored-by: georgi <19498+georgi@users.noreply.github.com>
🚨 Severity: CRITICAL
💡 Vulnerability: SQL Injection in Data Definition Language (DDL) queries. Methods in
src/nodetool/models/postgres_adapter.pyused unsafe Python f-string concatenation for table names, column names, and types.🎯 Impact: A malicious user could potentially execute arbitrary SQL commands if they can control the input to these schema modification methods.
🔧 Fix: Refactored the methods to use safe query composition objects specifically designed for DDL. In psycopg (PostgreSQL), used
psycopg.sql.SQLandpsycopg.sql.Identifierto safely construct dynamic table, column, and schema names in database adapters.✅ Verification: Ran unit tests
uv run pytest tests/models/test_postgres_adapter.pyand ensured they passed. Code review also verified the imports and safety of the changes.PR created automatically by Jules for task 4961605429346768070 started by @georgi