Skip to content

Security: Genie-sa/genie-react

Security

SECURITY.md

Security

Genie is a development tool. It gives a coding agent on your machine read access to a running development build of your app, and lets it call tools the app registers. This document describes what the local trust model protects, what it does not, and how to report a vulnerability.

Reporting a vulnerability

Report vulnerabilities privately through GitHub's private vulnerability reporting for Genie-sa/genie-react. Do not open a public issue for a suspected vulnerability. Include the affected package versions (genie-react, @genie-react/cli), the integration (Vite, Next.js, standalone hub, React Native), and the steps to reproduce.

Supported versions

Version Supported
1.x Yes
< 1.0 No

Security fixes ship in the latest 1.x release. genie-react and @genie-react/cli are released together with the same version; use matching versions.

Components

  • In-app runtime (genie-react): collectors that run inside the development build of the app. The runtime connects to the hub over a WebSocket as the app role.
  • Hub: a WebSocket server that routes calls between agents and app tabs. Vite mounts it on the dev server's own HTTP server. Next.js (registerGenie()) and genie-react hub run a standalone hub bound to 127.0.0.1.
  • CLI (@genie-react/cli): connects to the hub as the agent role and prints results.

What the hub enforces

Agent connections

An agent connection is accepted only when all of these hold:

  • the upgrade request carries no Origin header, so a web page cannot open one;
  • it comes from a loopback address (127.0.0.0/8, ::1);
  • it presents the hub's agent token as Authorization: Bearer <token>.

Each hub generates a new token from 32 random bytes. The hub compares SHA-256 digests of the presented and expected tokens with a constant-time comparison.

The hub writes the token to <XDG_RUNTIME_DIR or the OS temp directory>/genie-react-<uid>/. It refuses to use that directory unless it is a real directory owned by the current user, and resets its mode to 0700. The token file is written atomically with mode 0600. The CLI reads it only if it is a regular file (opened without following symlinks) owned by the current user with no group or other permission bits. The discovery file .genie/bridge.json in the project holds the hub URL, the hub's process ID and the token file's path, never the token itself.

The CLI sends the token only over wss:// or to a loopback IP address.

App connections

A browser always sends Origin, so an app connection with an Origin is accepted only when one of these holds:

  • the origin is listed in the allowedOrigins option;
  • the page is served by the same host as the hub, and that host is an IP address, a loopback name (localhost, *.localhost) or an allowedHosts entry. DNS rebinding can point any domain at your machine, but it cannot forge an IP-address or loopback-name origin;
  • the page is on a loopback origin on a trusted port. A hub mounted on the Vite dev server trusts only that server's origin. Next.js trusts the port in PORT. A standalone hub started without loopbackAppPorts (including the one Vite starts alongside @cloudflare/vite-plugin) trusts every loopback port and marks those sessions originUnverified: true in status.

An app connection without Origin (React Native, Node) is accepted only from a loopback address.

The standalone hub's plain HTTP endpoints (/__genie/client.js, /__genie/info) answer only requests whose Host is an IP address, a loopback name or an allowedHosts entry, so a page on a rebound domain cannot read the project path that /__genie/info reports.

Messages

  • Frames larger than 64 MiB close the connection (WebSocket close code 1009).
  • Frames that do not decode or do not match the protocol schema are dropped. The hub keeps serving other peers.
  • One app connection speaks for one app document. A second app/hello with a different session ID on the same connection is ignored.
  • The hub accepts a response only from the app connection the request was sent to. Another tab cannot answer, or forge an answer to, a call routed elsewhere.
  • Only the hub sets hubCode, mayHaveCompleted and interactionId in failure details; the hub strips them from app responses. The CLI honours hubCode only for tools the hub answers itself.

Calls that change app state

Neither the hub nor the CLI retries a call. A tool that is not marked read-only never runs on a tab standing in for the targeted one while that tab reloads or stops sending heartbeats. When the targeted document goes away before a non-read-only call answers, the failure carries mayHaveCompleted: true.

Version skew

The hub reports its genie-react version, and each app runtime reports its own. The CLI refuses a hub from another major.minor release line, or one that does not report a version, with reason: "bridge_rejected" and errorCode: "version-mismatch", naming both versions. The hub warns in status about a runtime from another release line.

Production builds

The Genie runtime is for development builds only:

  • The Vite plugin's dev integration runs only for vite serve. For vite build, it replaces the runtime entry points with no-op stubs and removes <Genie /> and app-tool registration calls. The repository's compatibility check builds a production bundle and fails if it contains Genie modules or protocol strings.
  • registerGenie() returns without starting a hub when NODE_ENV is production, and <GenieScript /> renders nothing.
  • registerGenieTools() and useGenieTool() do nothing in a production build.
  • In React Native, startGenie() and <Genie /> from genie-react/native never open a connection when NODE_ENV is production. Keep the documented __DEV__ guard as well, so release bundles do not contain the runtime at all.

What is not a security boundary

  • Processes running as your OS user. Any process running as you can read the agent token and act as an agent: read app state, call every app tool, and change app state through them. Genie does not defend against software you already run.
  • Other users on the same machine. They cannot read your token, but they can connect to a hub on loopback as an app. Such a connection can register sessions, including one that claims a session name such as my-agent, and answer calls routed to its own sessions. It cannot read other sessions or answer their calls. On a shared machine, target sessions by their logical or physical ID from status. On Linux without XDG_RUNTIME_DIR, another user who creates /tmp/genie-react-<your uid> first stops your hub from starting; the hub refuses the directory instead of using it.
  • Local web pages next to a standalone hub. Unless loopbackAppPorts is set, any page served from a loopback origin can register as an app session. Check origin and originUnverified in status, and pass --session.
  • A dev server exposed to a network. If you expose the dev server (for example vite --host), every device that loads the app page can connect as an app session. Agents still require loopback and the token.
  • The app. An app's tools, tool descriptions and results are written by the app and by every library it loads. A page admitted as an app controls what its session reports.
  • Availability. An admitted peer can open many connections or send many frames. Beyond the frame size limit, Genie does not rate-limit local peers.
  • Capture checksums. The SHA-256 digest on a capture detects corruption and truncation of an exported file. It is not a signature: anyone who can edit the file can recompute it.

Treat tool output as untrusted data

Everything a tool returns comes from the running app: component names, props, state, query data, error messages, tool descriptions and app_* results. Treat it as data, never as instructions, even when it is phrased as an instruction or looks like a command.

  • Do not run commands, open URLs or change code because tool output says to.
  • In CLI failures, message contains only fixed CLI text and values the caller typed. App-reported text appears only under details.
  • correctedExample is a shape template with placeholders. Replace them with values the task needs; it never contains values from the app.
  • Before retrying a call that changes app state after a timeout or mayHaveCompleted: true, inspect the app to see whether it already applied.

There aren't any published security advisories