Medusa: arbitrary file write via the upload-files workflow, up to code execution in development mode

An admin account writes files to arbitrary places in the project directory through POST /admin/workflows-executions/upload-files/run; when the server runs with medusa develop, it loads a subscriber file placed that way and executes its code.

Advisory ID: TP-2026-132
Product: Medusa (headless commerce backend on Node.js)
Vulnerability type: Path traversal on file write, up to code execution (CWE-22)
CVE: not requested
CVSS 3.1: 7.2 (High) · CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H
Affected versions: up to and including 2.15.5 (tested: 2.15.3 and 2.15.5)
Fixed in: 2.16.0
Reported: 25 May 2026

Summary

Medusa is a headless commerce backend that admins manage through a REST API under /admin. Through POST /admin/workflows-executions/:workflow_id/run an admin starts any registered workflow with freely chosen input, including upload-files. The local file provider takes the directory part of the supplied file name and does not check whether the target path stays inside the upload directory. An admin therefore writes files with their own content to any place the server process may write to. When the server runs with medusa develop, it loads a file written to src/subscribers on the automatic restart and executes its code as the process user.

Root cause

AdminCreateWorkflowsRun declares input as z.any() (packages/medusa/src/api/admin/workflows-executions/validators.ts:34-37), and the route carries no check other than this body validation (packages/medusa/src/api/admin/workflows-executions/middlewares.ts:65-68).
The step of the upload-files workflow passes data.files unchanged to createFiles of the file module (packages/core/core-flows/src/file/steps/upload-files.ts:60-61).
LocalFileService.upload carries the directory part of the file name into the file key via path.parse(file.filename) (packages/modules/providers/file-local/src/services/local-file.ts:44-52).
getUploadFilePath joins upload directory and key with path.join without checking that the result stays inside the upload directory (packages/modules/providers/file-local/src/services/local-file.ts:223-225), and fs.writeFile writes to that path (packages/modules/providers/file-local/src/services/local-file.ts:73).
medusa develop watches the project directory, src/subscribers is not on the ignore list (packages/medusa/src/commands/develop.ts:177-189), and after the restart the server loads the file via dynamicImport (packages/core/framework/src/utils/resource-loader.ts:93).

Proof of Concept

POST /admin/workflows-executions/upload-files/run HTTP/1.1
Host: <medusa-host>
Authorization: Bearer <admin token>
Content-Type: application/json

{"input": {"files": [{"filename": "../src/subscribers/poc.ts", "mimeType": "text/plain", "content": "<base64 of the TypeScript code>", "access": "public"}]}}

The provider prefixes the file name with a timestamp and keeps the directory ../src/subscribers. Verified on 25 May 2026 on 2.15.3 under medusa develop: the file was in src/subscribers afterwards, the watcher restarted the server, and the code ran as the user of the server process. Retested against the file provider in November 2026: 2.15.3 and 2.15.5 write the file outside the upload directory, 2.22.7 rejects the same call with Invalid file key. Without the medusa develop watcher we have shown only the file write, not the code execution.

Impact

  • Write of files with freely chosen content to any place the server process may write to.
  • Under medusa develop, execution of the attacker's code as the user of the server process, with access to database credentials and secrets of the environment.
  • The attack requires an admin account and the local file provider; installations with another provider such as S3 do not reach the vulnerable code.

References

Is Something Like This in Your Software?

Our team found this vulnerability during its work. Have your applications tested by the same specialists, with a penetration test from turingpoint.