Skip to content

fix(media): contain media file resolution inside the store (CWE-22 path traversal) - #1319

Open
DHDHLZ wants to merge 1 commit into
TraderAlice:devfrom
DHDHLZ:fix/media-path-traversal
Open

fix(media): contain media file resolution inside the store (CWE-22 path traversal)#1319
DHDHLZ wants to merge 1 commit into
TraderAlice:devfrom
DHDHLZ:fix/media-path-traversal

Conversation

@DHDHLZ

@DHDHLZ DHDHLZ commented Sep 2, 2026

Copy link
Copy Markdown

Security fix: GET /api/media/:date/:name allowed arbitrary file disclosure.

What: URL segments were joined into the media path without a containment
check; Hono percent-decodes route params, so a request such as
GET /api/media//..%2F..%2Fconfig%2Fauth.json read files outside the
store (auth.json, accounts.json with broker credentials, and any file
readable by Alice).

Fix:

  1. resolveMediaPath now rejects any result outside MEDIA_DIR (path.relative fence);
  2. the media route only serves known media extensions and answers traversal with 404;
  3. regression specs cover both the fence and the route behaviour.

Verified:

  • npx vitest run --project node src/core/media-store.spec.ts src/webui/routes/media.spec.ts (12 passed)
  • npx tsc --noEmit
  • local live check: the traversal request returns 404 after the fix (was 200 before)

GET /api/media/:date/:name joined URL segments into the media path without a containment check. Hono percent-decodes route params, so ..%2F.. sequences escaped MEDIA_DIR and read arbitrary files readable by the Alice process (e.g. data/config/auth.json, data/config/accounts.json).

Add a path fence in resolveMediaPath (reject any result outside MEDIA_DIR), restrict the route to known media extensions, and cover both with regression specs.
@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

@DHDHLZ is attempting to deploy a commit to the luokerenx4's Team Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant