[Security] Harden dev proxy invalid path response against content sniffing - #8537
Draft
github-actions[bot] wants to merge 1 commit into
Draft
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
…text The reverse proxy used during `app dev` echoes the requested path back in a 500 response without a content type, so browsers content-sniff the body. Set an explicit text/plain content type and X-Content-Type-Options: nosniff. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
WHY are these changes introduced?
The reverse HTTP proxy used during
app devechoes the requested path back to the client when no routing rule matches it. The response is sent without an explicit content type, so browsers fall back to content sniffing and may interpret the reflected path as HTML. That makes the local dev server vulnerable to a reflected content-injection issue in its own origin, reachable from any page the developer happens to have open.WHAT is this pull request doing?
Send the "invalid path" error with an explicit
text/plain; charset=utf-8content type andX-Content-Type-Options: nosniff, so the reflected path can never be treated as markup. The status code and message are unchanged, and a regression test covers the new response headers.How to manually test your changes?
Run
shopify app devand request a path that no proxy rule matches on the proxy port, for examplecurl -i http://localhost:<proxy-port>/nowhere. The 500 response should carryContent-Type: text/plain; charset=utf-8andX-Content-Type-Options: nosniff, with the same body as before.Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add