Skip to content

security: a missing or unreadable user config is silent (CODECORA_HOME, unset HOME, unreadable path) #864

Closed

Description

@ajianaz

Version

develop at 584d63a. Item 2 of the not-fixed list of #858. DESIGN DECISION: options and my recommendation below; I will not implement before the owner answers.

Operating system

Any.

What happened?

The user config is the only source of [sandbox], [sandbox.consumers], [secrets], [delegation], hook routes, profiles and the approval allow/trust lists. Where it is read decides whether any of that applies:

So CODECORA_HOME=/empty (or a foreign directory, a typo, HOME unset in a service unit, a path the process cannot stat) silently runs with defaults: sandbox off, consumers off, default secret release, no hook routes, no owner allow list. cron/setup.rs::user_config() has the same filter(|p| p.exists()). This is also the owner's legitimate override (a test home, a second profile), so the environment alone cannot tell an attack from a choice.

Callers (grep): load_user_config has one production caller, main.rs startup (plus tests); user_config_path is used by main.rs, serve.rs, doctor.rs, sandbox_cmd.rs, hook_cli.rs, cron/setup.rs, delegation/ledger_file.rs, skill/curator.rs and config/mod.rs.

What did you expect to happen?

A user config that the owner has, but this process cannot read or did not look for, must not look the same as "no user config".

Options

A. Fail closed on an unreadable path. try_exists() in both loaders; Ok(false) stays "no config", Err(e) (permission denied, I/O error, not a directory) is a startup error naming the path. Small, no trade-off for the owner. Inside a command sandbox the data dir is masked (absent, so Ok(false), unchanged).
B. Make absence visible. When the file is absent, print one line: tole: no user config at <path> (sandbox, approvals and secret release use their defaults). To keep an owner's attended runs quiet: once per process, only when the root came from CODECORA_HOME or is unresolvable (HOME unset), or the run is unattended or under a session. tole doctor and config check already show the path.
C. Pin the config path across a session. The session host passes the resolved user config path (and its hash) to children (agent_start, delegation) and a child refuses to start when it resolves a different one or none. Only protects children tole itself starts; an unsandboxed script that clears its environment is untouched (same class as item 1: an env marker), so it does not close the hole it is aimed at.
D. Ignore CODECORA_HOME under a session or an unattended face. Always $HOME/.codecora there. Breaks the legitimate override for serve, cron and tests that set it; rejected.

Recommendation

A and B together (B limited as described), plus documenting that the boundary for an attacker who controls the environment is the command sandbox ([sandbox.consumers] run_command = required masks the data dir). Not C or D. A is small and certain; B turns the silent no-config into a visible one without changing the owner's attended runs.

Tests (if A and B are chosen)

A unit test of load_user_config with an unreadable directory (mode 000) failing closed and a missing file returning None; e2e: CODECORA_HOME pointing at an empty dir under TOLE_UNDER_SESSION prints the notice and an owner at a terminal with the default path does not; the existing config_*, main_gate_tests.rs, cron_* and layering rerun. Each must fail without the fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions