Skip to content

fix: validate INTO OUTFILE, DUMPFILE and INTO TEMP as selectInto - #2868

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
tanjiroK-coder:validate-select-into-clauses
Oct 29, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
tanjiroK-coder:validate-select-into-clauses

Conversation

@tanjiroK-coder

Copy link
Copy Markdown
Contributor

FeaturesAllowed.SELECT is documented as every SELECT feature "without modification features like selectInto", and Validation with it is a natural gate for only letting read queries through. SelectValidator checks getIntoTables() against Feature.selectInto, but the MySQL/MariaDB INTO OUTFILE / INTO DUMPFILE / INTO @var clause lives in getMySqlSelectIntoClause() and the trailing INTO TEMP table in getIntoTempTable(), and neither was looked at. So SELECT * INTO newtab FROM t is reported as selectInto not allowed, while SELECT a FROM t INTO OUTFILE '/tmp/x', SELECT '<?php ... ?>' INTO DUMPFILE '/var/www/html/s.php' and the same clause inside an IN (...) subquery validate with no errors, although they write files on the database server. I found it by running statements with side effects through Validation.validate(List.of(FeaturesAllowed.SELECT), sql) and comparing which ones came back clean. Both clauses now report selectInto next to the existing INTO-table check, and selectInto is added to MySqlVersion and MariaDbVersion so validating against DatabaseType.MYSQL / MARIADB still accepts their own SELECT ... INTO syntax. The new parameterized case in SelectValidatorTest fails for all five statements before the change, and ./gradlew check passes after it.

@manticore-projects
manticore-projects merged commit a075737 into JSQLParser:master Oct 29, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you!

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.

2 participants