-
Notifications
You must be signed in to change notification settings - Fork 224
fix SSRF vulnerability in proxy.ts #6794
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
base: main
Are you sure you want to change the base?
Conversation
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success3658 tests passing in 1429 suites. Report generated by 🧪jest coverage report action from 951f207 |
packages/theme/src/cli/utilities/theme-environment/storefront-renderer.ts
Outdated
Show resolved
Hide resolved
|
@EvilGenius13 pointed out there is conditional branching logic in the These are the questions I identified I need to answer in my investigation: And the answers I came up: (for the path without the ext) Both paths will ultimately fail in the new check that I wrote, since in both cases, the hostname will be |
d526b32 to
951f207
Compare
WHY are these changes introduced?
Fixes #947
WHAT is this pull request doing?
Fixes the vulnerability when proxying by introducing a check where if the two host names don't match, the request is not executed and a 502 error is surfaced to the user.
I could have identified hosts preceded by
//and then performed the matching logic or even tried to correct the incorrect host but we (I and Josh) chose to throw an error because it's simpler to do, and the alternate method of rewriting the//path would involve regexes, and we don't want to try loading these requests. This change ensures we block the request. We also chose to throw an error instead of outputWarn as this is a rare but real vulnerability and if it happens, we want the surfaced error message to be loudBaseline behavior:
Malicious request in logs and browser:


How to test your changes?
p build(in editor terminal) on main branchStart the dev server in an external terminal using:
When the server is running, use the
tshortcut to trigger a legitimate request and see the healthy logs outputTo trigger the SSRF detection, visit the malicious URL directly in your browser:
http://127.0.0.1:9292//pokeapi.co/api/v2/pokemon/gengarand see the browser behavior change
Then switch to my branch to see the fix in action:
before testing the new build, kill the server in the external terminal
ctrl-cThen
p buildThen restart the server again
Then run the malicious request again and see the new browser and log behavior:




wrote a new unittest to verify the behavior and all proxy tests pass and all storefront-renderer tests pass