oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1# Task 1 report: read-only probes and static reads (slice F)
2
3Status: DONE_WITH_CONCERNS. No code, no commits, nothing changed on the
4Studio. Tests, mutations, copy: none (no code in this task).
5
6Machines and dates:
7- Studio outputs: `tito-studio` (hostname `Tito-Studio.localdomain`), as
8 `paulca` (uid 502), over `ssh -o BatchMode=yes`, 2026-11-28 17:55Z to
9 18:09Z.
10- CLI reads: docs-t1, 2026-11-28 17:57Z to 18:10Z, static reads only
11 (`rg -a`, `dd`), the binary was never executed.
12
13Verdicts: the Machines page line for Tito Studio (protocol, P1 to P7,
14tainted) was not fetched here; per the controller, that is the
15controller's job. Not recorded in this report.
16
17## R1 Studio basics (tito-studio, 2026-11-28 17:55Z)
18
19```
20sw_vers: ProductName macOS, ProductVersion 27.2, BuildVersion 26B123
21xcodebuild: Xcode 27.2, Build version 27B52
22xcode-select: /Applications/Xcode.app/Contents/Developer
23swift: swift-driver 1.168.6, Apple Swift 6.4.2 (swiftlang-6.4.2.1.9 clang-2100.4.1.1)
24 Target: arm64-apple-macosx27.2.0
25sysctl: hw.ncpu: 36, hw.memsize: 103079215104 (96 GiB),
26 machdep.cpu.brand_string: Apple M5 Ultra
27uptime: 17:55 up 19 days, 7:20, 8 users, load averages: 0.83 1.15 1.25
28simctl runtimes (identifier, version, build, available, device types):
29 com.apple.CoreSimulator.SimRuntime.iOS-27-0 27.0 24A434 true 62
30 com.apple.CoreSimulator.SimRuntime.iOS-27-2-iPhone19-4 27.2 24B91016s true 1
31 com.apple.CoreSimulator.SimRuntime.iOS-27-2 27.2 24B8117 true 63
32```
33
34Note: the BuildVersion `26B123` is what `sw_vers` printed; recorded as is.
35There are three runtimes, not two: a device-specific `iOS-27-2-iPhone19-4`
36runtime (one device type) sits beside the general 27.2 one. Task code
37that picks "the newest iPhone simulator" should not assume one runtime
38per version.
39
40## R2 Homes, ACLs, the runner (tito-studio, 2026-11-28 17:55Z)
41
42`ls -led /Users/*`:
43
44```
45drwxr-x---+ 51 billhorsman staff 1632 28 Nov 17:35 /Users/billhorsman
46 0: user:paulequipo deny list,search,readattr,readextattr,readsecurity
47 1: group:everyone deny delete
48drwxr-x---+ 16 ci staff 512 11 Nov 17:48 /Users/ci
49 0: user:paulequipo deny list,search,readattr,readextattr,readsecurity
50 1: group:everyone deny delete
51drwxr-x---+ 37 drbparsons staff 1184 28 Nov 17:54 /Users/drbparsons
52 0: user:paulequipo deny list,search,readattr,readextattr,readsecurity
53 1: group:everyone deny delete
54drwxr-x---+ 28 murraysum staff 896 6 Oct 13:27 /Users/murraysum
55 0: user:paulequipo deny list,search,readattr,readextattr,readsecurity
56 1: group:everyone deny delete
57drwxr-x---+ 45 paulca staff 1440 28 Nov 15:05 /Users/paulca
58 0: user:paulequipo deny list,search,readattr,readextattr,readsecurity
59 1: group:everyone deny delete
60drwxr-x---+ 19 paulequipo staff 608 28 Nov 15:22 /Users/paulequipo
61 0: group:everyone deny delete
62drwxrwxrwt 8 root wheel 256 9 Nov 10:37 /Users/Shared
63drwxr-x---+ 41 vicky staff 1312 28 Nov 17:29 /Users/vicky
64 0: user:paulequipo deny list,search,readattr,readextattr,readsecurity
65 1: group:everyone deny delete
66```
67
68This differs from what the brief recorded earlier ("no ACL"). Every other
69home now carries an ACL that denies `paulequipo` list and search. So the
70runner user cannot enter other people's homes, whatever their modes.
71`paulequipo`'s own home has no such entry: it is `drwxr-x---` group
72`staff`, and every human user is in `staff`. So any staff user can list
73and traverse `/Users/paulequipo`. What they can read inside depends on
74the modes of its contents, which I did not read.
75
76`id paulequipo`:
77```
78uid=506(paulequipo) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),
79204(_developer),702(...sharepoint.group.2),703,705,704,100(_lpoperator),707,701,706
80```
81`dscl`: NFSHomeDirectory /Users/paulequipo, PrimaryGroupID 20, UniqueID
82506, UserShell /bin/zsh. `paulequipo` is not in `admin` (paulca is).
83
84`ps -axo user,pid,etime,command | grep equipo-runner`:
85```
86paulequipo 32952 02:33:28 /Users/paulequipo/.local/lib/equipo-runner/equipo-runner run --env-file /Users/paulequipo/.config/equipo-runner/runner.env
87```
88One runner, up 2 h 33 min at 17:55Z.
89
90## R3 Nested Seatbelt on macOS 27.2 (tito-studio, 2026-11-28 17:55Z to 17:56Z)
91
92| Outer profile | Inner profile | Result |
93|---|---|---|
94| none | `(allow default)` | rc 0 |
95| `(allow default)` | `(allow default)` | rc 0 |
96| `(allow default)` | `(deny default)(allow process-exec)(allow file-read*)` | rc 71, `sandbox-exec: sandbox_apply: Operation not permitted` |
97| `(deny default)(allow process-exec)(allow process-fork)(allow file-read*)` | `(allow default)` | rc 71, same message |
98| `(allow default)` | `(allow default)(deny file-read* (literal "/private/etc/hosts"))` | rc 71, same message |
99| `(allow default)(deny file-read* (literal "/private/etc/hosts"))` | `(allow default)` | rc 71 |
100| none (control) | `(allow default)(deny file-read* (literal "/private/etc/hosts"))`, `cat /etc/hosts` | rc 1, `cat: /etc/hosts: Operation not permitted` (single profile works) |
101| `(allow default)` | `(deny default)` + exec, fork, read, sysctl-read, mach-lookup | rc 71, same message |
102
103Verdict: macOS 27.2 does not let a real profile be applied inside
104another. The only nesting that "works" is two bare `(allow default)`
105profiles; as soon as either side restricts anything, the inner
106`sandbox_apply` fails with EPERM. Background only: the design does not
107nest. It does mean anything a sandboxed command starts that itself calls
108`sandbox-exec` (a nested `claude`, `srt`, a tool that sandboxes itself)
109fails rather than running weaker.
110
111## R4 What `process-info*` governs on 27.2 (tito-studio, 2026-11-28 17:56Z to 18:08Z)
112
113Method: a scratch dir from `mktemp -d` under paulca's `$TMPDIR`
114(`/var/folders/3s/.../T/r4probe.*`), removed in the same command. A
115small C reader (built with `clang` in the scratch dir) calls
116`sysctl({CTL_KERN, KERN_PROCARGS2, pid})`, `proc_pidinfo(PROC_PIDTBSDINFO)`
117and `proc_pidpath`. Targets are processes I started with
118`R4_MARKER=r4probe` in their environment: `/bin/sleep`, a non-platform
119sleeper compiled in the scratch dir, `/bin/bash -c`, `/bin/zsh -c`, and
120Xcode's `git hash-object --stdin`.
121
122Plain shell (no sandbox), same uid:
123
124| Target | `ps -E` shows env | `KERN_PROCARGS2` env |
125|---|---|---|
126| own process (the reader, self) | n/a | yes (1372 bytes, marker seen) |
127| `/bin/sleep` (platform binary) | no | no (34 bytes: argv only) |
128| `/bin/bash -c` (platform) | no | (not run; `ps -E` uses procargs2) |
129| `/bin/zsh -c` (platform) | no | (as above) |
130| scratch-built sleeper (ad hoc signed) | yes | yes (1356 bytes, marker seen) |
131| Xcode `git` (Apple signed, not platform) | yes | (as above) |
132| own login shell `$$` | marker absent, as expected: exported after the shell started |
133
134`codesign -dv`: `/bin/bash`, `/bin/zsh`, `/bin/sleep`,
135`/usr/bin/sandbox-exec`, `/usr/bin/env` all show `Platform identifier=27`;
136Xcode's `git` and `xcodebuild` show `flags=0x2000(library-validation)` and
137no platform identifier.
138
139So on 27.2 the kernel hides the environment of **platform binaries**
140from other processes, even of the same user, and shows it for every
141other same-user process.
142
143Inside `sandbox-exec -p '(version 1)(deny default)(allow process-exec)(allow file-read*)'`:
144- the reader still read the full environment of the same-user
145 non-platform sleeper through `KERN_PROCARGS2` (marker seen), and
146 `proc_pidinfo` and `proc_pidpath` still succeeded for both targets;
147- `kern.argmax` (plain `sysctl-read`) failed with EPERM, so the deny
148 default was in force;
149- adding `(allow sysctl-read)`, `(allow process-info*)`, or
150 `(allow process-info* (target same-sandbox))` changed nothing;
151- `/bin/ps` could not be started at all under any profile, including
152 `(allow default)`: `sandbox-exec: execvp() of '/bin/ps' failed:
153 Operation not permitted`. `/bin/ps` is setuid root
154 (`-rwsr-xr-x root wheel`), and a sandboxed process may not exec a
155 setuid binary.
156
157What this shows for 27.2: in these tests, `process-info*` does not stop
158`KERN_PROCARGS2`, `proc_pidinfo(TBSDINFO)` or `proc_pidpath` against
159same-user processes. A sandboxed command can read the initial
160environment of any same-user non-platform process, which includes the
161`claude` binary itself. F3 is the proof under the real generated
162profile; this is the hand-written-profile preview.
163
164Two consequences, for task 9 and task 10:
165- The §5 marker sweep (`ps -E` for `EQUIPO_ATTEMPT`) cannot see the
166 marker on `/bin/bash`, `/bin/zsh`, `/bin/sleep`, `/usr/bin/env` or
167 `/usr/bin/sandbox-exec`. Those are exactly the processes Claude's
168 Bash tool starts (see S5). The sweep sees the marker only on
169 non-platform children (Xcode tools, built test binaries, Homebrew
170 tools).
171- A token in `claude`'s environment at exec is readable by its own
172 sandboxed Bash commands through `KERN_PROCARGS2`. Use the file
173 descriptor path (S4) so the token is never in `claude`'s environ.
174
175## S1 Pinned CLI digest (docs-t1, 2026-11-28 17:58Z)
176
177The official installer `https://claude.ai/install.sh` (fetched 17:57Z)
178sets `DOWNLOAD_BASE_URL="https://downloads.claude.ai/claude-code-releases"`.
179It fetches `$DOWNLOAD_BASE_URL/$version/manifest.json`, reads
180`.platforms["darwin-arm64"].checksum`, downloads
181`$DOWNLOAD_BASE_URL/$version/$platform/claude` and checks its SHA-256. It
182no longer names a `storage.googleapis.com` bucket; `downloads.claude.ai`
183is the one host it uses. (`$DOWNLOAD_BASE_URL/latest` answered `2.1.332`
184at 17:57Z.)
185
186- Manifest URL: `https://downloads.claude.ai/claude-code-releases/2.1.312/manifest.json`
187 (file sha256 `f9bc2d099665e498cbc4123f81f2220852c3a75ee118c0081ef83f42f165aec9`).
188 Contents: `"version": "2.1.312"`, `"commit":
189 "f375cd85d4f70920de17ce3a4ad646e18834e833"`, `"buildDate":
190 "2026-10-27T17:16:03Z"`, `"manifestSignatureEnforcement": "flag"`.
191- Binary URL: `https://downloads.claude.ai/claude-code-releases/2.1.312/darwin-arm64/claude`
192- Manifest `darwin-arm64`: `checksum
193 6b5ec691195e551b02c41df9f7d723f4ea61eaa03c2df90acefe3736f1aeb620`,
194 `size 275988512`.
195- Downloaded: 275988512 bytes, `sha256sum`
196 `6b5ec691195e551b02c41df9f7d723f4ea61eaa03c2df90acefe3736f1aeb620`.
197 It matches. `file`: `Mach-O 64-bit arm64 executable`.
198
199**`claude.ExecutableSHA256DarwinArm64 = "6b5ec691195e551b02c41df9f7d723f4ea61eaa03c2df90acefe3736f1aeb620"`**
200
201Kept for task 5: `/home/paulca/.cache/mac-slice-f-build/claude-2.1.312-darwin-arm64`,
202mode `-rw-rw-r--` (no exec bit; it was never run), sha256 as above.
203
204## S2 Sandbox settings keys (docs-t1, static)
205
206The settings schema (zod, `nur=f(()=>u({enabled:...`) and its network
207(`Rf`) and filesystem (`Tf`) parts list every key the design names:
208
209| Key | Present | Matched text (short) |
210|---|---|---|
211| `sandbox.enabled` | yes | `enabled:M().optional().describe("Run Bash commands inside the sandbox. Default: false.` |
212| `sandbox.failIfUnavailable` | yes | `failIfUnavailable:M().optional().describe("Exit with an error at startup if sandbox.enabled is true but the sandbox cannot start` |
213| `sandbox.allowUnsandboxedCommands` | yes | `When false, the dangerouslyDisableSandbox parameter is completely ignored and all commands must run sandboxed. Default: true.` |
214| `sandbox.excludedCommands` | yes | `excludedCommands:C(o()).optional().describe("Command patterns (Bash permission-rule syntax) that always run outside the sandbox.` |
215| `sandbox.enableWeakerNestedSandbox` | yes, **Linux only** | `enableWeakerNestedSandbox:M().optional().describe("Linux only: Run without the fresh /proc mount` |
216| `sandbox.filesystem.allowWrite` | yes | `allowWrite:C(o()).optional().describe("Additional paths to allow writing within the sandbox.` |
217| `sandbox.filesystem.denyWrite` | yes | `denyWrite:C(o()).optional().describe("Additional paths to deny writing within the sandbox.` |
218| `sandbox.filesystem.denyRead` | yes | `denyRead:C(o()).optional().describe("Additional paths to deny reading within the sandbox.` |
219| `sandbox.filesystem.allowRead` | yes | `allowRead:C(o()).optional().describe("Paths to re-allow reading within denyRead regions.` |
220| `sandbox.network.allowedDomains` | yes | `allowedDomains:C(o()).optional().describe("Domains sandboxed commands may reach without a prompt` |
221| `sandbox.network.allowUnixSockets` | yes | `allowUnixSockets:C(o()).optional().describe("macOS only: Unix socket paths to allow.` |
222| `sandbox.network.allowLocalBinding` | yes | `allowLocalBinding:M().optional().describe("macOS only: If true, sandboxed commands can bind to localhost ports.` |
223| `sandbox.network.allowMachLookup` | yes | `allowMachLookup:...describe('macOS only: Additional XPC/Mach service names to allow looking up. Supports trailing-wildcard prefix matching (e.g., "com.apple.CoreSimulator.*")` |
224
225Also present and relevant: `network.strictAllowlist`, `network.deniedDomains`,
226`network.allowAllUnixSockets`, `autoAllowBashIfSandboxed`,
227`enableWeakerNetworkIsolation` (macOS: opens `com.apple.trustd.agent`),
228`allowAppleEvents`, `credentials.{files, envVars}`, `filesystem.disabled`.
229`allowMachLookup` wildcards: only one trailing `*`.
230
231Settings-source rule: the CLI refuses repo settings that negate operator
232posture: `["sandbox.enabled",...,!1],["disableAllHooks",...],["sandbox.allowUnsandboxedCommands",...,!0],["sandbox.failIfUnavailable",...,!1]`
233throws `negates the operator's ${de} posture (projectSettings overrides userSettings ...)`.
234And `if(s.enabled===!0&&m.failIfUnavailable===void 0)m.failIfUnavailable=!0`
235in the `--settings` merge: `sandbox.enabled: true` in a `--settings`
236file implies `failIfUnavailable: true` unless set.
237
238**What an empty `allowedDomains` means: ask, not "no network".** This
239contradicts spec §4.1 line 393 ("empty means no network").
240- macOS wrap: `ge=h?.network?.allowedDomains!==void 0||Pe?.network?.allowedDomains!==void 0,ue=b?.denyAllNetwork===!0,Ce=ge||ue` and the
241 profile gets `needsNetworkRestriction:Ce`. Any defined list, even
242 `[]`, puts network behind the local proxy. If neither is set the
243 profile says `(allow network*)`. Claude Code itself always passes a
244 defined array (`allowedDomains:z`, built from settings and
245 `WebFetch(domain:...)` rules) unless the env-scrub subprocess sandbox
246 is in use.
247- The proxy's per-request filter, in order:
248 `Denied by config rule` (deniedDomains) then `Allowed by config rule`
249 (allowedDomains) then
250 `if(Pe.network.strictAllowlist)return Et("No matching config rule, denying: ...")`,
251 then per-command lists, then `if(!r)return Et("No matching rule, denying: ...")`,
252 else `Et("No matching rule, asking user: ...")` and `await r({host,port})`.
253- In headless `--print` / stream-json, the ask callback is either
254 `createSandboxAskCallback(...)`, which sends the SDK host
255 `{subtype:"can_use_tool",tool_name:"SandboxNetworkAccess",input:{host},description:"Allow network connection to ${m}?"}`
256 and allows on `behavior:"allow"`, or `LE(e)`, which emits a
257 permission denial (`emitPermissionDenied(aQ,...)`, `aQ="SandboxNetworkAccess"`)
258 and returns false. In auto mode a classifier decides
259 (`Auto mode classifier blocked sandbox network access to ${e}`).
260- So with `allowedDomains: []` alone, every host becomes a
261 `SandboxNetworkAccess` permission request to Equipo's canUseTool
262 answerer. Equipo's "nobody to ask" default probably denies it, but
263 that denial comes from Equipo's answer, not from the sandbox.
264 `network.strictAllowlist: true` gives a deterministic deny:
265 `"If true, hosts not in allowedDomains are denied without consulting the ask callback"`.
266 It is honoured only from user, managed/policy or `--settings`
267 (`Only honored from user, managed/policy, or CLI (--settings) settings`).
268 `--settings` is how Equipo passes it, so it applies.
269
270Recommendation for task 8 (not a stop: every needed key exists): set
271`network.strictAllowlist: true` next to `allowedDomains: []`, and make
272the answerer deny `SandboxNetworkAccess` as a second layer.
273`enableWeakerNestedSandbox` does nothing on macOS (Linux only); do not
274rely on it.
275
276## S3 Embedded sandbox-runtime and its macOS profile (docs-t1, static)
277
278**Version.** The binary embeds no `@anthropic-ai/sandbox-runtime`
279version string. (I looked for `sandbox-runtime` with a version, `srtVersion`,
280`SANDBOX_RUNTIME_VERSION`, and `package.json` fragments.) I fetched the
281npm tarballs 0.0.79, 0.0.80, 0.0.81, 0.0.82 and 0.0.83 (sha512 integrity
282checked against the registry; `latest` is 0.0.83, published 2026-11-13).
283The embedded code matches none of them exactly:
284
285| Fingerprint string | binary | 0.0.79 | 0.0.80 | 0.0.81 | 0.0.82 | 0.0.83 |
286|---|---|---|---|---|---|---|
287| `askCallbackDenyReason` | yes | no | yes | yes | yes | yes |
288| `denyAllNetwork` | yes | no | no | no | no | no |
289| `file mask degrades to deny on macOS until the interposer lands` | yes | no | no | no | no | no |
290| `getProfileReadSecurityWarnings` | yes | no | no | no | no | no |
291| `network-bind (local ip "localhost:` (proxy port bind) | no | yes | yes | yes | yes | yes |
292
293So 2.1.312 (built 2026-10-27) vendors an unreleased sandbox-runtime
294that is newer than 0.0.80 and differs from every public release up to
2950.0.83. The source of truth for its profile is the generator inside the
296binary, which I read directly (function `z9`, beginning
297`"(version 1)",\`(deny default (with message "${q}"))\``). The spec's
298"0.0.81 on main today" (§4.1) is not the embedded code.
299
300**Generated profile defaults (from the binary):**
301- `(deny default (with message "<logTag>"))`.
302- Process: `(allow process-exec)`, `(allow process-fork)`,
303 `(allow process-info* (target same-sandbox))`,
304 `(allow signal (target same-sandbox))`,
305 `(allow mach-priv-task-port (target same-sandbox))`. Note R4: on 27.2
306 `process-info*` did not stop `KERN_PROCARGS2` for same-user processes.
307- `mach-lookup` (fixed list): `com.apple.audio.systemsoundserver`,
308 `com.apple.distributed_notifications@Uv3`, `com.apple.FontObjectsServer`,
309 `com.apple.fonts`, `com.apple.logd`, `com.apple.lsd.mapdb`,
310 `com.apple.PowerManagement.control`, `com.apple.system.logger`,
311 `com.apple.system.notification_center`,
312 `com.apple.system.opendirectoryd.libinfo`,
313 `com.apple.system.opendirectoryd.membership`, `com.apple.bsd.dirhelper`,
314 **`com.apple.securityd.xpc`**, `com.apple.coreservices.launchservicesd`;
315 and separately, under `; Specific mach-lookup permissions for security operations`,
316 **`(allow mach-lookup (global-name "com.apple.SecurityServer"))`**. So
317 the Keychain API is reachable from every sandboxed command, as §4.5
318 says. Opt-ins add `com.apple.trustd.agent` (enableWeakerNetworkIsolation),
319 appleevents plus `lsopen` (allowAppleEvents), and the user's
320 `allowMachLookup` entries (`global-name` or `global-name-prefix`).
321- `file-read*`: `q9` starts with `"(allow file-read*)"`, which allows
322 everything. Then it adds denyRead regions as
323 `(deny file-read* ...)`, re-allows allowRead inside them, and adds
324 `(allow file-read-metadata (vnode-type DIRECTORY))` when any deny
325 exists. With no read config the whole read section is just
326 `(allow file-read*)`. Reads are deny-list, never allow-list.
327- `sysctl-read`: a fixed list (hw.*, `kern.argmax`, `kern.hostname`,
328 `kern.osproductversion`, `kern.osversion`, `vm.loadavg`, and so on)
329 plus prefixes `hw.optional.arm`, `hw.perflevel`, `kern.proc.all`,
330 `kern.proc.pgrp.`, `kern.proc.pid.`, `machdep.cpu.`, `net.routetable.`.
331 It also has `(allow sysctl-write (sysctl-name "kern.tcsm_enable"))`.
332 `kern.proc.all` and `kern.proc.pid.` mean sandboxed commands can list
333 every process.
334- Also: `user-preference-read`, `ipc-posix-shm`, `ipc-posix-sem`,
335 a few IOKit classes, `iokit-get-properties`, `AF_SYSTEM` sockets,
336 `distributed-notification-post`, `file-ioctl` on /dev/null, zero,
337 random, urandom, dtracehelper, tty.
338- Network: `(allow network*)` only when no restriction is needed;
339 otherwise, with `allowLocalBinding`,
340 `(allow network-bind (local ip "*:*"))`, `(allow network-inbound (local ip "*:*"))`,
341 `(allow network-outbound (remote ip "localhost:*"))`. Unix sockets
342 are per path, or all of them. For the proxy ports it emits
343 `(deny network-bind network-inbound (local ip "*:<port>"))` and
344 `(allow network-outbound (remote ip "localhost:<port>"))`. (0.0.81
345 instead *allows* bind and inbound on `localhost:<port>`.)
346- Writes: `allowOnly` roots, then denies for `denyWithinAllow` plus a
347 fixed list per cwd: shell rc and dangerous files (`EQn`, `vQn`),
348 `.git/hooks` and `**/.git/hooks/**`, and `.git/config` unless
349 `allowGitConfig`.
350- The wrapper (`PGr`) runs
351 `env -u <unset vars> <set vars> <proxy env> /usr/bin/sandbox-exec -p <profile> <shell> -c <command>`,
352 with shell `binShell || "bash"` found on PATH. Violations are read from
353 `log stream --predicate (eventMessage ENDSWITH "<random>_SBX")`, not
354 `process == "sandbox-exec"` as §4.5 has it.
355
356## S4 OAuth token by file descriptor, and the Keychain (docs-t1, static)
357
358**File descriptor: yes.** The build reads
359`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR` (36 occurrences):
360`Pv(){return ... $Zr({envVar:"CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR",wellKnownPath:bte,label:"OAuth token",...})}`.
361The reader parses the number, then
362`let l=\`/dev/fd/${p}\`,c=mlt(l,{maxBytes:LUe}).trim()` and logs
363`Successfully read ${o} from file descriptor ${p}`. If the env var is
364unset it falls back to the well-known file `bte=\`${y}/.oauth_token\``.
365It persists the token to disk only when `CLAUDE_CODE_REMOTE` is set
366(`async function D(...){if(!i.CLAUDE_CODE_REMOTE)return;...`). The env
367var itself (just the number) is deleted only in the socket case
368(`delete process.env[e]` after `Leo(l)`).
369
370Precedence (`function ha()`): apiKeyHelper (bare) > `ANTHROPIC_AUTH_TOKEN`
371> `if(i.CLAUDE_CODE_OAUTH_TOKEN||o0()!==null)return{source:"CLAUDE_CODE_OAUTH_TOKEN"}`
372> `if(Pv()){...return{source:"CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR"}}`
373> apiKeyHelper > profile > `claude.ai` (stored, Keychain-backed). An env
374token or an FD token is used before the Keychain-backed sign-in.
375
376Other FD variables in the build: `CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR`,
377`CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR`,
378`CLAUDE_CODE_GATEWAY_TOKEN_FILE_DESCRIPTOR`,
379`CCR_AGENT_PROXY_TOKEN_FILE_DESCRIPTOR`.
380
381Bash children never get the token in their env: `$Tn=["CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CODE_SESSIONS_OAUTH_TOKEN",...]`
382is always deleted from the child env (`M.has(o.toUpperCase())&&!L(o,d)` then `delete d[o]`).
383But R4 shows that a sandboxed child can still read `claude`'s
384**initial** environment through `KERN_PROCARGS2`. So the FD path is the
385one that keeps the token out of reach.
386
387**A set `CLAUDE_CODE_OAUTH_TOKEN` does not skip every Keychain read.**
388- Startup prefetch, called unconditionally from the main entry
389 (`process.env.NoDefaultCurrentDirectoryInExePath="1";...;rts();`):
390 `function rts(){let e=yr();if(o||e)return;...s(HW(KPe))...s(HW())...}`,
391 where `s(e)` runs
392 `execFile("security",["find-generic-password","-a",iO(),"-w","-s",e],...)`.
393 `yr` comes from the module that exports
394 `function yr(){return Ne(process.env.CLAUDE_CODE_SIMPLE)||i("--bare")}`.
395 So on every start, unless `--bare` or `CLAUDE_CODE_SIMPLE`, it reads
396 two items: `Claude Code-credentials` and the legacy `Claude Code` API
397 key item. This happens whether or not `CLAUDE_CODE_OAUTH_TOKEN` or the
398 FD variable is set.
399- Service name: `function HW(e=""){...return\`Claude Code${on().OAUTH_FILE_SUFFIX}${e}${a}\`}`,
400 where `a` is `-<first 8 hex of sha256(config dir)>` when
401 `CLAUDE_CONFIG_DIR` (or `CLAUDE_SECURESTORAGE_CONFIG_DIR`) is set, and
402 empty otherwise. `KPe="-credentials"`. The account (`iO()`) is
403 `process.env.USER` or the OS username, or `claude-code-user` if that
404 has odd characters. So a per-session `CLAUDE_CONFIG_DIR` gives a
405 per-config-dir Keychain service name.
406- Other Keychain users in the build: a device-key store, service
407 `"Claude Code-device-keys"`
408 (`add-generic-password -U -a "${n}" -s "${C}" -X "${i}"`); the
409 `/doctor` probe `"Claude Code-doctor-probe"`; and credential update
410 and delete (`add-generic-password -U`, `delete-generic-password`) on
411 the credentials item (sign-in, refresh, sign-out). From static reading
412 I did not find a write that runs only because an env or FD token is
413 in use, but I cannot prove there is none.
414- `security` is spawned by bare name, resolved through `PATH`
415 (`execFile("security",...)`, `it("security",...)`,
416 `YUe(\`security find-generic-password ...\`)` through a shell). Only
417 the confined-evaluation code names `/usr/bin/security` directly (for
418 its exclusion list). So the runner can put a refusing `security` shim
419 first on `claude`'s `PATH` to block the startup reads. That is a
420 design option for task 10, not tested.
421
422## S5 How Bash starts its shell, and the env scrub (docs-t1, static)
423
424**Spawn.** The Bash shell provider returns
425`{type:"bash",shellPath:e,detached:!0,stdin:"pipe",...}`, and the spawn
426passes `detached:Xt.detached`:
427`Wkr(ls,Es,{...,env:fLr({...}),cwd:Tn,stdio:...,detached:Xt.detached,windowsHide:!0})`.
428Bun's `detached: true` on POSIX means `setsid()`: each Bash tool command
429gets a **new session and a new process group** (pgid = its pid). It does
430not stay in the `claude` process's group. Kill paths signal the group:
431`if(I()!=="linux"&&I()!=="wsl")try{return process.kill(-p,e)}`, SIGTERM
432then SIGKILL after 5 s. On macOS the chain is `<shell> -c "env -u ...
433/usr/bin/sandbox-exec -p <profile> bash -c <cmd>"`, where the shell is
434the user's shell (`SHELL` is set to `binShell` for bash).
435
436Consequence for task 9 (not one of the two named stops, but it bites
437§5): `SIGTERM`/`SIGKILL` to the attempt's group does not reach Bash
438tool commands, because each has its own session. The §5 sweep has to
439find them by marker. Per R4, `ps -E` cannot see the marker on
440`/bin/bash`, `/bin/zsh`, `/usr/bin/env` or `/usr/bin/sandbox-exec`
441(platform binaries); it sees it only on non-platform descendants. A
442reliable sweep needs another key: a walk of the parent-pid tree from
443`claude` (`kern.proc.all`), or session ids (`ps -o sess` / `getsid`)
444of the per-command sessions recorded while `claude` runs, plus the
445marker for non-platform children.
446
447**`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`.** It turns on with `1/true/yes/on`
448(`function On(e){...n==="1"||n==="true"||n==="yes"||n==="on"}`; also on
449under `GITHUB_ACTIONS` unless explicitly `0/false/no/off`). When on:
450- Bash children additionally lose the `to` list (config-path variables
451 that point credential tools elsewhere), each also as `INPUT_<name>`:
452 `AWS_SHARED_CREDENTIALS_FILE, AWS_CONFIG_FILE, CLOUDSDK_CONFIG,
453 AZURE_CONFIG_DIR, KUBECONFIG, NETRC, PGPASSFILE, PGSERVICEFILE,
454 DOCKER_CONFIG, GH_CONFIG_DIR, GNUPGHOME, NPM_CONFIG_USERCONFIG,
455 NPM_CONFIG_GLOBALCONFIG, SSH_AUTH_SOCK, GIT_SSH_COMMAND, GIT_SSH,
456 GIT_ASKPASS, SSH_ASKPASS, SSH_AGENT_PID, TF_CLI_CONFIG_FILE, WGETRC,
457 PIP_CONFIG_FILE, UV_CONFIG_FILE, RCLONE_CONFIG, BOTO_CONFIG, BOTO_PATH,
458 S3CMD_CONFIG, SOPS_AGE_KEY_FILE, ANSIBLE_VAULT_PASSWORD_FILE,
459 ANSIBLE_VAULT_IDENTITY_LIST, ANSIBLE_CONFIG, GOAUTH, SBT_CREDENTIALS,
460 COURSIER_CREDENTIALS, CONSUL_HTTP_TOKEN_FILE, SYSTEM_WGETRC,
461 CLOUDSDK_ROOT_DIR, M2_HOME, MAVEN_HOME, LEIN_HOME, SSLKEYLOGFILE,
462 GIT_CONFIG_GLOBAL, GIT_CONFIG_SYSTEM, XDG_CONFIG_HOME, XDG_CONFIG_DIRS,
463 XDG_CACHE_HOME, XDG_DATA_HOME, XDG_STATE_HOME, XDG_RUNTIME_DIR,
464 HELM_REGISTRY_CONFIG, HELM_REPOSITORY_CONFIG, HELM_CONFIG_HOME,
465 REGISTRY_AUTH_FILE, DOCKER_CERT_PATH, SSL_CLIENT_CERT, GIT_SSL_CERT,
466 GIT_SSL_KEY, PIP_CLIENT_CERT, PGSSLKEY, VAULT_CLIENT_KEY,
467 VAULT_CLIENT_CERT, CONSUL_CLIENT_KEY, CONSUL_CLIENT_CERT,
468 NOMAD_CLIENT_KEY, NOMAD_CLIENT_CERT, PGSSLCERT, PGSYSCONFDIR, CURL_HOME,
469 CARGO_HOME, COMPOSER_HOME, GRADLE_USER_HOME, BUNDLE_CONFIG,
470 BUNDLE_USER_CONFIG, BUNDLE_USER_HOME, BUNDLE_APP_CONFIG,
471 POETRY_CONFIG_DIR, COURSIER_CONFIG_DIR, HEX_HOME, HF_HOME, HF_TOKEN_PATH,
472 HF_STORED_TOKENS_PATH, CONDARC, BUN_CONFIG_FILE, GOENV, NPM_CONFIG_PREFIX,
473 CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE, CLAUDE_CONFIG_DIR,
474 ANTHROPIC_CONFIG_DIR, ANTHROPIC_PROFILE, CLAUDE_CODE_FEDERATION_CACHE_DIR,
475 CLAUDE_SECURESTORAGE_CONFIG_DIR`.
476- They also lose any variable whose **name** looks like a secret
477 (`m7r` then `fwe`), using the regex built from
478 `Un=["TOKEN","SECRET","PASSWORD","PASSWD","PASSPHRASE","KEY","AUTH","COOKIE","PAT","DSN","WEBHOOK","CREDENTIAL","CREDENTIALS","CREDS","APIKEY",...]`,
479 `$n=["PWD","PASS","JWT"]`, `Gn=[...]`, `Wn=[...]`:
480 `((^|_)(Un...|(Wn...)S)|_($n...)|(Gn...))(?=$|[_0-9])`, case
481 insensitive. Also `CONN_STR`-style names, `BUNDLE_*__` credentials,
482 and `INPUT_`/Poetry/Conan prefixed user and password names.
483- Values that look like URLs with embedded credentials are dropped or
484 rewritten (`lO`, `XCn`).
485- Always, scrub or not, Bash children lose `$Tn` (the CLI's own tokens,
486 above), the large `eo` list of well-known secret names (GITHUB_TOKEN,
487 VAULT_TOKEN and so on), `OTEL_*`, and some CLAUDE_* internals.
488- Side effects of scrub mode: permission mode is forced to `default`
489 (`"Permission mode forced to default — CLAUDE_CODE_SUBPROCESS_ENV_SCRUB is set (allowed_non_write_users hardening). Declare allowedTools explicitly"`);
490 `autoAllowBashIfSandboxed` is off (`function zV(){return!hp()&&I()!=="windows"}`,
491 `zde(){if(!zV())return!1;...}`), so sandboxed Bash goes through the
492 permission answerer, not auto-allow; `--await-claim` is refused. If
493 `sandbox.enabled` is not true it builds its own subprocess sandbox
494 (`oSe(){return hp()&&Pie()&&!Wc()}`); with `sandbox.enabled true`
495 (Equipo's Engineering profile) the normal sandbox applies.
496
497**`EQUIPO_ATTEMPT` survives the scrub.** It is in no list (`rg -a -c EQUIPO`
498finds no matches), and it does not match the name regex. Checked by
499rebuilding the regex in Python from the arrays above:
500`EQUIPO_ATTEMPT -`, `EQUIPO_ATTEMPT_ID -`, `EQUIPO_RUN_ATTEMPT -`, and
501the controls `EQUIPO_ATTEMPT_TOKEN In`, `EQUIPO_KEY In` (scrubbed). Keep
502the value plain (no `scheme://user:pass@`), keep the name free of the
503listed words, and never suffix it `_KEY`, `_TOKEN`, `_AUTH`, `_PAT`
504and so on. The S5 stop does not apply.
505
506## S6 Transcript directory from cwd (docs-t1, static)
507
508- Projects root: `function hm(){return S(Le(),"projects")}`, with
509 `Le=f(()=>(B8t()??u(D(),".claude")).normalize("NFC"),B8t)` and
510 `B8t(){return process.env.CLAUDE_CONFIG_DIR}`. So it is
511 `$CLAUDE_CONFIG_DIR/projects`, else `~/.claude/projects`.
512- Directory: `function yw(e,n=hm()){return S(n,HC(e))}`,
513 `function HC(e){return KPn()??CD(e)}`.
514- Override: `KPn=f(()=>B8t()||fne()?jfs(l()):void 0,S)`, where
515 `l(){return process.env.CLAUDE_CODE_PROJECT_DIR_NAME}` and
516 `jfs` accepts only `/^[A-Za-z0-9_-]{1,64}$/` and rejects
517 `con|prn|aux|nul|com[0-9]|lpt[0-9]`. `CLAUDE_CODE_PROJECT_DIR_NAME` is
518 honoured only when `CLAUDE_CONFIG_DIR` is set (or diskless).
519- Default rule:
520 `function k(e){return e.replace(/[^a-zA-Z0-9]/g,"-")}`,
521 `function CD(e){let n=k(e);if(n.length<=lEe)return n;return\`${n.slice(0,lEe)}-${Pe(e)}\`}`,
522 `lEe=200`, `function Pe(e){return Math.abs(Vme(e)).toString(36)}`,
523 `function Vme(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return e}`
524 (a Java-style 32-bit string hash over UTF-16 code units).
525- Input path: the cwd after `realpath` and `normalize("NFC")`
526 (`XS(e,n){...return Hn(await J(e))}`, `Hn(t){return t.normalize("NFC")}`;
527 the SDK helper does the same: `Xt(e){let s=fr(e??"."),r;try{r=cr(s)}catch{r=s}return Hn(r)}`).
528
529So for task 7: name = `realpath(cwd)` NFC-normalised, every UTF-16 code
530unit outside `[A-Za-z0-9]` replaced by `-` (an astral character becomes
531`--`). If the result is longer than 200, keep its first 200 characters
532and append `-` and `base36(|javaHash(realpath)|)`, where the hash is
533computed on the unreplaced path. `/workspace` gives `-workspace`. On the
534Mac the realpath matters: `/var/...` becomes `/private/var/...` and
535`/tmp/...` becomes `/private/tmp/...`. Example:
536`/Users/paulequipo/x/wt` gives `-Users-paulequipo-x-wt`. Setting both
537`CLAUDE_CONFIG_DIR` and `CLAUDE_CODE_PROJECT_DIR_NAME=<attempt-safe name>`
538pins the directory name outright, which is simpler than computing it.
539
540## Stops
541
542- S2 stop: **does not apply.** Every key the design needs is present.
543 But "empty `allowedDomains` = no network" is wrong for this build.
544 Empty means each host becomes a `SandboxNetworkAccess` ask to the SDK
545 host. Use `network.strictAllowlist: true` for a deterministic deny.
546 `enableWeakerNestedSandbox` is Linux only.
547- S5 stop: **does not apply.** `EQUIPO_ATTEMPT` survives
548 `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`. But Bash tool commands run in
549 their own session and process group (`detached: true`), and `ps -E`
550 cannot show the marker on the platform binaries that make up that
551 chain on 27.2 (R4). The §5 group-plus-marker sweep misses them as
552 written.
553
554## Only the Mac can show
555
556- Whether `KERN_PROCARGS2` shows `claude`'s own initial environment to
557 a command under the real generated profile (F3). The R4 preview says
558 yes for any same-user non-platform process. `claude` is
559 Anthropic-signed, not a platform binary.
560- Whether the `CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR` descriptor stays
561 open in Bash tool children (`ls /dev/fd` inside a sandboxed command).
562 That depends on Bun's spawn closing inherited descriptors on darwin.
563- Whether the startup `security find-generic-password` reads (S4) raise
564 a Keychain prompt or fail quietly for `paulequipo` in a non-GUI
565 session, and whether a `security` shim on PATH blocks them all.
566- The actual Bash shell on the runner (`SHELL` for `paulequipo` is
567 `/bin/zsh`), and the session and pgid layout of a live Bash command
568 (`ps -o pid,pgid,sess,ppid`).
569- Exact `realpath` of the runner's worktree root, for S6.
570- Whether `xcodebuild`, `swift build` and the simulator services
571 (`com.apple.CoreSimulator.*`) need more than the fixed mach-lookup
572 list (P2).
573
574## Open issues
575
5761. Spec §4.1 says "0.0.81 on main today" and "empty means no network".
577 Both differ from 2.1.312: the embedded sandbox-runtime is unreleased
578 and newer, and empty `allowedDomains` asks. Task 8 should add
579 `network.strictAllowlist: true` and have the answerer deny
580 `SandboxNetworkAccess`.
5812. Spec §5 termination: Bash commands are `setsid` children. Task 9
582 needs a sweep key besides the attempt pgid and the `ps -E` marker
583 (a ppid-tree walk from `claude`, or recorded session ids). Otherwise
584 a sandboxed `sleep 1000 &` outlives cancel unseen.
5853. Spec §4.5 names `log stream --predicate 'process == "sandbox-exec"'`.
586 The build tails `eventMessage ENDSWITH "<random>_SBX"` with a
587 per-session random tag. If the runner tails violations itself, match
588 on `Sandbox:` and `deny` lines, not on the process name.
5894. If task 9 or 10 sets `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1` (§7 line
590 707), sandboxed Bash loses auto-allow and permission mode is forced
591 to `default`. The answerer must allow Bash explicitly. The scrub
592 also removes `CLAUDE_CONFIG_DIR`, `XDG_*`, `CARGO_HOME`,
593 `GRADLE_USER_HOME`, `GIT_CONFIG_GLOBAL` and others from Bash
594 commands, so builds cannot use them.
5955. Keychain: a set token does not stop the two startup Keychain reads
596 (S4). If D1 requires no Keychain touch at all, the options are
597 `--bare`, which changes a lot, or a `security` shim on PATH. Task 10
598 should decide.
5996. R2: other users can list `paulequipo`'s home (group `staff`, no ACL).
600 Anything secret inside it is protected only by its own file modes.
6017. The Machines page line (protocol, P1 to P7, tainted) is still owed
602 by the controller.
603
604## Cleanup done
605
606- Studio: every probe ran in a `mktemp -d` under paulca's `$TMPDIR`,
607 removed in the same command (`scratch removed` printed). Probe
608 processes (`sleep`, the C sleeper, `bash -c`, `zsh -c`,
609 `git hash-object`) were killed. At 18:09Z:
610 `no leftover probe processes`, `no r4probe scratch dirs`. Nothing of
611 `paulequipo`'s was read; no settings, users, ACLs, installs, launch
612 agents or the runner were touched; no sudo.
613- docs-t1: the scratch dir
614 `/home/paulca/.cache/tmp/claude-1001/slicef-t1.lA55Mp` (install.sh,
615 manifest, npm metadata and tarballs 0.0.79 to 0.0.83, a literal
616 extractor script; 76 MB) was deleted by exact name, and its absence
617 confirmed.
618- Kept on purpose: `/home/paulca/.cache/mac-slice-f-build/claude-2.1.312-darwin-arm64`
619 (sha256 `6b5ec691195e551b02c41df9f7d723f4ea61eaa03c2df90acefe3736f1aeb620`)
620 for task 5.
621