N Noer

OpenCodex credential routing and security boundaries

A security-first OpenCodex guide covering credentials, routing authority, account pools, logs, exposure, and recovery boundaries.

Security starts at the boundary, not at the model

OpenCodex is best treated as a local control plane with real trust boundaries. The first security question is not which provider handles the prompt. The first question is which process may route requests, which machine state may be reused, which logs may store metadata, and whether the service is exposed beyond the local host. Once those answers are blurred, even a well-behaved model backend cannot save the setup.

A proxy like this becomes sensitive because it sits in the middle of identity and traffic. It may read API keys, hold session state, choose among accounts, and forward requests to several external services. That means the boundary is the product. If the boundary is too loose, the rest of the design loses meaning.

Split credentials into separate trust domains

OAuth sessions, API keys, proxy variables, and service manager environments are not interchangeable. They live on different clocks, expire in different ways, and fail for different reasons. Keeping them separate makes the system easier to operate and easier to recover. Mixing them is how operators end up with a failure they can neither explain nor reproduce.

Security also means knowing where secrets should never appear. Screenshots, chat logs, telemetry exports, and casual copy-paste are all common leakage paths. If a credential can be recreated from a log or a pasted config snippet, it is already too exposed.

# check the shell environment without printing secrets themselves
printenv | grep -E 'ANTHROPIC_API_KEY|GOOGLE_API_KEY|XAI_API_KEY' || true

Routing authority is not the same as authorization

It is easy to confuse “which backend should be used” with “whether a request should be allowed”. Those are separate decisions. Routing decides path. Authorization decides permission. If the wrong person can edit routes, the control plane has a governance problem. If a route can send a request to a backend that should not receive that class of prompt, the system has a policy problem.

That distinction matters when multiple people or multiple tools touch the same proxy. A secure setup should make it hard to change the route map casually, and even harder to move sensitive requests into the wrong provider by accident.

Questions a security review should ask first

  • Is the listener bound only to localhost?
  • Can a shared account be removed without affecting others?
  • Do logs expose tokens, full prompts, or reusable sessions?
  • Can the route map be edited without a clear audit trail?

Account pools need revocation and containment

If you run an account pool, you are managing a living risk surface. Each account can fail, expire, be rate-limited, or be compromised. The pool therefore needs a fast revocation path, visible cooldown state, and a way to keep one bad account from contaminating the rest. If an account is suspected to be compromised, removal should be quick and boring.

Containment matters because the pool can easily become the shared heart of the system. Long-lived sessions may be pinned to a single account, which is fine until that account becomes unhealthy. Then the proxy should know how to stop using it, shift new traffic away, and preserve the evidence needed to explain the event later.

Keep the network surface narrow

Local proxies are safest when they stay local. The minute you expose the listener to the network, the trust story changes. Port forwarding, reverse proxies, and shared LAN access all widen the boundary. That does not make them wrong, but it does mean you must revisit authentication, logging, and account handling. Local by default is the sane baseline.

If you do decide to put another layer in front, make that change consciously. Document which host can reach the proxy, whether the proxy should reject non-local requests, and how you intend to protect credentials from being visible through a wider network path. Security boundaries should get tighter, not fuzzier, as the surface expands.

Logs should help you respond to an incident

Logs are not just for debugging. In a security review, the valuable records are the ones that let you answer what changed, when it changed, which account handled it, and whether the event involved a failed login, a revoked key, or an unexpected route. The right log format turns a vague suspicion into a concrete timeline.

Do not keep more sensitive material than you need. If you need metadata, keep metadata. If you need a route decision, keep the route decision. Dumping full request bodies into long-term logs makes for a bigger blast radius later. Secure systems record enough to reason, not enough to replay everything forever.

Security-friendly logging tends to include

FieldWhy keep it
Session IDLets you connect events without exposing content
Selected providerShows where traffic actually went
Account stateExplains why one credential was chosen or skipped
Error classSeparates auth failure from transport failure

Secret handling must survive restarts and user changes

One of the most common security mistakes is to make the first run work in the current shell and then forget that the daemon or future login may not inherit the same environment. If a secret only exists in one interactive session, the setup is fragile. If it exists in too many places, the setup is noisy. The right answer is an intentional storage point plus a verified startup path.

That same logic applies to migrations. When moving from manual launch to a service manager, re-check where the process will read its credentials from and whether the GUI or account pool still sees the same state. Security issues often arrive as deployment mismatches, not obvious hacks.

Different threat models demand different defaults

A solo machine used by one person is not the same as a shared workstation. A private proxy is not the same as a team proxy. A proxy that only forwards low-risk prompts is not the same as one that can touch sensitive credentials or long-lived sessions. The right default settings depend on who else can reach the system and what kind of content travels through it.

That is why “it works on my machine” is such a weak security argument. A setting that is harmless in one environment may become dangerous in another. If the proxy is to live long-term, the safer posture is to design it for the stricter environment first and relax it only when the boundary really allows that.

Incident response should already be part of the design

If an account gets revoked, a token leaks, or a route behaves unexpectedly, the operator should know the next move before panic begins. Disable the affected account, preserve the relevant logs, confirm whether other accounts are isolated, and verify the listener is still only reachable where intended. A good proxy makes these steps quick.

Incident response is not about dramatic tools. It is about short paths from detection to containment. A system with a clear revoke button, a readable state model, and a limited network surface is much easier to defend than one that only looks flexible on paper.

How to decide whether the security cost is worth it

If your workflow has one provider, one credential, and no shared access, OpenCodex may be more control than you need. But once you start juggling account pools, different providers, GUI visibility, or external access, the security questions become unavoidable. At that point, the proxy is not just a convenience layer. It is a boundary manager.

The adoption test is simple: if you can clearly answer where secrets live, who can change routing, how to revoke one account, and what gets written to logs, then the system is probably within your comfort zone. If those answers are fuzzy, the design still needs work before it should be trusted.

GUI access is also a security boundary

Do not treat the GUI as harmless just because it looks like an inspection surface. If it can reveal account state, provider names, failure patterns, or route decisions, it exposes operational information. If it can write changes, it becomes a control surface. That means GUI access should be limited with the same seriousness as configuration access.

A safe default is to use the GUI locally and keep write actions deliberate. If the interface is opened to another user or another machine, document what that user can see and change. A beautiful dashboard is still a boundary once it controls live traffic.

Backups should not become secret archives

Configuration backups are useful, but they can quietly become secret archives if they include tokens, session files, or account exports. Backup only what you need to reconstruct policy, and store secrets through the mechanism you actually trust. A stale backup with a valid credential can be more dangerous than the live config.

During recovery, restore policy first and credentials second. That order forces you to confirm the route map before reintroducing sensitive material. It also avoids the habit of copying every old file back into place just because it made the service work once.

Adoption requires a security owner

If OpenCodex becomes part of a team workflow, someone must own the security posture. That person does not need to approve every prompt, but they should own credential storage, route permissions, account revocation, and log retention. Without an owner, the proxy will gradually collect exceptions until nobody understands the risk.

The decision to adopt should therefore include an ownership question. If no one wants to own the boundary, keep the setup personal and local. Shared control planes without clear owners are rarely safer than simple individual setups.

Rotation should be routine, not an emergency

Credentials should not only be rotated after an incident. Routine rotation is healthier because it proves the system can recover without drama. When a key is refreshed or an account is replaced, the proxy should keep the route structure intact and simply rebind the identity. If rotation always feels like an outage, the credential model is too brittle.

Routine rotation also surfaces weak spots early. If a new key is not picked up correctly, or a stale session keeps being preferred, you find out during a calm change window rather than after a leak.

Keep secrets away from browser-visible surfaces

If the GUI includes account state, it should still avoid showing anything that could be copied into screenshots and reused later. A secure interface tells you enough to operate, but not enough to reconstruct secrets from the page. That means masking, redaction, and careful labels are part of the design, not extra polish.

Security often fails in the visible parts of the stack, not the hidden ones. The proxy may be technically safe but still leak too much through the dashboard. Good boundary design accounts for that.

Document the trust model before sharing the setup

If anyone else will touch the system, write down the trust model first. Who may authenticate, who may route, who may inspect logs, who may revoke an account, and who may change the exposed surface. Without that document, the system slowly becomes more permissive than intended.

That document does not need to be long. It just needs to make the boundary visible. Once the boundary is visible, the rest of the controls become easier to defend.

Separate GUI visibility from GUI authority

A GUI can be safe for observation while still being risky for live changes. Operators may need to see selected providers, account health, and error classes, but only a smaller group should be able to rewrite route policy or re-enable a suspended account. Treat those permissions as separate decisions.

This distinction keeps investigations fast without turning every viewer into an administrator. It also makes screenshots and shared debugging sessions less dangerous, because the interface can expose status without exposing controls that affect traffic.

Design backups around recovery, not hoarding

Backups should preserve the policy needed to rebuild the system, not every secret the system has ever touched. Route maps, service definitions, and redacted examples are useful. Raw tokens, browser sessions, and exported account material belong in a dedicated secret store or should not be backed up at all.

During recovery, restore the policy first and bind fresh credentials second. That order proves the boundary still makes sense before sensitive material returns to the process.

Name an owner for each boundary

Shared OpenCodex deployments need explicit ownership for credentials, route policy, GUI permissions, log retention, and account revocation. The owner does not need to approve every request, but someone must be responsible for keeping the boundary understandable.

Ownership also gives exceptions a place to go. Temporary routes, extended debug logs, or suspended accounts should have a person who knows why they exist and when they should be reviewed.