auth: CODE_INDEX_DAEMON_NO_AUTH is a presence-check and is inherited by the spawned daemon #12
Labels
No labels
code-review
correctness
dos
performance
security
severity/high
severity/low
severity/medium
tech-debt
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
h-dv/code-index#12
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: High · Category: Security (auth bypass)
The daemon disables the capability-token auth whenever
CODE_INDEX_DAEMON_NO_AUTHis present in the environment —var_os(...).is_some()(crates/daemon/src/main.rs:143), so any value counts, even0or empty. The MCP server spawns the daemon withCommand::newand no.env_clear()(crates/mcp-server/src/main.rs:390-397), so the child inherits the full parent environment.Consequence: if the MCP process (or the shell / CI / agent harness that launched it) has
CODE_INDEX_DAEMON_NO_AUTHset for any reason, a production daemon silently starts with auth OFF and no token indaemon.toml— reopening the "any local process can read the whole index over loopback" hole the token was designed to close. The only signal is a warn log.Fix
cmd.env_remove("CODE_INDEX_DAEMON_NO_AUTH").#[cfg(test)]/ a debug-build check rather than a runtime env var.=="1"as enabling (not mere presence).Related
daemon.tomlis0600on Unix only (lifecycle.rs:251-298); on Windows the token file gets default inherited ACLs — a separate low-severity hardening item, tracked in the polish backlog.Filed from a deep multi-agent code review of the workspace (v0.5.7). Severity/category per the review; file:line refs were accurate at review time — verify against current
master.Fixed in
78c5737(branchfix/ultradeep-review-findings).Reassessed on current master — both claims held (
var_os(...).is_some()presence-check in the production path atdaemon/src/main.rs:141; noenv_clear/env_removeon the mcp-server spawn path). Fix enforces the guarantee two ways:cfg!(debug_assertions) && var_os(...).is_some()— so a release-profile production daemon always mints a token regardless of the environment.cmd.env_remove("CODE_INDEX_DAEMON_NO_AUTH")on the spawn path, so a spawned daemon never inherits a stray parent value.Test:
mcp_smoke::spawned_daemon_does_not_inherit_no_auth_envsets the var in the MCP server's own environment, spawns a daemon through the real--daemon-binpath, and asserts the daemon published a non-empty token indaemon.toml. Because the spawned test daemon is a debug build (its compile-gate would otherwise honor an inherited var), this genuinely exercises the env-strip, not just the gate.