Commit Graph

14 Commits

Author SHA1 Message Date
subrih 3c941eae23 fix: deep-copy nested scripts policy objects in mergeAccessPolicy, use SEATBELT_WRITE_OPS
- mergeAccessPolicy !base fast-path: scripts["policy"] and per-script entry.policy were
  shallow-copied, leaving them as references into the cached _fileCache object.
  autoExpandBareDir mutations would propagate back into the cache, violating the invariant
  established by the policy-copy fix. Now deep-copied via Object.fromEntries map.
- exec-sandbox-seatbelt: replace hardcoded "file-write*" with SEATBELT_WRITE_OPS constant
  in the /tmp write allowance branch, consistent with all other allowance lines in the file.
- Tests added for nested scripts deep-copy invariant.
2026-03-14 16:20:02 -07:00
subrih 8848bb82e9 fix: cross-layer enforcement gaps and cache mutation (vettri review)
- bwrap: '---' rules on SYSTEM_RO_BIND_PATHS (/etc /usr /bin /lib /sbin /opt) now emit
  --tmpfs in restrictive mode — previously the deny branch was gated to permissive mode
  only, leaving syscalls inside the sandbox able to read /etc/passwd etc. despite policy
- seatbelt: bracket globs [abc] now detected as wildcards (/[*?[]/ and strip regex updated);
  previously emitted as SBPL literals matching only a file literally named '[abc]'
- access-policy-file: mergeAccessPolicy fast-path (!base) returns shallow copy instead of
  reference — autoExpandBareDir was mutating the cached agents['*'].policy in-place,
  corrupting all subsequent resolveAccessPolicyForAgent calls in the same process
- access-policy: sha256 comparison normalizes to lowercase (.toLowerCase()) — validation
  regex accepts uppercase (/i) but crypto.digest always returns lowercase, causing uppercase
  sha256 in config to silently deny exec at runtime with no useful error
- Tests added for all four findings
2026-03-14 16:19:51 -07:00
subrih 65946937a0 fix: validation completeness and consumer invariant consistency across all enforcement layers
- permAllowsWrite (bwrap), permToOps/deniedOps (seatbelt): guard all positional perm accesses with VALID_PERM_RE
- catchAllPerm/tmpPerm (seatbelt): validate rawPerm before positional access; fail closed to '---'
- hasScriptOverride (exec-runtime): check entry shape (non-null object, not array) before setting bypass flag
- scripts["policy"] merged into overrideRules in applyScriptPolicyOverride (was silently dropped)
- mergeAccessPolicy: reject non-object script entries before propagating
- validateAccessPolicyFileStructure: recurse into per-script entries to catch removed deny/default fields
- validateAccessPolicyConfig: reject non-object entries, validate sha256 format, emit mid-path wildcard
  diagnostics for scripts["policy"] AND per-script policy blocks (previously only config.policy)
- env-prefix regex: handle escaped quotes in double-quoted values ((?:[^"\\]|\\.)*)
- _resetBwrapAvailableCacheForTest: export added for test isolation
- Tests added for all of the above
2026-03-14 16:19:51 -07:00
subrih c92c9c2181 refactor(access-policy): rename rules→policy, agents['*'] as universal base, docs rewrite 2026-03-14 16:19:51 -07:00
subrih 77beb444bc fix(access-policy): mid-path wildcard OS enforcement, structural validation, doc cleanup 2026-03-14 16:19:51 -07:00
subrih cd2d9c3b8d refactor(access-policy): drop deny[] and default — rules only, --- implies deny 2026-03-14 16:19:51 -07:00
subrih 4f4d1af887 fix(access-policy): resolve symlink keys in scripts lookup, document /bin/sh and network* intent 2026-03-14 16:19:51 -07:00
subrih 4c0ffe0884 fix(access-policy): bwrap file-path tmpfs guard, seatbelt /tmp exec bit, mtime cache 2026-03-14 16:19:51 -07:00
subrih db6ddaf0b3 fix(access-policy): bwrap tmpfs file guard, DENY_ALL freeze, access read-only check, seatbelt ? wildcard strip 2026-03-14 16:19:50 -07:00
subrih a5e8054a01 fix(access-policy): read TOCTOU, sandbox skips hash check, seatbelt profile file cleanup 2026-03-14 16:19:50 -07:00
subrih e63aa29e1c fix(access-policy): env look-through, PATH= partial-match, bwrap -w-, seatbelt mid-path wildcards, O_EXCL profile files 2026-03-14 16:19:50 -07:00
subrih 18a8707a2f fix: env option stripping, PATH resolution for bare names, exec tool-layer policy check 2026-03-14 16:19:50 -07:00
subrih d4d15435f8 fix: seatbelt race, env quoted argv0 look-through, TSDoc default perm 2026-03-14 16:19:50 -07:00
subrih 003cf88d71 feat(access-policy): filesystem RWX enforcement via access-policy.json 2026-03-14 16:19:50 -07:00