Repository navigation
fix(onboard): install only from this machine, on devframe v1.2.5 #1126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
antfubot
wants to merge
4
commits into
main
Choose a base branch
from
deps/devframe-1.2.5
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
80ce3e6
chore(deps): upgrade devframe to v1.2.5
antfubot 206c148
test(onboard): refuse installs nobody confirms in the terminal
antfubot 6090e58
docs(onboard): note that installs wait for a terminal confirmation
antfubot e264e86
fix(onboard): install only for a browser on this machine, without the…
antfubot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| const LOOPBACK_ADDRESS_RE = /^(?:127(?:\.\d{1,3}){3}|::1|::ffff:127(?:\.\d{1,3}){3})$/ | ||
| const LOCAL_HOST_RE = /^(?:(?:[a-z\d-]+\.)*localhost|127(?:\.\d{1,3}){3}|\[::1\])(?::\d+)?$/i | ||
|
|
||
| /** | ||
| * Whether the request comes from a browser on the machine that runs the dev | ||
| * server. The socket must be loopback, which another device cannot fake, and | ||
| * the `Host` a local name, so a tunnel or proxy on this machine that keeps | ||
| * its public host does not count either. | ||
| */ | ||
| export function fromThisMachine(req: { socket: { remoteAddress?: string }, headers: { host?: string } }): boolean { | ||
| return LOOPBACK_ADDRESS_RE.test(req.socket.remoteAddress ?? '') && LOCAL_HOST_RE.test(req.headers.host ?? '') | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { expect, it } from 'vitest' | ||
| import { fromThisMachine } from '../src/this-machine' | ||
|
|
||
| it.each([ | ||
| ['127.0.0.1', 'localhost:3000', true], | ||
| ['::1', '[::1]:3000', true], | ||
| ['::ffff:127.0.0.1', '127.0.0.1:3000', true], | ||
| ['127.0.0.1', 'my-app.localhost', true], | ||
| // Another device, even when it claims a local host | ||
| ['192.168.1.20', 'localhost:3000', false], | ||
| ['::ffff:192.168.1.20', '192.168.1.5:3000', false], | ||
| // A tunnel or proxy on this machine that keeps its public host | ||
| ['127.0.0.1', 'my-app.trycloudflare.com', false], | ||
| ['127.0.0.1', '192.168.1.5:3000', false], | ||
| ['127.0.0.1', 'localhost.example.com', false], | ||
| ['127.0.0.1', undefined, false], | ||
| ])('socket %s with Host %s is from this machine: %s', (remoteAddress, host, expected) => { | ||
| expect(fromThisMachine({ socket: { remoteAddress }, headers: { host } })).toBe(expected) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift
Do not treat a forwarded browser request as server-machine consent.
When a browser opens
http://localhost:<forwarded-port>through SSH port forwarding, the dev server can see a loopback socket and a localhostHost. The browser also sends a matchingOrigin. This callback then approves an install from a browser that is not on the dev server’s machine, without the upstream terminal confirmation. Keep an explicit approval step for this case; socket address andHostalone cannot distinguish it from a local browser. (code.visualstudio.com)🤖 Prompt for AI Agents