Skip to content

Commit 10c8d52

Browse files
committed
Authenticate profiles at disposal boundary
1 parent a5dfaba commit 10c8d52

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎agents/container/run.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { execFileSync, spawnSync } from 'node:child_process';
22
import { realpathSync } from 'node:fs';
3-
import { assertContainerProfile, disposeContainerProfile, isContainerProfileAuthentic, profileTimeout,
3+
import { assertContainerProfile, assertContainerProfileAuthenticity, disposeContainerProfile,
4+
isContainerProfileAuthentic, profileTimeout,
45
type ContainerProfile } from './profile.ts';
56
import { BASE_IMAGE, CLAUDE_VERSION, CODEX_VERSION } from './image.ts';
67
import { taskFilesystemAllocationId } from './storage.ts';
@@ -90,6 +91,7 @@ const removeContainerOrThrow = (profile: ContainerProfile, createUnsettled = fal
9091

9192
/** Remove a validated invocation container, then its profile-owned staging and network resources. */
9293
export function disposeValidatedContainer(profile: ContainerProfile): void {
94+
assertContainerProfileAuthenticity(profile);
9395
removeContainerOrThrow(profile);
9496
}
9597

‎test/agent-supervisor.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { isInvocationActive, readBoundedContainerFile, retainSetupCleanup,
1010
import { captureInvocation, type InvocationInput } from '../agents/contract.ts';
1111
import { buildAgentImage } from '../agents/container/image.ts';
1212
import { createContainerProfile, disposeContainerProfile, type ContainerProfile } from '../agents/container/profile.ts';
13-
import { prepareTaskFilesystems, removeTaskFilesystems } from '../agents/container/run.ts';
13+
import { disposeValidatedContainer, prepareTaskFilesystems, removeTaskFilesystems } from '../agents/container/run.ts';
1414
import { createVendorNetwork } from '../agents/network/network.ts';
1515
import { createIsolationProbeCommand, createPhasePolicy, type IsolationProbe } from '../agents/policy.ts';
1616
import { createTaskClone } from '../git/clone.ts';
@@ -174,6 +174,7 @@ describe('container invocation supervisor', () => {
174174
const current = profile(fixture(), 'ignore-term', 'cloned-profile');
175175
const first = startProfileInvocation(current, { timeoutMs: 30_000 });
176176
const clone = Object.freeze({ ...current });
177+
expect(() => disposeValidatedContainer(clone)).toThrow('not created by the trusted profile builder');
177178
expect(() => startProfileInvocation(clone)).toThrow('not created by the trusted profile builder');
178179
expect(isInvocationActive('cloned-profile')).toBe(true);
179180
expect(spawnSync('docker', ['container', 'inspect', current.name]).status).toBe(0);

0 commit comments

Comments
 (0)