Security: Insecure dev-script injection via HTTP and document.write#477
Closed
tuanaiseo wants to merge 1 commit intogre:masterfrom
Closed
Conversation
…ocumen
The app conditionally injects a script using `document.write('<script src="http://localhost:8097"></script>')` when `NODE_ENV !== 'production'`. If this code runs in any non-production deployment (including misconfigured staging), it trusts an unauthenticated HTTP endpoint and executes arbitrary JavaScript from it, enabling code execution in the browser.
Affected files: index.js
Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
Owner
|
I don't see this being an issue. it's a dev thing. |
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.
Problem
The app conditionally injects a script using
document.write('<script src="http://localhost:8097"></script>')whenNODE_ENV !== 'production'. If this code runs in any non-production deployment (including misconfigured staging), it trusts an unauthenticated HTTP endpoint and executes arbitrary JavaScript from it, enabling code execution in the browser.Severity:
highFile:
packages/cookbook/src/index.jsSolution
Remove
document.write-based script injection. Gate React Inspector tooling behind compile-time dev flags and use secure/local-only mechanisms (e.g., bundler plugin in dev server). If dynamic loading is required, usehttps, strict host allowlisting, and avoid runtime script injection in shipped bundles.Changes
packages/cookbook/src/index.js(modified)Testing