feat(tasks): upload agent-created artifacts#3754
Conversation
Generated-By: PostHog Code Task-Id: 69a64521-9a7f-4886-937e-3cf1e05ef563
|
😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details. |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
| } | ||
| form.append( | ||
| "file", | ||
| new Blob([await readFile(artifactPath)], { type: contentType }), |
There was a problem hiding this comment.
High: Symlink race bypasses workspace containment
The containment check and stat operate before this readFile, so an agent can run a background rename/symlink loop that makes realpath validate an in-workspace file and then redirects this reopen to a file such as /tmp/agent-env. That lets the agent register sandbox credentials or other out-of-workspace data as a downloadable artifact. Open the file once, verify the opened descriptor's canonical target is within workspace, and use that same descriptor for stat and reading rather than reopening the pathname.
PR overviewThis pull request adds support for uploading artifacts created by agents through the local tools adapter. One security issue remains open in the artifact upload path: a symlink race can bypass workspace containment and expose files outside the workspace as downloadable artifacts. No issues have yet been addressed, and the remaining flaw could disclose sandbox credentials or other sensitive data accessible to the agent process. Open issues (1)
Fixed/addressed: 0 · PR risk: 8/10 |
|
Reviews (1): Last reviewed commit: "feat(tasks): upload agent-created artifa..." | Re-trigger Greptile |
Problem
Files created by cloud agents only live in the temporary sandbox, so users cannot download non-code deliverables after a run ends.
Why: Cloud tasks need a durable, adapter-independent way to deliver reports, images, archives, and other generated files.
Changes