@memnexus-ai/mx-agent-cli 0.1.249 → 0.1.250
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/codex-agent-gate.test.js +110 -34
- package/dist/__tests__/codex-agent-gate.test.js.map +1 -1
- package/dist/commands/codex-agent-gate.d.ts +52 -1
- package/dist/commands/codex-agent-gate.d.ts.map +1 -1
- package/dist/commands/codex-agent-gate.js +66 -41
- package/dist/commands/codex-agent-gate.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,41 +11,115 @@
|
|
|
11
11
|
import { describe, it, expect } from 'vitest';
|
|
12
12
|
import { readFileSync, readdirSync, statSync } from 'fs';
|
|
13
13
|
import { join } from 'path';
|
|
14
|
-
import { decideCodexAgentGate, extractAgentName, parseProvenGuardsArgs, } from '../commands/codex-agent-gate.js';
|
|
14
|
+
import { AGENT_NAME_FIELD, decideCodexAgentGate, extractAgentName, parseProvenGuardsArgs, } from '../commands/codex-agent-gate.js';
|
|
15
15
|
import { CODEX_AGENT_GATE_COMMAND, buildCodexHooksJson } from '../lib/runtime/codex-config.js';
|
|
16
16
|
const PROVEN = ['git-mutation-guard', 'named-memory-write-guard'];
|
|
17
|
+
/**
|
|
18
|
+
* A SubagentStart payload shaped like codex-cli 0.145.0's embedded
|
|
19
|
+
* `subagent-start.command.input` schema. Every `required` property is present, so a
|
|
20
|
+
* test that removes one is testing a real mutation rather than an already-invalid
|
|
21
|
+
* payload.
|
|
22
|
+
*/
|
|
17
23
|
function payload(fields) {
|
|
18
|
-
return JSON.stringify({
|
|
24
|
+
return JSON.stringify({
|
|
25
|
+
agent_id: 'agent_01HZ',
|
|
26
|
+
agent_type: 'git-expert',
|
|
27
|
+
cwd: '/workspace/.worktrees/wt',
|
|
28
|
+
hook_event_name: 'SubagentStart',
|
|
29
|
+
model: 'gpt-5.5',
|
|
30
|
+
permission_mode: 'default',
|
|
31
|
+
session_id: 'abc',
|
|
32
|
+
transcript_path: '/tmp/transcript.jsonl',
|
|
33
|
+
turn_id: 'turn_1',
|
|
34
|
+
...fields,
|
|
35
|
+
});
|
|
19
36
|
}
|
|
20
|
-
describe('extractAgentName —
|
|
21
|
-
it('reads the
|
|
22
|
-
|
|
23
|
-
|
|
37
|
+
describe('extractAgentName — reads the ONE verified field (NEW-6)', () => {
|
|
38
|
+
it('reads agent_type, the field the shipped schema marks required', () => {
|
|
39
|
+
expect(AGENT_NAME_FIELD).toBe('agent_type');
|
|
40
|
+
expect(extractAgentName(JSON.parse(payload({ agent_type: 'memory-creator' })))).toBe('memory-creator');
|
|
41
|
+
});
|
|
42
|
+
it('reads NOTHING ELSE — the schema sets additionalProperties:false', () => {
|
|
43
|
+
// Each of these was accepted before the field name was established. A genuine
|
|
44
|
+
// Codex payload cannot carry them, so accepting them only added ways for a
|
|
45
|
+
// non-genuine payload to name itself something the eligibility table allows.
|
|
46
|
+
for (const field of ['agent_name', 'agentName', 'subagent_type', 'subagentType', 'agent', 'name']) {
|
|
47
|
+
const p = JSON.parse(payload({ [field]: 'git-expert' }));
|
|
48
|
+
delete p[AGENT_NAME_FIELD];
|
|
49
|
+
expect(extractAgentName(p)).toBeNull();
|
|
24
50
|
}
|
|
25
51
|
});
|
|
26
|
-
it('
|
|
27
|
-
|
|
28
|
-
|
|
52
|
+
it('does not descend into a wrapper object', () => {
|
|
53
|
+
for (const key of ['subagent', 'agent_info']) {
|
|
54
|
+
const p = JSON.parse(payload({ [key]: { agent_type: 'red-team' } }));
|
|
55
|
+
delete p[AGENT_NAME_FIELD];
|
|
56
|
+
expect(extractAgentName(p)).toBeNull();
|
|
57
|
+
}
|
|
29
58
|
});
|
|
30
|
-
it('IGNORES tool_input — the one
|
|
31
|
-
// A name read from tool_input is a name the gated party chose
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
expect(decision.exitCode).toBe(2);
|
|
59
|
+
it('IGNORES tool_input — the one field whose contents the model writes', () => {
|
|
60
|
+
// A name read from tool_input is a name the gated party chose for itself.
|
|
61
|
+
const p = JSON.parse(payload({ tool_input: { agent_type: 'git-expert' } }));
|
|
62
|
+
delete p[AGENT_NAME_FIELD];
|
|
63
|
+
expect(extractAgentName(p)).toBeNull();
|
|
64
|
+
const raw = JSON.stringify(p);
|
|
65
|
+
expect(decideCodexAgentGate({ rawPayload: raw, provenGuards: ['git-mutation-guard'] }).exitCode).toBe(2);
|
|
39
66
|
});
|
|
40
67
|
it('trims surrounding whitespace', () => {
|
|
41
|
-
expect(extractAgentName(JSON.parse(payload({
|
|
68
|
+
expect(extractAgentName(JSON.parse(payload({ agent_type: ' git-expert \n' })))).toBe('git-expert');
|
|
42
69
|
});
|
|
43
|
-
it('returns null
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
expect(extractAgentName(
|
|
70
|
+
it('returns null for absent, blank, non-string and non-object input', () => {
|
|
71
|
+
const missing = JSON.parse(payload({}));
|
|
72
|
+
delete missing[AGENT_NAME_FIELD];
|
|
73
|
+
expect(extractAgentName(missing)).toBeNull();
|
|
74
|
+
expect(extractAgentName(JSON.parse(payload({ agent_type: ' ' })))).toBeNull();
|
|
75
|
+
expect(extractAgentName(JSON.parse(payload({ agent_type: 42 })))).toBeNull();
|
|
76
|
+
expect(extractAgentName(JSON.parse(payload({ agent_type: { nested: 'git-expert' } })))).toBeNull();
|
|
47
77
|
expect(extractAgentName(null)).toBeNull();
|
|
48
78
|
expect(extractAgentName('a string')).toBeNull();
|
|
79
|
+
expect(extractAgentName([{ agent_type: 'git-expert' }])).toBeNull();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe('MUTATION CHECK — narrowing the field list did not open the gate', () => {
|
|
83
|
+
// The risk in shrinking seven candidates to one is that a payload which no longer
|
|
84
|
+
// resolves starts being ALLOWED instead of refused. These assert the opposite: for
|
|
85
|
+
// every agent in the eligibility table, and with every guard claimed proven, a
|
|
86
|
+
// payload whose agent_type is missing is still exit 2.
|
|
87
|
+
const AGENTS = ['git-expert', 'memory-creator', 'security-reviewer', 'bar-raiser', 'prd-writer'];
|
|
88
|
+
it('refuses when agent_type is absent, however generous --proven-guards is', () => {
|
|
89
|
+
for (const agent of AGENTS) {
|
|
90
|
+
// Name present in every OTHER plausible field, and in a wrapper, and in
|
|
91
|
+
// tool_input — the exact payload the old seven-candidate list would have
|
|
92
|
+
// resolved and allowed.
|
|
93
|
+
const mutated = JSON.parse(payload({
|
|
94
|
+
agent_name: agent,
|
|
95
|
+
agentName: agent,
|
|
96
|
+
subagent_type: agent,
|
|
97
|
+
subagentType: agent,
|
|
98
|
+
agent,
|
|
99
|
+
name: agent,
|
|
100
|
+
subagent: { agent_type: agent },
|
|
101
|
+
agent_info: { agent_type: agent },
|
|
102
|
+
tool_input: { agent_type: agent },
|
|
103
|
+
}));
|
|
104
|
+
delete mutated[AGENT_NAME_FIELD];
|
|
105
|
+
const d = decideCodexAgentGate({
|
|
106
|
+
rawPayload: JSON.stringify(mutated),
|
|
107
|
+
provenGuards: [...PROVEN, 'worktree-guard', 'mx-guard-hook'],
|
|
108
|
+
});
|
|
109
|
+
expect(d.exitCode).toBe(2);
|
|
110
|
+
expect(d.message).toMatch(/no agent name found/);
|
|
111
|
+
expect(d.agent).toBeUndefined();
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
it('names the field it required, so an operator can diagnose a payload change', () => {
|
|
115
|
+
const missing = JSON.parse(payload({}));
|
|
116
|
+
delete missing[AGENT_NAME_FIELD];
|
|
117
|
+
const d = decideCodexAgentGate({ rawPayload: JSON.stringify(missing) });
|
|
118
|
+
expect(d.message).toContain('agent_type');
|
|
119
|
+
expect(d.message).toMatch(/subagent-start\.command\.input/);
|
|
120
|
+
});
|
|
121
|
+
it('an empty payload object is refused, not treated as an unnamed allow', () => {
|
|
122
|
+
expect(decideCodexAgentGate({ rawPayload: '{}' }).exitCode).toBe(2);
|
|
49
123
|
});
|
|
50
124
|
});
|
|
51
125
|
describe('decideCodexAgentGate — fails CLOSED on unusable input', () => {
|
|
@@ -57,22 +131,24 @@ describe('decideCodexAgentGate — fails CLOSED on unusable input', () => {
|
|
|
57
131
|
it('refuses an empty payload (stdin never opened)', () => {
|
|
58
132
|
expect(decideCodexAgentGate({ rawPayload: '' }).exitCode).toBe(2);
|
|
59
133
|
});
|
|
60
|
-
it('refuses when no agent name can be identified, and
|
|
61
|
-
const
|
|
134
|
+
it('refuses when no agent name can be identified, and names the field it needed', () => {
|
|
135
|
+
const missing = JSON.parse(payload({}));
|
|
136
|
+
delete missing[AGENT_NAME_FIELD];
|
|
137
|
+
const d = decideCodexAgentGate({ rawPayload: JSON.stringify(missing) });
|
|
62
138
|
expect(d.exitCode).toBe(2);
|
|
63
139
|
expect(d.message).toMatch(/no agent name found/);
|
|
64
|
-
expect(d.message).toMatch(/
|
|
140
|
+
expect(d.message).toMatch(/agent_type/);
|
|
65
141
|
});
|
|
66
142
|
});
|
|
67
143
|
describe('decideCodexAgentGate — FR-14b: security-reviewer refused at runtime', () => {
|
|
68
144
|
it('blocks security-reviewer', () => {
|
|
69
|
-
const d = decideCodexAgentGate({ rawPayload: payload({
|
|
145
|
+
const d = decideCodexAgentGate({ rawPayload: payload({ agent_type: 'security-reviewer' }) });
|
|
70
146
|
expect(d.exitCode).toBe(2);
|
|
71
147
|
expect(d.message).toMatch(/Run security review in a Claude session/);
|
|
72
148
|
});
|
|
73
149
|
it('blocks it even when every guard is claimed proven', () => {
|
|
74
150
|
const d = decideCodexAgentGate({
|
|
75
|
-
rawPayload: payload({
|
|
151
|
+
rawPayload: payload({ agent_type: 'security-reviewer' }),
|
|
76
152
|
provenGuards: [...PROVEN, 'worktree-guard'],
|
|
77
153
|
});
|
|
78
154
|
expect(d.exitCode).toBe(2);
|
|
@@ -81,37 +157,37 @@ describe('decideCodexAgentGate — FR-14b: security-reviewer refused at runtime'
|
|
|
81
157
|
describe('decideCodexAgentGate — FR-14a / FR-15 at runtime', () => {
|
|
82
158
|
it('blocks bar-raiser and red-team as in-session subagents', () => {
|
|
83
159
|
for (const agent of ['bar-raiser', 'red-team']) {
|
|
84
|
-
const d = decideCodexAgentGate({ rawPayload: payload({
|
|
160
|
+
const d = decideCodexAgentGate({ rawPayload: payload({ agent_type: agent }), provenGuards: PROVEN });
|
|
85
161
|
expect(d.exitCode).toBe(2);
|
|
86
162
|
expect(d.message).toMatch(/read-only wrapper process/);
|
|
87
163
|
}
|
|
88
164
|
});
|
|
89
165
|
it('blocks every Bash-holding agent with no proven guards — the pre-G-7 state', () => {
|
|
90
166
|
for (const agent of ['git-expert', 'memory-creator', 'dogfood-auditor', 'prd-writer']) {
|
|
91
|
-
const d = decideCodexAgentGate({ rawPayload: payload({
|
|
167
|
+
const d = decideCodexAgentGate({ rawPayload: payload({ agent_type: agent }) });
|
|
92
168
|
expect(d.exitCode).toBe(2);
|
|
93
169
|
expect(d.message).toMatch(/not verified firing/);
|
|
94
170
|
}
|
|
95
171
|
});
|
|
96
172
|
it('allows an agent once ITS OWN guard is proven', () => {
|
|
97
173
|
expect(decideCodexAgentGate({
|
|
98
|
-
rawPayload: payload({
|
|
174
|
+
rawPayload: payload({ agent_type: 'git-expert' }),
|
|
99
175
|
provenGuards: ['git-mutation-guard'],
|
|
100
176
|
}).exitCode).toBe(0);
|
|
101
177
|
});
|
|
102
178
|
it('does not let one guard\'s proof unlock a different agent', () => {
|
|
103
179
|
expect(decideCodexAgentGate({
|
|
104
|
-
rawPayload: payload({
|
|
180
|
+
rawPayload: payload({ agent_type: 'memory-creator' }),
|
|
105
181
|
provenGuards: ['git-mutation-guard'],
|
|
106
182
|
}).exitCode).toBe(2);
|
|
107
183
|
});
|
|
108
184
|
it('blocks an unclassified agent', () => {
|
|
109
|
-
const d = decideCodexAgentGate({ rawPayload: payload({
|
|
185
|
+
const d = decideCodexAgentGate({ rawPayload: payload({ agent_type: 'brand-new-agent' }), provenGuards: PROVEN });
|
|
110
186
|
expect(d.exitCode).toBe(2);
|
|
111
187
|
expect(d.message).toMatch(/no entry in the per-agent safety mechanism table/);
|
|
112
188
|
});
|
|
113
189
|
it('prefixes refusals so the operator knows which control fired', () => {
|
|
114
|
-
const d = decideCodexAgentGate({ rawPayload: payload({
|
|
190
|
+
const d = decideCodexAgentGate({ rawPayload: payload({ agent_type: 'git-expert' }) });
|
|
115
191
|
expect(d.message).toMatch(/^codex agent gate: /);
|
|
116
192
|
});
|
|
117
193
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-agent-gate.test.js","sourceRoot":"","sources":["../../src/__tests__/codex-agent-gate.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE/F,MAAM,MAAM,GAAG,CAAC,oBAAoB,EAAE,0BAA0B,CAAC,CAAC;AAElE,SAAS,OAAO,CAAC,MAA+B;IAC9C,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;AAC5F,CAAC;AAED,QAAQ,CAAC,4CAA4C,EAAE,GAAG,EAAE;IAC1D,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,KAAK,MAAM,KAAK,IAAI,CAAC,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC;YAChH,MAAM,CAAC,gBAAgB,CAAC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ACxF,0DAA0D;QAC1D,MAAM,CAAC,wBAAwB,CAAC,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8EAA8E,EAAE,GAAG,EAAE;QACtF,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE,OAAO,CAAC,CAAC;QAC3D,uEAAuE;QACvE,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC;QACpE,MAAM,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,CAAC,CAAC;QAC9C,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAC3C,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;QAC5C,kEAAkE;QAClE,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,3 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The field that carries the subagent's identity in a SubagentStart payload.
|
|
3
|
+
*
|
|
4
|
+
* ─── HOW THIS WAS ESTABLISHED (security review NEW-6) ───────────────────────────
|
|
5
|
+
* codex-cli 0.145.0 EMBEDS the JSON Schema for every hook's stdin payload in its own
|
|
6
|
+
* binary, under the title `subagent-start.command.input`. That is the contract the
|
|
7
|
+
* shipped binary serializes against, so it is the primary source — stronger than a
|
|
8
|
+
* single observed payload, which shows only the fields that happened to be populated
|
|
9
|
+
* in one run. Reproduce with:
|
|
10
|
+
*
|
|
11
|
+
* strings -n 6 "$(node -p "require.resolve('@openai/codex/package.json')" \
|
|
12
|
+
* | xargs dirname)/node_modules/@openai/codex-linux-x64/vendor/\
|
|
13
|
+
* x86_64-unknown-linux-musl/bin/codex" | grep -A56 'subagent-start.command.input'
|
|
14
|
+
*
|
|
15
|
+
* The schema is (verbatim, fields elided for length):
|
|
16
|
+
*
|
|
17
|
+
* "title": "subagent-start.command.input", "type": "object",
|
|
18
|
+
* "additionalProperties": false,
|
|
19
|
+
* "properties": { agent_id, agent_type, cwd, hook_event_name, model,
|
|
20
|
+
* permission_mode, session_id, transcript_path, turn_id },
|
|
21
|
+
* "required": [ agent_id, agent_type, cwd, hook_event_name, model,
|
|
22
|
+
* permission_mode, session_id, transcript_path, turn_id ]
|
|
23
|
+
*
|
|
24
|
+
* Two properties of that schema decide this constant:
|
|
25
|
+
*
|
|
26
|
+
* - `agent_type` is the subagent's TYPE — the roleguide name the eligibility table is
|
|
27
|
+
* keyed on (`git-expert`, `security-reviewer`). `agent_id` is the per-spawn instance
|
|
28
|
+
* identifier, which identifies WHICH spawn, not WHAT was spawned, so it is not the
|
|
29
|
+
* gate's subject. Both are `required`.
|
|
30
|
+
* - `additionalProperties: false` means the other six names the previous version
|
|
31
|
+
* accepted (`agent_name`, `agentName`, `subagent_type`, `subagentType`, `agent`,
|
|
32
|
+
* `name`) CANNOT appear in a genuine payload, and neither can a `subagent` or
|
|
33
|
+
* `agent_info` wrapper. Accepting them was not caution; it was six extra strings an
|
|
34
|
+
* attacker-shaped payload could set to a name that passes the eligibility table
|
|
35
|
+
* while `agent_type` said something else. Narrowing to the one real field removes
|
|
36
|
+
* that ambiguity without weakening anything: an absent field is still a refusal.
|
|
37
|
+
*
|
|
38
|
+
* DO NOT re-widen this on a hunch. If a Codex upgrade changes the payload, the schema
|
|
39
|
+
* above is re-derivable in one command, and VERIFIED_CODEX_VERSION plus
|
|
40
|
+
* .devcontainer/codex-version.pin exist precisely so that upgrade is a deliberate act.
|
|
41
|
+
*/
|
|
42
|
+
export declare const AGENT_NAME_FIELD = "agent_type";
|
|
1
43
|
export interface GateDecision {
|
|
2
44
|
/** 0 = allow, 2 = block (the exit code Codex reads as a refusal). */
|
|
3
45
|
exitCode: 0 | 2;
|
|
@@ -6,7 +48,16 @@ export interface GateDecision {
|
|
|
6
48
|
/** The agent name the gate resolved, for diagnostics. */
|
|
7
49
|
agent?: string;
|
|
8
50
|
}
|
|
9
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Pull the agent type out of a SubagentStart payload, or null if it is absent, blank
|
|
53
|
+
* or not a string. Null is a REFUSAL upstream — see `decideCodexAgentGate`.
|
|
54
|
+
*
|
|
55
|
+
* Reads exactly one top-level field and never descends into nested objects. The
|
|
56
|
+
* schema forbids any other property, and the nested search the previous version did
|
|
57
|
+
* was reachable only from a payload Codex cannot produce. `tool_input` in particular
|
|
58
|
+
* is never consulted: its contents are written by the model, so a name taken from it
|
|
59
|
+
* would be a name the gated party chose for itself.
|
|
60
|
+
*/
|
|
10
61
|
export declare function extractAgentName(payload: unknown): string | null;
|
|
11
62
|
/**
|
|
12
63
|
* Decide whether a subagent spawn may proceed. Pure — no I/O, no process exit — so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-agent-gate.d.ts","sourceRoot":"","sources":["../../src/commands/codex-agent-gate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"codex-agent-gate.d.ts","sourceRoot":"","sources":["../../src/commands/codex-agent-gate.ts"],"names":[],"mappings":"AA4BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAE7C,MAAM,WAAW,YAAY;IAC3B,qEAAqE;IACrE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IAChB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAMhE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC,GAAG,YAAY,CA+Bf;AAED,2EAA2E;AAC3E,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAYvE;AAgBD,2FAA2F;AAC3F,wBAAsB,iBAAiB,CAAC,IAAI,GAAE,SAAS,MAAM,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAQnF"}
|
|
@@ -9,17 +9,16 @@
|
|
|
9
9
|
* the call site: the generated `.codex/hooks.json` registers it as a SubagentStart
|
|
10
10
|
* hook, so Codex asks it before a subagent starts and a refusal blocks the spawn.
|
|
11
11
|
*
|
|
12
|
-
* FAIL CLOSED.
|
|
12
|
+
* FAIL CLOSED. One input remains uncertain and resolves to refusal:
|
|
13
13
|
*
|
|
14
|
-
* 1. WHICH
|
|
15
|
-
* machine-verified — unlike the PreToolUse payload, which was probed on
|
|
16
|
-
* codex-cli 0.145.0 (see codex-config.ts). Several plausible field names are
|
|
17
|
-
* accepted; if none is present, the spawn is REFUSED rather than allowed. A gate
|
|
18
|
-
* that cannot identify its subject must not wave it through.
|
|
19
|
-
* 2. WHICH GUARDS are proven comes from `--proven-guards`, written by the generator
|
|
14
|
+
* 1. WHICH GUARDS are proven comes from `--proven-guards`, written by the generator
|
|
20
15
|
* from the adapter's own list. Absent or empty → nothing is proven → every
|
|
21
16
|
* hook-gated agent is refused, which is the correct pre-G-7 state.
|
|
22
17
|
*
|
|
18
|
+
* The other one — WHICH FIELD carries the agent's identity — is now settled; see
|
|
19
|
+
* AGENT_NAME_FIELD below. An absent, empty or non-string value is still REFUSED. A
|
|
20
|
+
* gate that cannot identify its subject must not wave it through.
|
|
21
|
+
*
|
|
23
22
|
* The generated hooks.json is therefore the trust anchor for this decision. An agent
|
|
24
23
|
* that can edit that file can widen its own allowlist, which is why the G-7 paired
|
|
25
24
|
* proof must include a mid-session tamper check (see codex-config.ts) and why Codex's
|
|
@@ -27,42 +26,65 @@
|
|
|
27
26
|
*/
|
|
28
27
|
import { checkCodexAgentEligibility } from '../lib/runtime/codex-adapter.js';
|
|
29
28
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* The field that carries the subagent's identity in a SubagentStart payload.
|
|
30
|
+
*
|
|
31
|
+
* ─── HOW THIS WAS ESTABLISHED (security review NEW-6) ───────────────────────────
|
|
32
|
+
* codex-cli 0.145.0 EMBEDS the JSON Schema for every hook's stdin payload in its own
|
|
33
|
+
* binary, under the title `subagent-start.command.input`. That is the contract the
|
|
34
|
+
* shipped binary serializes against, so it is the primary source — stronger than a
|
|
35
|
+
* single observed payload, which shows only the fields that happened to be populated
|
|
36
|
+
* in one run. Reproduce with:
|
|
37
|
+
*
|
|
38
|
+
* strings -n 6 "$(node -p "require.resolve('@openai/codex/package.json')" \
|
|
39
|
+
* | xargs dirname)/node_modules/@openai/codex-linux-x64/vendor/\
|
|
40
|
+
* x86_64-unknown-linux-musl/bin/codex" | grep -A56 'subagent-start.command.input'
|
|
41
|
+
*
|
|
42
|
+
* The schema is (verbatim, fields elided for length):
|
|
43
|
+
*
|
|
44
|
+
* "title": "subagent-start.command.input", "type": "object",
|
|
45
|
+
* "additionalProperties": false,
|
|
46
|
+
* "properties": { agent_id, agent_type, cwd, hook_event_name, model,
|
|
47
|
+
* permission_mode, session_id, transcript_path, turn_id },
|
|
48
|
+
* "required": [ agent_id, agent_type, cwd, hook_event_name, model,
|
|
49
|
+
* permission_mode, session_id, transcript_path, turn_id ]
|
|
50
|
+
*
|
|
51
|
+
* Two properties of that schema decide this constant:
|
|
52
|
+
*
|
|
53
|
+
* - `agent_type` is the subagent's TYPE — the roleguide name the eligibility table is
|
|
54
|
+
* keyed on (`git-expert`, `security-reviewer`). `agent_id` is the per-spawn instance
|
|
55
|
+
* identifier, which identifies WHICH spawn, not WHAT was spawned, so it is not the
|
|
56
|
+
* gate's subject. Both are `required`.
|
|
57
|
+
* - `additionalProperties: false` means the other six names the previous version
|
|
58
|
+
* accepted (`agent_name`, `agentName`, `subagent_type`, `subagentType`, `agent`,
|
|
59
|
+
* `name`) CANNOT appear in a genuine payload, and neither can a `subagent` or
|
|
60
|
+
* `agent_info` wrapper. Accepting them was not caution; it was six extra strings an
|
|
61
|
+
* attacker-shaped payload could set to a name that passes the eligibility table
|
|
62
|
+
* while `agent_type` said something else. Narrowing to the one real field removes
|
|
63
|
+
* that ambiguity without weakening anything: an absent field is still a refusal.
|
|
64
|
+
*
|
|
65
|
+
* DO NOT re-widen this on a hunch. If a Codex upgrade changes the payload, the schema
|
|
66
|
+
* above is re-derivable in one command, and VERIFIED_CODEX_VERSION plus
|
|
67
|
+
* .devcontainer/codex-version.pin exist precisely so that upgrade is a deliberate act.
|
|
68
|
+
*/
|
|
69
|
+
export const AGENT_NAME_FIELD = 'agent_type';
|
|
70
|
+
/**
|
|
71
|
+
* Pull the agent type out of a SubagentStart payload, or null if it is absent, blank
|
|
72
|
+
* or not a string. Null is a REFUSAL upstream — see `decideCodexAgentGate`.
|
|
73
|
+
*
|
|
74
|
+
* Reads exactly one top-level field and never descends into nested objects. The
|
|
75
|
+
* schema forbids any other property, and the nested search the previous version did
|
|
76
|
+
* was reachable only from a payload Codex cannot produce. `tool_input` in particular
|
|
77
|
+
* is never consulted: its contents are written by the model, so a name taken from it
|
|
78
|
+
* would be a name the gated party chose for itself.
|
|
32
79
|
*/
|
|
33
|
-
const AGENT_NAME_FIELDS = [
|
|
34
|
-
'agent_name',
|
|
35
|
-
'agentName',
|
|
36
|
-
'subagent_type',
|
|
37
|
-
'subagentType',
|
|
38
|
-
'agent',
|
|
39
|
-
'agent_type',
|
|
40
|
-
'name',
|
|
41
|
-
];
|
|
42
|
-
/** Pull the agent name out of a SubagentStart payload, or null if none is present. */
|
|
43
80
|
export function extractAgentName(payload) {
|
|
44
|
-
if (!payload || typeof payload !== 'object')
|
|
81
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload))
|
|
45
82
|
return null;
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
// One level of nesting: some hook payloads wrap the subject.
|
|
53
|
-
// `tool_input` is DELIBERATELY NOT in this list (security review round 2): it is the
|
|
54
|
-
// one candidate whose contents the model writes, so a name read from it is a name the
|
|
55
|
-
// gated party chose. Dropping it can only widen the fail-closed path — an unresolved
|
|
56
|
-
// name is refused, never allowed.
|
|
57
|
-
for (const key of ['subagent', 'agent_info']) {
|
|
58
|
-
const nested = obj[key];
|
|
59
|
-
if (nested && typeof nested === 'object') {
|
|
60
|
-
const inner = extractAgentName(nested);
|
|
61
|
-
if (inner)
|
|
62
|
-
return inner;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return null;
|
|
83
|
+
const value = payload[AGENT_NAME_FIELD];
|
|
84
|
+
if (typeof value !== 'string')
|
|
85
|
+
return null;
|
|
86
|
+
const trimmed = value.trim();
|
|
87
|
+
return trimmed === '' ? null : trimmed;
|
|
66
88
|
}
|
|
67
89
|
/**
|
|
68
90
|
* Decide whether a subagent spawn may proceed. Pure — no I/O, no process exit — so
|
|
@@ -85,7 +107,10 @@ export function decideCodexAgentGate(opts) {
|
|
|
85
107
|
return {
|
|
86
108
|
exitCode: 2,
|
|
87
109
|
message: 'codex agent gate: no agent name found in the SubagentStart payload — refusing the ' +
|
|
88
|
-
`spawn.
|
|
110
|
+
`spawn. Required field \`${AGENT_NAME_FIELD}\` was absent, blank or not a string. ` +
|
|
111
|
+
'That field is `required` in codex-cli 0.145.0\'s own subagent-start.command.input ' +
|
|
112
|
+
'schema, so a payload without it did not come from a Codex version this gate has ' +
|
|
113
|
+
'been verified against.',
|
|
89
114
|
};
|
|
90
115
|
}
|
|
91
116
|
const result = checkCodexAgentEligibility(agent, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-agent-gate.js","sourceRoot":"","sources":["../../src/commands/codex-agent-gate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"codex-agent-gate.js","sourceRoot":"","sources":["../../src/commands/codex-agent-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAW7C;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IACnF,MAAM,KAAK,GAAI,OAAmC,CAAC,gBAAgB,CAAC,CAAC;IACrE,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;AACzC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAGpC;IACC,IAAI,OAAgB,CAAC;IACrB,IAAI,CAAC;QACH,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,QAAQ,EAAE,CAAC;YACX,OAAO,EACL,qFAAqF;gBACrF,wEAAwE;SAC3E,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxC,I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