fix: use parameterized query in cleanup_old_results (CWE-89)#3899
fix: use parameterized query in cleanup_old_results (CWE-89)#3899spidershield-contrib wants to merge 1 commit intoIBM:mainfrom
Conversation
Thank You for Identifying This Security Issue! 🙏@spidershield-contrib, thank you for identifying and reporting the SQL injection vulnerability in Decision: Proceeding with PR #3944After reviewing both PRs, we've decided to proceed with PR #3944 instead of this one. Here's why: Comparison
Why PR #3944?While your PR was opened first and correctly identifies the vulnerability, PR #3944 provides:
Your Contribution MattersYour identification of this issue through SpiderShield is valuable! The SQL injection fix in PR #3944 is identical to yours, which validates your analysis. We want to ensure you receive proper credit:
Next StepsWe'll be closing this PR in favor of #3944, but your security scanning work is appreciated. If you'd like to contribute more:
Thank you again for helping make ContextForge more secure! 🛡️ Duplicate of #3944 |
Summary
Fixes #3898 — The
cleanup_old_resultsmethod used an f-string to embed thedays_oldparameter directly into SQL, allowing SQL injection if the parameter bypasses type checking.Changes
?placeholderCAST(? AS TEXT)with string concatenation in thedatetime()function to safely pass the parameterCWE Reference
Testing
cleanup_old_results(days_old=30)still correctly deletes results older than 30 dayscleanup_old_results(days_old=0)works correctlyFound by SpiderShield security scanner