Repository navigation
fix(crewai-tools): block SELECT INTO in NL2SQLTool read-only mode - #9670
Vidit Ostwal (Vidit-Ostwal) wants to merge 3 commits into
Conversation
Strix Security Review✅ No open security findings. PR summary: Hardens `NL2SQLTool`'s read-only mode so `SELECT ... INTO OUTFILE`/`DUMPFILE` and `SELECT ... INTO new_table` are rejected when `allow_dml=False`, while keeping MySQL `INTO @var` allowed. Adds tests for blocked and benign forms. Review summaryThe PR adds an Ruled out (4)
Review history (2)
Review 2 on this PR · Reviewed by Strix |
Read-only mode only checked the leading keyword, so SELECT ... INTO OUTFILE/DUMPFILE could write files on the database host and SELECT ... INTO <table> could create tables. Reject INTO clauses (outside string literals) for read commands and CTEs when allow_dml=False. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
79ea45e to
eb44383
Compare
…sing Match INTO OUTFILE/DUMPFILE on the raw statement, and scan raw text for INTO when the statement contains backslashes, double quotes or backticks, since the single-quote blanker can disagree with the database lexer there. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Fixes OSS-262 (GHSA-5gjp-r3m5-5w96).
Problem
NL2SQLTool read-only mode only validated the leading keyword, so
SELECT ... INTO OUTFILE/DUMPFILEcould write files on the DB host, andSELECT ... INTO new_tablecould create tables.Fix
_detect_into_clause, which ignores string literals, and call it for SELECT/SHOW/DESCRIBE/EXPLAIN/WITH statements whenallow_dml=False.INTO @var(MySQL session variable) stays allowed.allow_dml=Trueis unchanged.Tests
Added
TestSelectIntoBlocked(blocked variants, benign queries,allow_dml=True).🤖 Generated with Claude Code