Repository navigation
feat(setup): report each tool's setup outcome every run [WEB-6392] - #446
Conversation
…errors [WEB-6392]
…s and the backstop [WEB-6392]
…written [WEB-6392]
…er's run [WEB-6392]
…s floor [WEB-6392]
…fill helper [WEB-6392]
…rsor's log [WEB-6392]
… copilot install fails [WEB-6392]
…ry uses [WEB-6392]
…each run [WEB-6392]
…, as the binary does [WEB-6392]
…op-in on windows [WEB-6392]
|
/review |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
🛡️ Automated Security Review (consensus)
1 finding: 0 high-confidence, 1 to triage. Reviewers: Claude, Semgrep, Gitleaks.
- [LOW] Windows race between the junction check and the rename in
_replace_user_file🟡 —augment/hooks/mdm/setup.py(_replace_user_file; the same code is copied into the other MDM scripts)- What: On Windows, SYSTEM checks the path for junctions before and after it opens the temp file. It then calls
os.replace(tmp, path)andtmp.unlink(), which look up the path again with no check. - Why: A user who controls
~/.<tool>/hookscan swap a folder on the path for a junction after_refuse_if_redirectedpasses. SYSTEM would then create, overwrite or delete a file with a fixed name (.error_log_forwardedor..error_log_forwarded.<pid>.tmp) in a folder the user picks. The name is fixed and the content is a timestamp in a checked format, so this is a narrow tool for gaining privilege, not an arbitrary write. - Fix: Keep the temp file's handle open and rename through that handle (
SetFileInformationByHandlewithFileRenameInfo), so no path is looked up twice. Another option is to do the state write on Windows as the user, through a process that runs with the user's token. - Flagged by: Claude
- What: On Windows, SYSTEM checks the path for junctions before and after it opens the temp file. It then calls
Pre-existing (not introduced by this PR)
pickle.loadsof the child's output in_run_as_user: Semgrepavoid-pickle, ataugment/hooks/mdm/setup.py:211,264and the matching lines in the claude-code, codex, copilot and cursor MDM scripts. The parent runs as root and unpickles bytes from a child that runs as the user. This PR only adds a time limit to that read and does not change how the data is read. The risk depends on the user being unable to write into the child's pipe, which non-dumpable processes on Linux and macOS prevent. Consider swapping pickle for JSON when this code is next changed.- Semgrep
insecure-file-permissions(0o700/0o755/0o775) andexec-detected(copilot/hooks/mdm/setup.py:913) are on lines this diff does not touch. They are not raised here.
setup_cmd.py, and some tests. The other four MDM scripts, onboard.sh, install.ps1 and the backfill changes were not reviewed.
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 2b03cdff · 2026-11-26T22:38Z
…amp so rotation cannot hide one [WEB-6392]
|
/review |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
🛡️ Automated Security Review (consensus)
2 findings — 0 high-confidence, 2 to triage. Reviewers: claude, semgrep, gitleaks.
-
[LOW] Header injection through the device key in a user's config.json 🟡 —
binary/src/unbound_hook/setup_cmd.py(_post_jsonand_home_device_key); the same pattern is inaugment/hooks/mdm/setup.py(_post_hook_jsonand_home_device_key) and the other MDM copies- What:
_home_device_keytakesapi_keyanddevice_tokenfrom the user-writable~/.unbound/config.json. It only checks that each is a non-emptystr._post_jsonthen writesf"{name}: {value}\n"into the curl-H @fileheader file. A CR or LF in the key adds extra header lines to a request that the root or SYSTEM setup process sends. - Why: A local user can make the privileged installer send any headers they choose to
/v1/hooks/errors. The user could already send that request with their own key. But if the gateway or an upstream proxy trusts internal headers (forwarding, identity or tenant hints), this hands that control to an unprivileged user.⚠️ The real impact depends on gateway header handling, which is not in this diff. - Fix: Refuse any header value that contains
\r,\nor other control characters before writing the header file. Also check the key against its expected shape (charset and length) in_home_device_key. - Flagged by: claude
- What:
-
[LOW] Best-effort redaction lets common credential formats through to the gateway and Sentry 🟡 —
binary/src/unbound_hook/setup_cmd.py(_redact_hook_error,_VENDOR_KEY); the same code is inaugment/hooks/mdm/setup.pyand the other MDM copies- What: Forwarded
error.logentries can be up to 2,000 characters, and traceback lines are attached to the entry. Redaction removes the home's own keys,Bearer …,name=valuepairs andsk-…keys. Tokens with no label pass through, such asghp_…/github_pat_…,AKIA…,xox[bp]-…, bare JWTs (eyJ…) and PEM private-key blocks. - Why: Hook errors often quote the tool input or command that failed. With this PR, device-local error text is sent off the machine on every run and grouped in Sentry. Any credential in that text is copied to a third-party store.
- Fix: Add patterns for the common token formats (GitHub, AWS access key IDs, Slack, JWT,
-----BEGIN … PRIVATE KEY-----). Better still, reuse the gateway's or the DLP engine's secret detector so the copies don't drift apart. Consider a shorter cap on traceback lines. - Flagged by: claude
- What: Forwarded
Pre-existing (not introduced by this PR)
pickledeserialization of privilege-dropped child output (*/mdm/setup.py_run_as_user, semgrepavoid-pickle): the root parent unpickles bytes from a child that runs as the target user. The PR changes the read and wait loop of_run_as_user(it adds the_timeoutbound) but not the pickle calls. It also sends more user-file parsing through this helper. The design is safe only while the user cannot tamper with that child. Replacing pickle with JSON for these return values would remove the risk.- The semgrep
insecure-file-permissions(0o700/0o755/0o775) andexec-detectedhits are on code this PR did not add. They concern directories and executables, which need those modes, so they are not raised here.
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 93b17fd9 · 2026-11-26T23:04Z
…he home [WEB-6392]
|
/review |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
✅ Security consensus: no issues found. (reviewers: Claude, Semgrep, Gitleaks)
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 10fd96a0 · 2026-11-26T23:18Z
…ed to be the path asked for [WEB-6392]
|
/review |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
🛡️ Automated Security Review (consensus)
3 findings — 0 high-confidence, 3 to triage. Reviewers: claude, semgrep, gitleaks.
-
[MEDIUM] Hook error.log content is forwarded with only best-effort redaction 🟡 —
binary/src/unbound_hook/setup_cmd.py(_redact_hook_error/_post_hook_errors), and the same copy in each MDM script, e.g.augment/hooks/mdm/setup.py- What: Setup now reads each user's
error.log(up to 25 entries per tool per home, up to 2,000 chars each, with traceback lines) and sends it to/v1/hooks/errors, which feeds Sentry. Before sending, it removes only the home's own keys,Bearer …,name=valuepairs, a few URL params, andsk-…strings. - Why: Hook errors can include tool inputs, command lines, file paths, and exception text. Many common credential shapes get through the redaction: AWS
AKIA…keys, GitHubghp_/github_pat_tokens, Slackxox…tokens, JWTs, PEM blocks, anduser:pass@hostURLs. Until now these logs stayed on the device. They now leave it on every run, for every user, with no opt-in. - Fix: Add patterns for the missing credential shapes (AKIA, gh*_, xox*,
eyJ…JWTs,-----BEGIN, URL userinfo). Better still, send only the error class and the first line, not the whole traceback. Consider an org-level switch to turn forwarding on. - Flagged by: claude
- What: Setup now reads each user's
-
[LOW] Windows forwarded-state write still uses the path after the handle check (TOCTOU) 🟡 —
augment/hooks/mdm/setup.py:~1673(_replace_user_file, and the same code in the other MDM scripts)- What: On Windows these steps run directly as SYSTEM.
_refuse_if_redirectedchecks the opened handle, buttmp.unlink(), the error-pathtmp.unlink(), andos.replace(tmp, path)then work on the path again. TOCTOU (time-of-check to time-of-use) means the path can change between the check and the use. - Why: If a user swaps a parent folder for a junction after the check, SYSTEM can create, rename, or delete
.error_log_forwarded[.<pid>.tmp]inside a folder the user cannot write to. The impact is limited, because the file names are fixed and the content is a timestamp/digest string. It is still a privileged write through a user-controlled path, the same kind of issue as the earlier cursor cleanup P0. - Fix: Do the rename and delete through the checked handle (
SetFileInformationByHandlewithFileRenameInfo/FileDispositionInfo). This matches the_delete_where_askedapproach used for cursor cleanup. Or do the write step in a process that runs as the user. - Flagged by: claude
- What: On Windows these steps run directly as SYSTEM.
-
[LOW] A killed user-side child can be treated as a successful exit 🟡 —
augment/hooks/mdm/setup.py:~234-260(_run_as_usertimeout path;⚠️ the PR says the claude-code and cursor copies got the same change, but those parts of the diff are truncated)- What: When the read deadline passes, the parent sends SIGKILL and
breaks, keeping the partial output. If the child is already reaped by the firstwaitpid(WNOHANG),statusis a signal status.os.WEXITSTATUS(status)returns0for a signal status, so the parent goes on to unpickle the truncated output from a process the user controls. - Why: The user can pause their own privilege-dropped child, which is the exact case this timeout exists for. A truncated pickle will most likely fail to load, so this is not shown to be exploitable. But the privilege boundary now relies on that failure, not on an explicit check.
- Fix: Return
Noneright after the timeout kill. Also requireos.WIFEXITED(status) and os.WEXITSTATUS(status) == 0before readingdata. - Flagged by: claude
- What: When the read deadline passes, the parent sends SIGKILL and
Pre-existing (not introduced by this PR)
avoid-pickle(semgrep) in_run_as_useracross all five MDM scripts: the root parent unpickles output from a child that runs as the user. This PR changed the function but not the pickle lines. JSON would remove this class of risk at the privilege boundary.insecure-file-permissions(semgrep) at0o700/0o755andexec-detectedatcopilot/hooks/mdm/setup.py:913: these lines are not in the diff.0o700is already restrictive, so those hits are noise.
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 8b31eab4 · 2026-11-26T23:32Z
…rors like the other scripts [WEB-6392]
|
/review |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
🛡️ Automated Security Review (consensus)
2 findings — 1 high-confidence, 1 to triage. Reviewers: Codex, Claude, Semgrep, Gitleaks.
-
[HIGH] Windows checkpoint writes retain a SYSTEM path race 🔴 —
antigravity/hooks/mdm/setup.py:977- What:
_replace_user_filevalidates the opened temporary file, then performstmp.unlink()andos.replace()by pathname; the same helper appears across MDM scripts. - Why: A local user can swap a parent directory for a junction after validation, redirecting privileged deletion or replacement outside their profile. The PR author's claimed Windows fix protects opens but leaves these later mutations exposed.
- Fix: Perform Windows checkpoint writes under the user's token, or use handle-based deletion and rename with a pinned, validated destination directory.
- Flagged by: Codex, Claude
- What:
-
[MEDIUM] Forwarded log messages can expose unredacted credentials 🟡 —
antigravity/hooks/mdm/setup.py:875- What: Error forwarding uploads free-form messages and traceback continuations after applying a limited set of credential patterns.
- Why: If logged exceptions contain GitHub tokens,
Authorization: Basiccredentials, or other unsupported formats, those values pass unchanged to/v1/hooks/errors; the supplied diff does not establish how frequently such content reaches these logs. - Fix: Prefer structured, allowlisted error fields; otherwise expand credential scrubbing across every implementation and apply server-side redaction before downstream reporting.
- Flagged by: Claude
🤖 consensus review · reviewers: Codex, Claude, Semgrep, Gitleaks · head a374341c · 2026-11-30T09:21Z
…ome users [WEB-6392]
…lder and redact github and basic credentials [WEB-6392]
|
/review |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
🛡️ Automated Security Review (consensus)
1 finding: 0 high-confidence, 1 to triage. Reviewers: Claude (own review), Semgrep, Gitleaks.
- [MEDIUM] User's
~/.npmrcprefix makes SYSTEM reach out to a UNC path (forced NTLM authentication) 🟡 —augment/hooks/mdm/setup.py(_npmrc_cli_dir/tool_installed); the same code is copied into every MDM script (antigravity/hooks/mdm/setup.pyand the others)- What: on Windows,
tool_installed()runs as SYSTEM. It reads theprefix=line from each user's~/.npmrcand keeps any value thatos.path.isabsaccepts. That includes UNC paths such as\\attacker.example\share. It then callsPath(value) / "auggie.exe"and.exists()on that path. - Why: any local user can write
prefix=\\host\sharein their own.npmrc. The SYSTEM setup run then opens an SMB connection to that host. This sends the machine account's NetNTLM hash, which the attacker can capture or relay (for example, to LDAP or AD CS). Relaying a machine account is a known route to local privilege escalation. The npm check only runs when no other footprint was found, so it fires on every device where the tool is not installed. The path globs_foundchecks under a user's home (such asAppData/Roaming/nvm/*) are also checked as SYSTEM, so a symlink there that points to a UNC path has the same effect. - Fix: reject
prefixvalues that start with\\or//, and anything that is not a local drive path. Better still, on Windows run the.npmrcand per-home existence checks through the same link and redirect guards as_read_user_file, or skip the.npmrclookup when running as SYSTEM. Mirror the fix in all copies;tests/test_tool_installed.pykeeps them identical. - Flagged by: Claude
- What: on Windows,
Pre-existing (not introduced by this PR)
pickle.loadsof child output in_run_as_user(Semgrepavoid-pickle, in every MDM script). The privileged parent unpickles bytes sent by a child that has already switched to the user's account. This PR only added a_timeoutto it, and it now sends more steps that handle user-controlled data through it (error-log parsing, reading the config key). Exploiting it means taking over that child process. Consider switching the parent–child channel to JSON.
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 0925caf7 · 2026-11-30T09:46Z
…indows through ntdll [WEB-6392]
…come like the other tools [WEB-6392]
|
/review |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
🛡️ Automated Security Review (consensus)
2 findings — 0 high-confidence, 2 to triage. Reviewers: Claude, Semgrep, Gitleaks.
Note: the diff was cut off at 80 KB of 438 KB. This review covers only the part shown: antigravity, augment, binary/README.md, and the start of binary/src/unbound_hook/setup_cmd.py.
-
[LOW] User-set key can add extra lines to curl's header file 🟡 —
antigravity/hooks/mdm/setup.py(_post_hook_json/_post_hook_errors); the same code is inaugment/hooks/mdm/setup.py- What:
_home_device_keyreadsapi_key/device_tokenfrom the user's own~/.unbound/config.json. Root then writes it unchanged into the-H @fileheader file asAuthorization: Bearer {api_key}\n, so a key containing\nadds headers of the user's choosing. - Why: a local user can add any headers to the root-run POST to
/v1/hooks/errors. The request is already signed with that user's own key, so the impact is small. But a value the user controls flows into a file root writes, with no checks. - Fix: refuse, or strip
\r/\n, in every header name and value in_post_hook_json. Also accept only keys that match the expected token shape in_home_device_key. - Flagged by: Claude
- What:
-
[LOW] Only known patterns are redacted before hook errors go to the gateway and Sentry 🟡 —
antigravity/hooks/mdm/setup.py(_redact_hook_error,_unsent_hook_errors); the same code is inaugment/hooks/mdm/setup.py- What: up to 25
error.logentries per tool and home, each up to 2,000 characters with traceback lines, are now sent off the device. Redaction (removing secrets) only catches the home's own keys, Bearer/Basic tokens,name=valuesecrets, URL query keys, andsk-/ghp_/github_pat_tokens. - Why: other secret shapes are sent in clear text if a hook error message contains them. Examples: AWS
AKIA…keys, JWTs, PEM private keys, or prompt and file text echoed into a traceback. Before this PR those entries never left the device. - Fix: add common token shapes (AWS keys, JWTs,
-----BEGIN … PRIVATE KEY-----, Slackxox[abp]-tokens). Consider sending only the first line plus the exception type rather than whole tracebacks. - Flagged by: Claude
- What: up to 25
Pre-existing (not introduced by this PR)
- Root unpickles data from a child process running as the user —
_run_as_userin each MDMsetup.py(Semgrepavoid-pickleat antigravity:100/155, augment:211/264, claude-code:133/186, codex:127/182, copilot:136/191, cursor:103/156).- The pickle code itself is unchanged. This PR adds only the
_timeoutbound. - This PR now sends much more work through it: log reads, key reads, and state writes for every home.
- The risk is limited today, because the child is no longer dumpable after
setuid, so the user cannot ptrace it.⚠️ If that ever stops holding, root would load data the user controls. - A plain JSON return format would remove the risk.
- The pickle code itself is unchanged. This PR adds only the
- The Semgrep
insecure-file-permissionshits (0o700/0o755/0o775) are directory and executable modes, not secrets. None of them is a real issue on the lines shown.
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 3f9aaed0 · 2026-11-30T10:12Z
…rors from the binary [WEB-6392]
|
/review |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
🛡️ Automated Security Review (consensus)
1 finding: 0 high-confidence, 1 to triage. Reviewers: Claude (lead), Semgrep, Gitleaks.
- [LOW]
globals()lookup with a non-constant index 🟡:claude-code/hooks/setup.py:2301- What: Semgrep reports that
globals()is indexed with a computed name. This line is outside the part of the diff shown here, so it is not confirmed whether this PR added it or what controls the name. It sits near the backfill-outcome code this PR changes (about lines 2213–2233). - Why: If the name can come from a file, config or server response, an attacker could call any module-level function in a setup that runs as root. If the name comes from a fixed internal set, there is no risk.
- Fix: Use an explicit dict of allowed names, for example
{"completed": ..., "failed": ...}[name], instead ofglobals()[name]. Or show that the index comes only from constants. - Flagged by: Semgrep (dangerous-globals-use)
- What: Semgrep reports that
Pre-existing (not introduced by this PR)
_run_as_userunpickles the child's output as root:*/mdm/setup.py(Semgrep avoid-pickle, all six MDM scripts). The child runs with the user's uid. The root parent then runspickle.loadson whatever the child wrote to the pipe. Today the child cannot be tampered with because a process that drops from root is non-dumpable (other processes cannot inspect or attach to it). This PR now runs this path on every setup for each home (key read, log read, place save), which makes it a more frequent target. Consider JSON for the return channel, because every new caller returns plain data (strings, lists, dicts, bools).- The
insecure-file-permissionshits (0o700,0o755,0o775,$BITS) are on directory and executable-hook modes. They do not come from this diff's changes and are not real issues.0o700is stricter than the rule's suggested0o644.
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head d560a3db · 2026-11-30T10:20Z
Refs WEB-6392
What
configured,skippedordeferred, with a reason and the file it wrote. This works from the binary and from the Python MDM scripts on Mac, Linux and Windows, Antigravity's included.error.logto the gateway.skipped, "Cursor is not installed"deferredreport with the tamper statestopped_by_cap, carried to the next run if unsenterror.logWhy
How
tool_installed()check that the binary uses.tests/test_tool_installed.pykeeps the copies identical, because the scripts run alone through curl.CLAUDE_CONFIG_DIRorCOPILOT_HOMEgets no forwarded errors. Setup ignores these variables at install too, and root cannot see a user's shell variables. Pugaz accepted this limit, because the case is rare.Testing
pytest tests/test_mdm_setup_status.py tests/test_tool_installed.py tests/claude_code binary/testswith a temporaryHOME: 2,959 passed, 8 failedpyteston the same 8 tests on plainstaging: the same 8 failed, so they come from before this branchinstall.ps1onboarding on a Windows Server 2022 Azure VM as SYSTEM: 4 tools configured, Augment skipped as not installed, backfill outcomecompletedonboard.shas root in a Linux Docker container: installed, not installed and write-failed tools each sent the right statusProof
8 failed, 2959 passed, 40 skippedon this branch. The 8 failures need/opt/unboundon the test machine and also fail onstaging.Risk and rollout
main. Merge after websentry-ai/ai-gateway-data#3575 and feat(discovery): report skipped scans and hook policy [WEB-6392] coding-discovery-tool#440 are live.skippedas connected and rejects run start and end reports.Start review at:
binary/src/unbound_hook/setup_cmd.pyUnbound Review · Score 5/5 (no findings) ·
d560a3dtool_installedcheck, start and end run reports, and forwarding of each hook'serror.logentries to the gateway before the migration sweep runs. I checked the binary'srun()ordering, the_reportand_tool_reporterwiring and the bounded_as_userpath. I also checked the_run_as_userfindings: 0 P0 · 0 P1 · 0 P2 (top 5 P0/P1 inline) · engines: codex ✅ · claude ✅