fix: 403 on asset downloads in Guest Mode - #4
Open
alaporterie wants to merge 1 commit into
Open
Conversation
/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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/api/downloadproxies 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 returned403 Forbidden.GUEST_MODE(not just URL shape) so it stays inert in cloud/R2 deployments./generated/../api/...resolve to an internal route, turning the download proxy into same-origin SSRF.Test plan
/generated/../...style paths rejected with 403GUEST_MODE)🤖 Generated with Claude Code