1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//! Hardcoded baselines: credential paths, protected project subdirs, etc.
//!
//! These are the kernel-enforced defaults that apply *regardless* of the
//! [`crate::policy::SandboxPolicy`] passed in. The policy can *augment*
//! these baselines (Phase 1+) but cannot weaken them — they're the floor.
//!
//! All lists ported verbatim from `koda-core/src/sandbox.rs` to preserve
//! Phase 0's byte-identical-behavior guarantee.
// ── Sensitive credential paths ───────────────────────────────────────────────
//
// Two tiers of credential protection:
//
// 1. **Write-only deny** (most paths) — CLI tools can *read* their own
// credentials (e.g. `gh`, `aws`, `kubectl`, `ssh`) but sandboxed
// commands cannot modify them. Matches Codex's model.
//
// Risk accepted: a sandboxed command *can* read credentials and could
// exfiltrate them over the network. Network-level egress restriction
// (Phase 3) is the proper mitigation — blocking reads without blocking
// network is security theater (#855).
//
// 2. **Full read+write deny** (`koda/db` only) — koda's own API keys live
// in a SQLite DB at `~/.config/koda/db/koda.db`. The koda process runs
// *outside* the sandbox and doesn't need sandboxed-command access.
// Blocking reads here prevents a `sqlite3` one-liner from dumping
// every stored API key (#847).
/// Credential *directories* under `$HOME` that are **write-protected**.
/// Reads are allowed so CLI tools can authenticate.
pub const CREDENTIAL_SUBDIRS: & = &;
/// Credential directories under `$HOME/.config/` that are **write-protected**.
/// Reads are allowed so CLI tools can authenticate.
pub const CREDENTIAL_CONFIG_SUBDIRS: & = &;
/// Credential directories under `$HOME/.config/` where **both reads and
/// writes** are denied. These contain koda's own secrets that sandboxed
/// commands have no legitimate reason to access.
pub const CREDENTIAL_CONFIG_FULL_DENY: & = &;
/// Individual credential *files* under `$HOME` that are **write-protected**.
/// Reads are allowed so tools like `curl`, `git`, `npm`, and `docker` can
/// authenticate.
pub const CREDENTIAL_FILES: & = &;
// ── Agent-file write protection ──────────────────────────────────────────────
//
// Prevent sandboxed commands from modifying koda agent definitions or the
// project-level system prompt. Same pattern as Claude Code blocking writes
// to `.claude/settings.json` — modifying these files could alter system
// prompts, tool access, or sandbox policy on next session.
/// Directories under the project root that are write-protected. Agent JSON
/// files control system prompts and tool access — a sandboxed command must
/// not be able to modify them.
pub const PROTECTED_PROJECT_SUBDIRS: & = &;
// ── Default writable system paths ────────────────────────────────────────────
/// Filesystem locations every sandboxed process may write to regardless of
/// policy. Phase 0 hardcodes the list; Phase 1 will let `FsPolicy.allow_write`
/// extend it.
pub const DEFAULT_WRITE_LITERALS: & =
&;
/// Subpaths under `$HOME` that are writable by default — common package
/// caches that would otherwise force re-downloads on every invocation.
pub const DEFAULT_WRITE_HOME_SUBDIRS: & = &;