Export job file_path is mass-assignable, so deleting the job deletes any file #31
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: medium (release blocker per Haystack) · found by Nye
Job.export_changeset(lib/fuzzy_catalog/import_export/job.ex) casts:file_path,:file_name,:file_size,:progress,:total_items,:processed_items,:error_messageand:user_idfrom the form's job params, andcreate_exportpassesjob_paramsstraight in.POST
job[file_path]=../../../config/runtime.exswithjob[filters][format]=bogus: the export fails (exporter.ex ~L56) and the forgedfile_pathstays on the job. (A completed export overwritesfile_path, but a failed or still-running one doesn't.)DELETE /admin/import-export/:idthen runsFile.rm(Path.join(base_path, job.file_path)), so path traversal deletes any file the app user can write.ImportExport.cleanup_expired_jobsis worse:File.rm(job.file_path)with no base at all.download/2reads from the same joined path.Admin-only once #17 lands (#8); any logged-in user before that.
Fix
export_changesetcasts only:filters; setuser_idand file fields withput_changefrom server code. Internal progress updates use a separate internal changeset.Path.expand+ prefix check), used by delete, download and expired-job cleanup, with aLogger.warning(job id) on rejection.job[file_path]is ignored; delete and cleanup of a job withfile_path: "../x"leave a sentinel file outside the base intact.