Repository navigation
Security & correctness hardening (P0 + P1) #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3797c63
fix(executor): enforce workspace isolation for every tool call and sc…
hutusi e97263a
fix(worker): contain artifact ingestion against symlink escapes
hutusi 6749bcb
fix(authz): pin an authorized run manifest and scope repo connections…
hutusi 173d673
fix(engine): atomic run transitions, DB-allocated event seq, recovera…
hutusi 2facd4b
fix(engine): recover crashed no-retry steps and resume their session
hutusi b514faa
fix(engine): align quota window and stop double-counting run spend on…
hutusi 9f001a1
fix(artifacts): enforce the step output contract on ingestion
hutusi ad48700
fix(api): close the SSE replay/subscribe gap by subscribing first
hutusi dbc379f
docs: record the security & correctness hardening
hutusi 300df2c
fix: address review — atomic approvals, safe sweeper, tighter lifecyc…
hutusi 28c319e
fix(security): address review — symlink writes, env allowlist, /app o…
hutusi 775db9d
docs: correct the enqueue window, SSE polling, and optional-resource …
hutusi f8985a2
fix(security): confine reads + redact event secrets; make seq/finaliz…
hutusi 8eeed20
fix: attempt-safe/binary artifacts, requires.skills, per-phase budget…
hutusi 509a5c7
fix: safe artifact-attempt cleanup + unified run-lifecycle finalization
hutusi 780cd17
fix: symmetric resource resolution, contiguous SSE cursor, split comp…
hutusi 1d444f6
fix(security): allow-list the agent subprocess env; harden the manife…
hutusi da8f08b
fix: guard the artifact-size env and mount the API artifact store rea…
hutusi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import { afterEach, describe, expect, it } from "bun:test"; | ||
| import { mkdtempSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; | ||
| import { mkdir } from "node:fs/promises"; | ||
| import { tmpdir } from "node:os"; | ||
| import path from "node:path"; | ||
| import { DiskArtifactStore } from "./artifacts"; | ||
|
|
||
| const store = new DiskArtifactStore(); | ||
| const dirs: string[] = []; | ||
|
|
||
| function freshWorkspace(): string { | ||
| const dir = mkdtempSync(path.join(tmpdir(), "agrippa-ws-")); | ||
| dirs.push(dir); | ||
| return dir; | ||
| } | ||
|
|
||
| afterEach(() => { | ||
| for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true }); | ||
| }); | ||
|
|
||
| describe("DiskArtifactStore path containment", () => { | ||
| it("stores a normal in-workspace file inline", async () => { | ||
| const ws = freshWorkspace(); | ||
| await mkdir(path.join(ws, ".agrippa/artifacts"), { recursive: true }); | ||
| writeFileSync(path.join(ws, ".agrippa/artifacts/report.md"), "# ok"); | ||
|
|
||
| const stored = await store.store( | ||
| "run-1", | ||
| "report", | ||
| "markdown", | ||
| { | ||
| path: ".agrippa/artifacts/report.md", | ||
| }, | ||
| ws, | ||
| ); | ||
| expect(stored.inline).toBe("# ok"); | ||
| expect(stored.size).toBeGreaterThan(0); | ||
| }); | ||
|
|
||
| it("rejects a symlink escaping the workspace", async () => { | ||
| const ws = freshWorkspace(); | ||
| await mkdir(path.join(ws, ".agrippa/artifacts"), { recursive: true }); | ||
| // secret file outside the workspace, reachable only via the symlink | ||
| const outside = mkdtempSync(path.join(tmpdir(), "agrippa-secret-")); | ||
| dirs.push(outside); | ||
| const secret = path.join(outside, "environ"); | ||
| writeFileSync(secret, "AGRIPPA_SECRET_KEY=master"); | ||
| symlinkSync(secret, path.join(ws, ".agrippa/artifacts/leak.md")); | ||
|
|
||
| await expect( | ||
| store.store("run-1", "leak", "markdown", { path: ".agrippa/artifacts/leak.md" }, ws), | ||
| ).rejects.toThrow(/escapes the run workspace/); | ||
| }); | ||
|
|
||
| it("treats a missing file as no content, not a zero-byte artifact", async () => { | ||
| const ws = freshWorkspace(); | ||
| const stored = await store.store( | ||
| "run-1", | ||
| "nope", | ||
| "markdown", | ||
| { | ||
| path: ".agrippa/artifacts/nope.md", | ||
| }, | ||
| ws, | ||
| ); | ||
| expect(stored.inline).toBeNull(); | ||
| expect(stored.storageRef).toBeNull(); | ||
| expect(stored.size).toBe(0); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.