You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SQL injection risk in MzMLSqliteHandler::writeRunLevelInformation via unescaped file path #9730
writeRunLevelInformation builds an INSERT statement by directly concatenating the loaded file path into the SQL string, instead of using a parameterized query. The developer already left a TODO acknowledging this:
src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp, lines 887 to 890:
std::stringstream insert_run_sql;
const std::string& native_id = exp.getLoadedFilePath(); // TODO escape stuff like ' (SQL inject)
insert_run_sql << "INSERT INTO RUN (ID, FILENAME, NATIVE_ID) VALUES (" <<
run_id_ << ",'" << native_id << "','" << native_id << "'); ";
The resulting string is executed as is through conn.executeStatement(insert_run_sql.str()), which calls sqlite3_exec with no binding or escaping. native_id comes from exp.getLoadedFilePath(), which in most workflows is just a local file path chosen by the user, but it can also come from mzML metadata, batch scripts, automated pipelines, or file names supplied by someone other than the person running the tool. Any of those containing a single quote will at minimum break the query, and a deliberately crafted path or filename could inject arbitrary SQL into the sqlite database being written.
Why it matters
This runs whenever an MSExperiment gets written out as sqlite (.sqMass output, used by the OpenSWATH-related tools). Since the file path is attacker-influenceable in scripted or automated environments, this is not just a theoretical concern. It also sits right next to a working example of the correct pattern in the same codebase.
Suggested fix
SqliteConnector already has executeBindStatement(sqlite3* db, const std::string& prepare_statement, const std::vectorstd::string& data) (src/openms/source/FORMAT/SqliteConnector.cpp, around line 132), which uses sqlite3_bind_blob with ? placeholders. writeRunLevelInformation should build the INSERT with placeholders and pass native_id through that instead of concatenating it into the string, the same way parameter binding is already done elsewhere in this file.
Welcome @aliviahossain and thank you for your contribution to OpenMS! To help us better understand our userbase and contributors, we would appreciate if you could complete the survey at the link below. Completing this survey will help us get to your issue sooner. Thank you for your participation!
As @timosachsenberg said on discord this sounds like something that could be nice to have so feel free to test/fix. I would also recommend looking at the parquet implementations as we are migrating towards using those as output files in OpenSWATH so any feedback there would be greatly appreciated.
Activity
github-actions commentedon Jul 12, 2026
Welcome @aliviahossain and thank you for your contribution to OpenMS! To help us better understand our userbase and contributors, we would appreciate if you could complete the survey at the link below. Completing this survey will help us get to your issue sooner. Thank you for your participation!
Survey
jcharkow commentedon Jul 13, 2026
As @timosachsenberg said on discord this sounds like something that could be nice to have so feel free to test/fix. I would also recommend looking at the parquet implementations as we are migrating towards using those as output files in OpenSWATH so any feedback there would be greatly appreciated.
aliviahossain commentedon Jul 13, 2026
@jcharkow Sure, please assign me this issue. Meanwhile let me test this and also look into the parquet implementations. Will update you soon !