Skip to content

feat(enclave): run the PII analyzer inside the enclave - #28

Draft
Marketen wants to merge 2 commits into
mainfrom
feat/enclave-pii
Draft

Marketen wants to merge 2 commits into
mainfrom
feat/enclave-pii

Conversation

@Marketen

@Marketen Marketen commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Why

A key's PII mode is silently ignored on the enclave gateway. The analyzer runs outside the enclave, so masking is switched off there (PII_FILTER_ENABLED=false), and a confidential request to a model whose provider can read the prompt (DeepSeek, Novita) goes out unmasked with no error.

That is the case where masking matters most. On a confidential request the provider sees the prompt but not who sent it, and Nexus knows who sent it but cannot read it. A name or an email inside the prompt breaks the first half of that.

What changes

Only what is needed to mask inside the enclave. Ordinary (non-Nitro) builds behave exactly as before.

  • nexus-enclave-init (apps/gateway/cmd/nexus-enclave-init) is the enclave entrypoint. It reads apps/gateway/enclave/services.yaml, which uses Docker Compose's key names (command, user, working_dir, environment, depends_on, restart), brings up loopback, starts Presidio as uid 1001, starts the gateway once Presidio is healthy, restarts a service that exits (clearing its process group first so a leftover worker cannot hold the port), reaps orphans, and stops everything in reverse order. The gateway launches nothing itself. A service gets a minimal environment unless it sets inherit_env.
  • Dockerfile.enclave: the runtime image is presidio-analyzer:2.2.362 pinned by digest (the version the regular gateway runs), with the gateway and the init added. Same builder and reproducibility rules.
  • Loopback only: a Nitro build refuses to start unless PRESIDIO_ANALYZER_URL is http://127.0.0.1:<port>, and reaches the analyzer through a transport that dials nothing but 127.0.0.0/8. The provider egress allowlist and the manifest are unchanged.

Requests with require_attested_inference still skip masking: their provider cannot read the prompt.

Not in this PR

The analyzer result cache, enclave metrics, new provider routes and the FX fix from #27 are left out on purpose; they are independent and will come as separate small PRs.

Checked locally (2 CPUs and 4 GB, like the enclave)

Check Result
Boot Presidio healthy, then gateway healthy, 9 s after start
Analyzer inside the container Finds PERSON and EMAIL_ADDRESS in a sample text on 127.0.0.1:3000
Presidio killed Restarted by the init, gateway kept answering, no zombie processes
Stop 0.7 s, reverse order
Memory About 800 MiB for the three processes
Tests go test ./... passes; Nitro build compiles and vets
Reproducible build Two --no-cache amd64 builds with rewrite-timestamp (at 173403f): identical image ID and identical PCR0, PCR1, PCR2. Image 582 MB, EIF 1.0 GB (was 40 MB)

Deploying

Needs the companion infrastructure PR: the enclave image grows from 40 MB to about 1 GB, so the enclave needs 4096 MiB instead of 2048, and the bundle must turn PII_FILTER_ENABLED on. Without it the new image does not fit.

Open

  • Presidio speed on the enclave's Xeon 8124M core is unmeasured. Each distinct text field is one analyzer call, so long agent conversations make many; the cache PR addresses that.
  • Enclave boot with a 1 GB image is untested on a real Nitro host.

🤖 Generated with Claude Code

Marketen and others added 2 commits November 24, 2026 17:14
A key's PII mode was silently ignored on the enclave gateway: the analyzer
lived outside it, so masking was switched off there. Confidential requests to
models whose provider can read the prompt went out unmasked.

Run Presidio inside the enclave so masking works on confidential requests
without prompt text leaving measured code:

- nexus-enclave-init is the enclave entrypoint. It reads
  apps/gateway/enclave/services.yaml (Compose-like), brings up loopback,
  starts Presidio as uid 1001, starts the gateway once Presidio is healthy,
  restarts a service that exits (clearing its process group first), reaps
  orphans, and stops everything in reverse order. The gateway launches
  nothing itself. A service gets a minimal environment unless it opts in.
- Dockerfile.enclave: the runtime image is presidio-analyzer 2.2.362 pinned
  by digest, with the gateway and the init added.
- In Nitro builds the gateway refuses a PRESIDIO_ANALYZER_URL that is not
  http://127.0.0.1:<port> and reaches the analyzer through a loopback-only
  transport, so the provider-only egress allowlist is unchanged.

Requests that require attested inference still skip masking: their provider
cannot read the prompt. Ordinary (non-Nitro) builds are unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
working_dir and environment mean what they mean in Docker Compose, so the
file reads like one.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.

1 participant