Skip to content

fix: use parameterized query in cleanup_old_results (CWE-89)#3899

Open
spidershield-contrib wants to merge 1 commit intoIBM:mainfrom
spidershield-contrib:fix/cwe-89-sql-injection
Open

fix: use parameterized query in cleanup_old_results (CWE-89)#3899
spidershield-contrib wants to merge 1 commit intoIBM:mainfrom
spidershield-contrib:fix/cwe-89-sql-injection

Conversation

@spidershield-contrib
Copy link
Copy Markdown

Summary

Fixes #3898 — The cleanup_old_results method used an f-string to embed the days_old parameter directly into SQL, allowing SQL injection if the parameter bypasses type checking.

Changes

  • Replaced the f-string SQL interpolation with a parameterized query using ? placeholder
  • Used CAST(? AS TEXT) with string concatenation in the datetime() function to safely pass the parameter

CWE Reference

  • CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
  • Severity: Medium

Testing

  • Verify that cleanup_old_results(days_old=30) still correctly deletes results older than 30 days
  • Verify that cleanup_old_results(days_old=0) works correctly
  • Verify that the parameterized query produces the same results as the original for valid integer inputs

Found by SpiderShield security scanner

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.

Security: SQL Injection in cleanup_old_results (CWE-89)

1 participant