Skip to content

Fix SQL injection: validate query tables against TAP_SCHEMA whitelist#12

Open
bjfultn wants to merge 3 commits intodevelopfrom
hotfix/table-validation
Open

Fix SQL injection: validate query tables against TAP_SCHEMA whitelist#12
bjfultn wants to merge 3 commits intodevelopfrom
hotfix/table-validation

Conversation

@bjfultn
Copy link
Collaborator

@bjfultn bjfultn commented Mar 4, 2026

nexsciTAP never validated that tables in ADQL queries were registered in TAP_SCHEMA.tables, allowing access to system catalogs, cross-schema tables with PII, and database internals. This adds table validation in tapquery.py and propfilter.py (the two query execution paths) and fixes a string-concatenation SQL injection in datadictionary.py with parameterized queries.

bjfultn and others added 2 commits March 3, 2026 17:49
nexsciTAP never validated that tables in ADQL queries were registered
in TAP_SCHEMA.tables, allowing access to system catalogs, cross-schema
tables with PII, and database internals. This adds table validation at
three layers (tap.py primary gate, runquery.py and propfilter.py
defense-in-depth) and fixes a string-concatenation SQL injection in
datadictionary.py with parameterized queries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move table validation to runquery.py and propfilter.py only, where DB
connections already exist. This eliminates one extra connection per
request, which matters especially for Oracle where connection setup
can take 50-200ms.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
sqlparse tokenizes 'ORDER BY' as a single compound keyword, but
extract_from_part only checked for 'ORDER' as a separate token.
This caused columns in ORDER BY clauses to be extracted as table
names, which the table validator then rejected as unauthorized.

Also adds 'LIMIT' and 'OFFSET' as stop-keywords for completeness.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant