Skip to content

feat: export handoffs to host paths - #1141

Merged
sarahxsanders merged 4 commits into
mainfrom
feat/handoff-output-file
Aug 27, 2026
Merged

sarahxsanders merged 4 commits into
mainfrom
feat/handoff-output-file

Conversation

@fercgomes

Copy link
Copy Markdown
Contributor

Problem

Cloud workers cannot use the report the Wizard publishes, so pull requests must use a generic body.

Changes

  • The Wizard can mirror a published handoff to a host-provided output path.
  • A failed file write keeps the user-facing handoff successful.
  • The host controls the output path outside agent input.

Test plan

  • Passed: focused handoff tests, Prettier, ESLint, and diff checks.
  • Not clean: repository typecheck has existing unrelated errors.
  • Not clean: the build bundles, but its smoke test cannot resolve the declared fuse.js dependency.

LLM context

Autonomy: Human-driven (agent-assisted)

Codex implemented the change. Skills used: wizard-development, writing-tests, and writing-pr-descriptions.

@fercgomes fercgomes self-assigned this Aug 25, 2026
@fercgomes
fercgomes marked this pull request as ready for review August 25, 2026 14:36
@fercgomes
fercgomes requested a review from a team as a code owner August 25, 2026 14:36

@edwinyjlim edwinyjlim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✍️

…nd scan gaps

Addresses the security review findings on the host-path handoff export:

1. Hardened write (wizard-tools/handoff.ts): the output write now refuses
   relative paths and non-regular destinations (symlink/dir/FIFO/device),
   writes a unique sibling temp file with O_NOFOLLOW | O_EXCL, renames it
   atomically over the target, and enforces 0o600 on the final file even
   when the host pre-created it looser. Write failures stay fail-open for
   the user-facing handoff but are surfaced in the tool result message
   and logged (agent-safe reason; full detail local-only).

2. Env isolation (agent-env-isolation.ts): POSTHOG_HANDOFF_OUTPUT_PATH,
   POSTHOG_TASK_RUN_ID, and POSTHOG_TASK_ID are stripped from the agent
   subprocess env. None is read by the subprocess (the MCP tool executes
   in the wizard process); leaking them told the agent exactly which file
   its report lands in. POSTHOG_API_KEY / POSTHOG_HOST stay passed
   through deliberately (pre-existing disposition, documented).

3. Scanner coverage (pi security.ts + yara-hooks.ts): publish_handoff
   content now passes the same 'output'-context YARA scan + triage as
   write/edit, on both harnesses — pi via a preExecutionYaraBlock case,
   anthropic via a new PreToolUse matcher on the MCP tool. Previously it
   was the one agent-driven write no scanner saw; now hardcoded keys /
   PII in the report block before persistence.
@PostHog PostHog deleted a comment from github-actions Bot Aug 25, 2026
@fercgomes
fercgomes requested a review from edwinyjlim August 25, 2026 18:41

let stat;
try {
stat = lstatSync(targetPath);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: Symlinked parent directories redirect the host write

lstatSync checks only the final component, so a symlinked ancestor makes an unrelated target appear to be a regular file; the temporary file and renameSync then follow that ancestor and overwrite the redirected file. Resolve the operation through a host-owned directory that untrusted project code cannot modify, or use directory-relative filesystem operations that pin and validate the parent rather than relying on path-string checks.

@veria-ai

veria-ai Bot commented Aug 25, 2026

Copy link
Copy Markdown

PR overview

This pull request adds support for exporting handoffs from the wizard tooling to host filesystem paths.

One security issue remains open in the host export path handling. A project-controlled symlink in a parent directory can redirect the export and overwrite an unintended host file within the process's filesystem permissions. No reported issues have been addressed yet.

Open issues (1)

Fixed/addressed: 0 · PR risk: 6/10

@fercgomes

Copy link
Copy Markdown
Contributor Author

/trunk merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants