# GHSA-2r2p-4cgf-hv7h: The local HTTP server started by `engram server` (binding `127.0.0.1:7337` by default) was exposed to any browser origin with no

> A malicious web page can exfiltrate local knowledge graph data and inject persistent prompt injection payloads into the user's AI coding agent via CSRF.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 22 Apr 2026

## What is GHSA-2r2p-4cgf-hv7h?

GHSA-2r2p-4cgf-hv7h is a vulnerability in engramx, published on 22 Apr 2026. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

### Summary

The local HTTP server started by `engram server` (binding `127.0.0.1:7337` by default) was exposed to any browser origin with no authentication unless `ENGRAM_API_TOKEN` was explicitly set. Combined with `Access-Control-Allow-Origin: *` on every response and a body parser that did not require `Content-Type: application/json`, this allowed a malicious web page the developer visited to:

1. **Exfiltrate** the local knowledge graph via `GET /query` and `GET /stats` (function names, file layout, recorded decisions/mistakes).
2. **Inject persistent prompt-injection payloads** via `POST /learn`, which wrote `mistake`/`decision` nodes that were later surfaced as system-reminders to the user's AI coding agent on every future session and file edit.

Severity: **High** — confidentiality + persistent indirect prompt injection against the user's coding agent.

### Affected versions

`engramx` >= 1.0.0, < 2.0.2 — any version that shipped the HTTP server.

### Patched in

`engramx@2.0.2`

### Workarounds (if you cannot upgrade)

- Do **not** run `engram server` or `engram ui`.
- If developers must, set `ENGRAM_API_TOKEN` to a long random value and terminate the server before browsing the web.

### Remediation (applied in 2.0.2)

1. Fail-closed auth on every non-public route — Bearer header or HttpOnly cookie, constant-time comparison, 256-bit auto-generated token at `~/.engram/http-server.token` (0600).
2. Wildcard CORS removed entirely; default is no CORS headers. Opt-in allowlist via `ENGRAM_ALLOWED_ORIGINS`.
3. Host + Origin validation — rejects DNS rebinding and Host spoofing.
4. `Content-Type: application/json` enforced on mutations — blocks the text/plain CSRF vector.
5. `/ui?token=` bootstrap with `Sec-Fetch-Site` gate — prevents cross-origin oracle probing.

### Credit

Discovered and responsibly disclosed by @gabiudrescu in engram issue #7.

## Which versions are affected by GHSA-2r2p-4cgf-hv7h?

2 open source packages ship an affected version, including engramx.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `engramx` | npm | All versions | 2.0.2 |
| `engramx` | npm | All versions | 2.0.2 |

## How do I fix GHSA-2r2p-4cgf-hv7h?

Upgrade engramx to 2.0.2 or later.

## Is GHSA-2r2p-4cgf-hv7h being exploited?

There is no known exploitation of GHSA-2r2p-4cgf-hv7h in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-2r2p-4cgf-hv7h and fix it if it is affected.

What it is: GHSA-2r2p-4cgf-hv7h is a vulnerability in engramx, published on 22 Apr 2026. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-2r2p-4cgf-hv7h in the wild and no public exploit code.

Affected packages and fixed versions:
- engramx (npm): affected all versions; fixed in 2.0.2
- engramx (npm): affected all versions; fixed in 2.0.2

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-2r2p-4cgf-hv7h/ (Markdown: https://insights.sbomify.com/GHSA-2r2p-4cgf-hv7h/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-2r2p-4cgf-hv7h

---
From sbomify Insights: https://insights.sbomify.com/GHSA-2r2p-4cgf-hv7h/
Summaries are generated and may contain mistakes; the official description above is the record.
