Repository navigation
feat(forward): per-program identities, Discord, wire record and an egress ceiling — plus two forward-auth fixes - #8
Merged
Conversation
Idea credit: NVIDIA's Open Agent Safety Platform — monitoring on the node's only path to the model, out of the agent's reach. The agent's audit log lives in the process it audits, so a compromised agent can drop entries. With PROXY_WIRE_RECORD set, the forward proxy appends one line per model response (OpenAI chat/Responses and Anthropic, JSON or SSE): host, path, status, model, request hash, size, and the tool calls the model returned as names + argument hashes — never text. Lines are hash-chained, so an edit, deletion or reordering breaks the chain (python -m secrets_proxy.wire_record verify). Tamper-evident, not tamper-proof: keep the file writable only by the proxy and anchor the head hash off the box. Recording never breaks a response.
Dev and prod can share the forward proxy; the caller label (the proxy username) is captured before the credential is stripped and written on each wire line, so a check runs against one instance's traces.
…licy change opens Idea credit: NVIDIA OpenShell's policy prover. - PROXY_EGRESS_CEILING: an outer boundary in the policy format, checked before the policy on every request. Outside it is denied outright and never asked about, so no person's answer, timed grant or policy edit can exceed it. Startup logs every policy rule that reaches past it. - python -m secrets_proxy.egress_policy diff OLD NEW [--ceiling] [--forward-map]: every request shape the new policy treats more permissively, marking credential-bearing ones and ones beyond the ceiling; exits 1 when anything opened. An honest comparison over the rules' own vocabulary, not a proof.
… after stripping it Every injection audit line said caller=-. Read the caller once, before the strip, and use it for both the audit line and the wire record.
HTTPS sends the proxy credential on the CONNECT only; the tunnelled requests carry none, and auth ran only in the request hook. So setting PROXY_FORWARD_AUTH_TOKEN refused every HTTPS request, right token or not — which is why no deployment runs with it. Authenticate at http_connect and remember the caller per client connection (the shape of mitmproxy's own proxyauth addon). Also: the audit line read the caller after the credential was stripped, so it always said caller=-.
…hat name programs Idea credit: NVIDIA OpenShell's per-program network policy. - PROXY_FORWARD_CALLERS: a file of program name -> token hash. A request's identity is WHOSE TOKEN MATCHED, never the free-form Basic username. The main token identifies as PROXY_FORWARD_AUTH_NAME (default prax). python -m secrets_proxy.callers new NAME prints a token and its entry. - Rules (policy and ceiling) take "callers": [...]. Answers are remembered per program, questions name the program, diff reports per program. - Honest limit: separates components with separate environments, not processes sharing one; per-binary attribution is not built.
Plain http:// to an injection host got the key injected and sent unencrypted (reproduced live with a fake key). Now it goes out without the credential, as if none were configured, with a warning. Idea credit: Agent Substrate's egress credential injection, which skips cleartext likewise.
…injection, one caller only
- header:<Name> rules take a prefix ("Bot " for Discord REST).
- ws-json:<path> rules set the credential in client->server WebSocket text
messages (Discord IDENTIFY/RESUME at d.token); wss only.
- Rules can name callers; an exclusive rule must, or the proxy refuses to
start — two instances holding a bot token both answer every message.
Verified with real discord.py through real mitmproxy against a fake Discord.
… feat/discord-gateway-injection
…ord-gateway-injection # Conflicts: # README.md # docker-compose.yml # secrets_proxy/mitm_addon.py # tests/test_forward_auth.py
This was referenced Oct 2, 2026
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.
This PR now carries all six open proxy PRs, because stacked PRs re-conflict after every squash merge. #3, #4, #5, #6 and #7 are folded in here and closed with a pointer. Merge this one.
Fixes
PROXY_FORWARD_AUTH_TOKENset, every HTTPS request was refused. The credential arrives on the CONNECT; it is now authenticated there, and the caller is remembered per connection.http://to a credential host had the real key injected; now it goes out without it.caller=-. It read the credential after stripping it.Features
egress_policy diffto show what a policy change newly opens (idea: NVIDIA OpenShell's policy prover).callers.Botprefix.ws-json:d.token.exclusiverules must name their callers, so a dev instance can never become the bot too.Verified
Unit: 111 passed, ruff clean,
docker compose configvalid.Live, in real
mitmproxy/mitmproxy:latestwith fake keys and fake upstreams, on this combined branch:verify: chain intactEarlier live runs, per piece:
Not run against Discord itself.