Skip to content

[Security] Harden dev proxy invalid path response against content sniffing - #8537

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
security-maintenance-34852179334
Draft

github-actions[bot] wants to merge 1 commit into
mainfrom
security-maintenance-34852179334

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

The reverse HTTP proxy used during app dev echoes 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-8 content type and X-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 dev and request a path that no proxy rule matches on the proxy port, for example curl -i http://localhost:<proxy-port>/nowhere. The 500 response should carry Content-Type: text/plain; charset=utf-8 and X-Content-Type-Options: nosniff, with the same body as before.

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset with pnpm changeset add

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants