Repository navigation
Description
Summary
Importing a session, generative session or model package unpickles files taken from the uploaded archive. A crafted package runs arbitrary code on the user's machine during import, and the import endpoints need no authentication.
Where
Found at 44d4e5a, still present on develop (f5b2c3e).
POST /api/v1/model-session/import(model_sessions.py#L1333) andPOST /api/v1/generative-session/import(generative_session.py#L1342) save the upload and call the package loaders.- Legacy plot files named by the archive are passed to
legacy_hpo_leaves(session_package/load.py#L85-L98), which callspickle.loadon them (core/run_plots.py#L95-L98).read_run_plot_file(run_plots.py#L73-L75) also unpickles. - The preprocessor entry of a model package is unpickled (model_package/load.py#L205-L206);
generative_package/load.pyfollows the same pattern. - Model
load()methods usetorch.loadwithoutweights_only=True(one setsweights_only=False, mlp_regression.py#L667) andjoblib.load, which is pickle underneath.
Zip extraction itself is safe (safe_extract blocks zip slip). The problem is deserializing the extracted content. A harmless test payload confirmed that code runs at pickle.load inside the real loader, before any validation of the result.
Impact
Code execution as the user running DashAI, from a single upload. The upload is a multipart/form-data POST, which browsers send cross site without a CORS preflight, so a web page the user visits can submit it to the local API. The CORS allowlist in #1063 only stops that page from reading the response, not the import itself.
Suggested fix
- Write plots and artifacts as JSON. For legacy pickled files, use a restricted
Unpicklerwith an explicit allowlist, or skip them with a warning. - Use
torch.load(..., weights_only=True)everywhere a stored or imported model is loaded. - For artifacts that must stay pickled (for example scikit learn estimators saved with joblib), make importing them an explicit user decision: a warning in the import dialog that only trusted packages should be imported, and a confirmation flag the endpoint requires.
Activity