fix(dev-server): validate open-url targets - #1416
Draft
dannyhw wants to merge 1 commit into
Draft
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 44ecf65 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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
/open-urlrequest bodies before invoking the operating-system openerhttp:andhttps:URLsopen@10@callstack/repack-dev-serverWhy
The endpoint passed the request-provided
urldirectly toopen(). That package accepts files and executables in addition to URLs, and its Windows implementation interpolates the target into PowerShell. This left the unauthenticated development-server route vulnerable to uncontrolled path/process targets and addresses code-scanning alert #3.Impact
Normal React Native
http:andhttps:browser links continue to work without configuration or API changes. Invalid bodies, paths, executable targets, and non-browser schemes now receive HTTP 400 and never reachopen().Test plan
2files,26tests)What user-facing behavior uses
/open-url?React Native's dev-only
openURLInBrowser()helper posts a URL to this endpoint. The React Native New App Screen uses that helper for its Learn & Explore cards: tapping a card such as DevTools opens the documentation in the default browser on the computer running the development server, rather than inside the simulator or device.The Re.Pack tester app renders its own test dashboard and does not currently include
@react-native/new-app-screenor another caller ofopenURLInBrowser(). Therefore it has no existing on-screen control that reaches/open-url. Pressingjexercises the separate/open-debuggerroute and is useful only as a general developer-workflow regression check.Manual tester-app validation
To expose the real user interaction temporarily, add the React Native helper and the tester app's existing button to
apps/tester-app/src/App.tsx:Then add this section inside
SectionContainer:These are local test-only edits and should not be committed.
From the repository root, start the tester-app development server:
In a second terminal, launch either platform:
pnpm --filter tester-app ios # or pnpm --filter tester-app androidTap Open React Native docs in the tester app.
Expected:
https://reactnative.dev/opens in the default browser on the computer running the development server, and the tester app remains running. This exercises the same React Native helper and/open-urlrequest used by New App Screen links.In the development-server terminal, press
rand verify the app reloads, then pressjand verify React Native DevTools opens and connects.Verify a non-browser target is rejected at the endpoint boundary:
Expected: HTTP 400 with
Invalid URL, with no browser, file, or application opened.Remove the temporary tester-app edits.
The positive check is intentionally user-facing. The rejected-target check remains direct because no legitimate React Native UI should generate a file, executable, or non-browser URL for this endpoint.