Skip to content

Security: Insecure dev-script injection via HTTP and document.write#477

Closed
tuanaiseo wants to merge 1 commit intogre:masterfrom
tuanaiseo:contribai/fix/security/insecure-dev-script-injection-via-http-a
Closed

Security: Insecure dev-script injection via HTTP and document.write#477
tuanaiseo wants to merge 1 commit intogre:masterfrom
tuanaiseo:contribai/fix/security/insecure-dev-script-injection-via-http-a

Conversation

@tuanaiseo
Copy link
Copy Markdown
Contributor

Problem

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.

Severity: high
File: packages/cookbook/src/index.js

Solution

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, use https, strict host allowlisting, and avoid runtime script injection in shipped bundles.

Changes

  • packages/cookbook/src/index.js (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

…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>
@gre
Copy link
Copy Markdown
Owner

gre commented Apr 8, 2026

I don't see this being an issue. it's a dev thing.

@gre gre closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants