[Security] SQL Injection Vulnerability in datasets and tasks routers
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 16
- Forks
- 50
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
A critical security vulnerability was identified in the list_datasets and task lookup functions within the routers. The application was using raw string concatenation (f-strings) to build SQL queries from user-provided input.
This creates a high-risk SQL Injection (SQLi) vulnerability, allowing a malicious user to manipulate the query structure and execute unauthorized database commands, leading to potential data loss or unauthorized access.
To Reproduce
Steps to reproduce the behavior:
- Send a request to the
/datasets/listendpoint. - Provide a
tagparameter containing malicious SQL syntax, for example:
'study_14'); DROP TABLE dataset; -- - Result: The server concatenates this string directly into the query, which would attempt to drop the
datasettable.
Expected behavior
User input must always be treated as data, never as part of the SQL command structure. All database interactions should:
- Use parameterized placeholders (Bind Parameters).
- Strictly validate any dynamic table or column names against a predefined whitelist.
Additional context
This vulnerability was found in the following files:
src/routers/openml/datasets.pysrc/routers/openml/tasks.py
Status: A fix has already been implemented in the branch feature/sql-parameterization and is ready for review.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/routers/openml/datasets.py and src/routers/openml/tasks.py, then review the existing fix in the feature/sql-parameterization branch. Verify that user input uses parameterized placeholders and that dynamic table or column names are restricted to a whitelist; done means the reported SQL injection paths cannot alter query structure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sql
- Domain
- api, databases, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 20/100