Commit 740a42a
fix(docker): mount CLI state directories in chroot mode for Copilot and Claude (#702)
* Initial plan
* fix(docker): mount ~/.copilot in chroot mode for copilot cli
GitHub Copilot CLI needs to extract bundled packages to ~/.copilot/pkg
directory. In chroot mode, this directory was not accessible, causing
"EACCES: permission denied" errors when trying to create directories.
The fix mounts ~/.copilot at /host~/.copilot in chroot mode, allowing
the CLI to create necessary directories while maintaining security
(no full HOME mount).
Added tests to verify ~/.copilot is writable in chroot mode.
Fixes: https://github.com/github/gh-aw-firewall/actions/runs/21912194865/job/63270212999
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
* feat(one-shot-token): add logging for cached token accesses
Add print statements whenever getenv() or secure_getenv() are called
for sensitive tokens, even when returning cached values. Previously,
only the first access was logged. Now subsequent accesses also log
"accessed (cached value)" for better debugging visibility.
This helps diagnose token access patterns and verify that the
one-shot-token library is working correctly.
Example output:
- First access: "Token GITHUB_TOKEN accessed and cached (value: ghp_...)"
- Subsequent: "Token GITHUB_TOKEN accessed (cached value: ghp_...)"
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
* fix(one-shot-token): temporarily disable ANTHROPIC_API_KEY
Comment out ANTHROPIC_API_KEY from DEFAULT_SENSITIVE_TOKENS to address
smoke CI timeout issues with Claude. This is a temporary change that
will be reverted once the underlying issue is resolved.
The token is commented out rather than removed to make it easy to
restore later.
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
* fix(one-shot-token): re-enable ANTHROPIC_API_KEY
Uncomment ANTHROPIC_API_KEY in DEFAULT_SENSITIVE_TOKENS to restore
token protection for Anthropic API keys. The token was temporarily
disabled to address Claude timeout issues, but is now being
re-enabled.
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
* fix(docker): mount ~/.cache, ~/.config, ~/.local in chroot mode
Claude Code and other CLI tools need write access to ~/.cache, ~/.config,
and ~/.local directories for state management, caching, and configuration.
In chroot mode, these directories were not mounted, causing tools to fail
when trying to write state. This resulted in Claude Code timing out after
10 minutes.
The fix mounts these directories at /host paths in chroot mode, similar to
the ~/.copilot mount. These directories are safe to mount as they contain
application state, not credentials. Specific credential files within
~/.config (like ~/.config/gh/hosts.yml) remain blocked via /dev/null
overlays.
Verified fix:
- ~/.cache: ✓ Writable
- ~/.config: ✓ Writable
- ~/.local: ✓ Writable
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
* fix(docker): mount ~/.anthropic in chroot mode for Claude Code
Add read-write mount for ~/.anthropic directory in chroot mode to allow
Claude Code to store Anthropic-specific state and configuration.
This directory is safe to mount as it contains only Claude-specific
application state, not credentials.
Verified: ~/.anthropic is writable in chroot mode.
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
* fix(one-shot-token): initialize token list in secure_getenv
Critical security fix: secure_getenv() was calling get_token_index()
before initializing the token list. If secure_getenv() was the first
function called for a sensitive token, tokens_initialized would be 0,
causing the token to pass through unprotected and remain exposed in
/proc/self/environ.
The fix mirrors getenv()'s initialization flow:
1. Take token_mutex
2. Call init_token_list() if not initialized
3. Get token_idx while holding mutex
This ensures sensitive tokens are always properly cached and removed
from the environment, regardless of which function is called first.
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
* fix(docker): mount ~/.claude in chroot mode for Claude CLI
Add read-write mount for ~/.claude directory in chroot mode to allow
Claude CLI to store state and configuration.
This directory is safe to mount as it contains only Claude-specific
application state, not credentials.
Verified: ~/.claude is writable in chroot mode.
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>1 parent 76c0c15 commit 740a42a
3 files changed
Lines changed: 121 additions & 4 deletions
File tree
- containers/agent/one-shot-token
- src
- tests/integration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| 293 | + | |
| 294 | + | |
293 | 295 | | |
294 | 296 | | |
295 | 297 | | |
| |||
318 | 320 | | |
319 | 321 | | |
320 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
321 | 330 | | |
322 | 331 | | |
323 | | - | |
| 332 | + | |
324 | 333 | | |
| 334 | + | |
325 | 335 | | |
326 | 336 | | |
327 | 337 | | |
328 | | - | |
329 | | - | |
330 | | - | |
| 338 | + | |
331 | 339 | | |
332 | 340 | | |
333 | 341 | | |
| |||
354 | 362 | | |
355 | 363 | | |
356 | 364 | | |
| 365 | + | |
| 366 | + | |
357 | 367 | | |
358 | 368 | | |
359 | 369 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
492 | 512 | | |
493 | 513 | | |
494 | 514 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments