Replace f-string SQL construction with parameterized queries #6
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Multiple routes build SQL WHERE clauses via f-string concatenation and pass them directly to
sqlalchemy.text():compliance/api/canonical_control_routes.py:295-377—text(f"SELECT ... WHERE {w_all}")compliance/api/quality_routes.py— same patterncompliance/api/obligation_routes.py— same patternEven though some individual values are bound via
params, the structural parts of the WHERE clause are built from unvalidated user input. This is exploitable SQL injection.Required Actions
compliance/api/fortext(f"andtext("with concatenation.bindparams()WhereClauseBuilderthat only allows known column names as keys (allowlist-based)bandit -r compliance/to CI python-lint job to catch future regressionsAcceptance Criteria
grep -r 'text(f' compliance/api/returns zero resultsbanditscan exits 0 on all API route files