Skip to content

fix: 403 on asset downloads in Guest Mode - #4

Open
alaporterie wants to merge 1 commit into
SegFault42:mainfrom
alaporterie:fix/guest-mode-download-403
Open

fix: 403 on asset downloads in Guest Mode#4
alaporterie wants to merge 1 commit into
SegFault42:mainfrom
alaporterie:fix/guest-mode-download-403

Conversation

@alaporterie

Copy link
Copy Markdown

Summary

  • /api/download proxies asset fetches through an origin allowlist (R2, kie.ai, replicate) to guard against SSRF. In Guest Mode, generated/uploaded files live on local disk and are served at a relative /generated/... path — not in that allowlist, so every download click returned 403 Forbidden.
  • Local-file exception is gated on GUEST_MODE (not just URL shape) so it stays inert in cloud/R2 deployments.
  • Re-checks the resolved pathname after building the absolute fetch URL — the raw prefix check alone would let /generated/../api/... resolve to an internal route, turning the download proxy into same-origin SSRF.

Test plan

  • Guest Mode: clicking download on a generated video/image now returns the file instead of 403
  • /generated/../... style paths rejected with 403
  • Maintainer smoke test on cloud/R2 mode (should be unaffected — gated on GUEST_MODE)

🤖 Generated with Claude Code

/api/download proxies asset fetches through an origin allowlist (R2, kie.ai,
replicate) to prevent SSRF. Guest Mode stores generated/uploaded files on
local disk and serves them at a relative "/generated/..." path, which isn't
in that allowlist — every download click returned 403.

Gate the local-file exception on GUEST_MODE (not just URL shape, so it's
inert in cloud deployments) and re-check the resolved pathname after
building the absolute fetch URL, since the raw prefix check alone would let
"/generated/../api/..." resolve to an internal route — turning the proxy
into same-origin SSRF.
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