SECURITY: SDK archive upload vulnerable to path traversal (tar/zip slip) — attacker can write arbitrary files on the server #89
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?
Description
services/mam-api/src/routes/sdk.jsextracts uploaded archives without checking for path traversal entries ("zip slip" / "tar slip"). A malicious archive whose entries contain../sequences can write files outsideSDK_ROOT.Affected code (
sdk.js):Exploitation
An attacker who has authenticated access (the route has
requireAuth) could upload a crafted.tar.gzsuch as:When the API extracts this to
/sdk/blackmagic/, the relative../../etc/cron.d/backdoorentry escapesSDK_ROOTand writes to the system cron directory (or anywhere the process has write access).Impact
AUTH_ENABLED=true: Exploitable by any authenticated admin (since SDK management is typically admin-only).AUTH_ENABLED=false(dev mode): Exploitable by anyone who can reach the API.The running process (
node) would need write access to the target path, but on many deployments the container runs as root or has elevated permissions.Suggested fixes
Option 1 — Validate entries before extraction (most robust):
For zip: use a library like
adm-zipto inspect entry names before extracting. For tar: use--strip-componentsand a content listing pre-pass.Option 2 — Use
--no-overwrite-dirand a jail:For tar, add
--no-absolute-namesand validate that no entry path contains..:Option 3 — Run extraction in a separate sandboxed process/container with a read-only filesystem root, only the target directory writable.