Repository navigation
fix(agent): source server-side secrets only from the launchd env file - #231
Merged
Merged
Conversation
Installing the launchd agent with the default CN_AGENT_ENV_FILE pointed at ~/.contextnest/tenant-auth/server.env silently changed the API's security posture: that file carries CONTEXTNEST_TENANTS_FILE, which flips Registry:: from_env from None to a tenant registry and makes every route require Authorization. The substrate booted healthy and then answered 401 "unauthorized scope" to every client that does not speak tenant auth — the contextnest MCP server (no auth headers at all), the dashboard, and the curl recipes. The file was written for clients, not the server: it also holds CONTEXTNEST_OPERATOR_HEADERS (a curl --header @file path) and CONTEXTNEST_LIBWIT_TOKEN. Meanwhile the agent needs exactly one thing from it: the embedding key. Default the agent at agent.env — server-side secrets only — and say so in the template. The split is documented in both places so a later re-install cannot regress it. Co-Authored-By: Claude Code <noreply@anthropic.com>
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.
Problem
Installing the launchd agent with the default
CN_AGENT_ENV_FILE(
~/.contextnest/tenant-auth/server.env) silently changed the API's securityposture. That file contains
CONTEXTNEST_TENANTS_FILE, andRegistry::from_env—let Ok(file) = std::env::var(...) else { return Ok(None) }— turns that into tenant mode: every route now requires
Authorization.Observed live after the agent install: the process booted, armed the watchdog,
restored 543 k fragments, and then answered
to the contextnest MCP server (which sends no auth headers at all), and would
do the same to the dashboard and the
docs/usage.mdcurl recipes.server.envis a client file: besides the tenant registry it holdsCONTEXTNEST_OPERATOR_HEADERS(acurl --header @filepath) andCONTEXTNEST_LIBWIT_TOKEN. The agent needs exactly one thing from it — theembedding key.
Change
CN_AGENT_ENV_FILEnow defaults to~/.contextnest/tenant-auth/agent.env,documented as server-side secrets only.
install cannot regress it.
CLAUDE.md'sCONTEXTNEST_VOLUME_WATCHrow now describes the sentineldescriptor from fix(watchdog): detect a remount that keeps its device number #230, not just
st_dev/st_ino.Operators who want tenant mode can still point
CN_AGENT_ENV_FILEat atenant-bearing file — but then every client must be taught to present the
operator header first.
Verification
agent.env;/api/v1/substrate/health→200without headers;
cn_healthMCP tool returns the subtree counts again.plutil -lint.🤖 Generated with Claude Code