OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
fix(config): pass native settings through scan workers (#1717)
Michael D'Angelo7d3325abce41
diff --git a/AGENTS.md b/AGENTS.mdindex e00c02abe..02401cd1c 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -11,9 +11,12 @@ Codex Security is a thin wrapper around Codex and its security plugin.- Keep credential access, storage, and configuration protections, unsafe-pathchecks, and settings the user explicitly requests.- Prefer straightforward code and tests for real behavior.-- Accept reasoning-effort values as strings and pass them through unchanged.- Do not add wrapper-owned enums or allowlists; let the selected model/provider- determine which values it supports.+- Pass Codex-owned settings through existing SDK configuration interfaces.+ Accept reasoning-effort values as strings and pass them through unchanged.+ Do not maintain wrapper-owned model or reasoning-effort enums or allowlists;+ let Codex and the selected model/provider validate supplied values. Use+ upstream capability discovery for suggested choices. Preserve credential+ protections, worker permissions, and per-scan configuration isolation.- Mention another `openai/` repository in comments or pull request descriptionsonly after checking that it is public. If you cannot confirm its visibility,leave it out.diff --git a/action.yml b/action.ymlindex 94a605e93..664b1ccd7 100644--- a/action.yml+++ b/action.yml@@ -25,7 +25,7 @@ inputs:cyber-access-program:description: 'Optional Cyber access program: standard, daybreak_blue, or daybreak_red. Unset preserves CLI defaults. Daybreak selections require approved organization and enabled API project access; model access is checked separately.'effort:- description: 'Reasoning effort: minimal, low, medium, high, xhigh, or max (subject to model support).'+ description: 'Reasoning effort passed to Codex; supported values depend on the model and provider.'default: xhighmax-cost:description: Positive estimated USD stop threshold per invocation. In-flight requests can exceed it; unset means no cost limit.diff --git a/github-action/README.md b/github-action/README.mdindex 8586adccc..05ec83b42 100644--- a/github-action/README.md+++ b/github-action/README.md@@ -471,7 +471,7 @@ Inputs are strings. Quote booleans and use newline-separated literal paths for l| `provider` | `openai` | Inference provider, matching scan --provider: openai, openrouter, fireworks, or amazon-bedrock. Supply the selected provider's credentials to the step. || `model` | Unset | Model to scan with, passed to scan --model. Defaults to gpt-5.6-sol for OpenAI; other providers require an explicit model ID. Cost limits require CLI pricing support for the model. || `cyber-access-program` | Unset | Optional Cyber access program: standard, daybreak_blue, or daybreak_red. Unset preserves CLI defaults. Daybreak selections require approved organization and enabled API project access; model access is checked separately. |-| `effort` | `xhigh` | Reasoning effort: minimal, low, medium, high, xhigh, or max (subject to model support). |+| `effort` | `xhigh` | Reasoning effort passed to Codex; supported values depend on the model and provider. || `max-cost` | Unset | Positive estimated USD stop threshold per invocation. In-flight requests can exceed it; unset means no cost limit. || `max-time-hours` | Unset | Positive Deep discovery duration in hours, up to 96. Unset uses the CLI default. Finalization and job timeout are separate. || `fail-on-severity` | `none` | none, low, medium, high, or critical. Fails on reported findings at or above the selected severity. Scanner and required reporting errors also fail. |diff --git a/github-action/dist/index.cjs b/github-action/dist/index.cjsindex ad63fee6c..cf3b9b598 100644--- a/github-action/dist/index.cjs+++ b/github-action/dist/index.cjs@@ -55600,7 +55600,7 @@ function parseInputs(read, workspace) {cyberAccessProgram,provider,model,- effort: choice("effort", ["minimal", "low", "medium", "high", "xhigh", "max"], "xhigh"),+ effort: str("effort", "xhigh"),maxCost: num("max-cost", false, Number.MIN_VALUE),maxTimeHours,failOnSeverity: choice("fail-on-severity", ["none", "low", "medium", "high", "critical"], "none"),@@ -55625,8 +55625,7 @@ function scanArguments(inputs, target, resultsDirectory) {"--mode",inputs.mode,...inputs.model ? [`--model=${inputs.model}`] : [],- "--effort",- inputs.effort,+ `--effort=${inputs.effort}`,"--headless","--output-dir",resultsDirectory,diff --git a/github-action/src/inputs.ts b/github-action/src/inputs.tsindex 1fa6b9267..8ee16014b 100644--- a/github-action/src/inputs.ts+++ b/github-action/src/inputs.ts@@ -53,7 +53,7 @@ export function parseInputs(read: (name: string) => string, workspace: string) {: undefined;return {repository: str('repository', workspace), scope, paths, diffBase, mode, cyberAccessProgram,- provider, model, effort: choice('effort', ['minimal','low','medium','high','xhigh','max'], 'xhigh'),+ provider, model, effort: str('effort', 'xhigh'),maxCost: num('max-cost', false, Number.MIN_VALUE), maxTimeHours, failOnSeverity: choice('fail-on-severity', ['none','low','medium','high','critical'], 'none'),verbose: bool('verbose', true), dryRun,summary: bool('summary', true), annotations: bool('annotations', true),@@ -67,7 +67,7 @@ export function scanArguments(inputs: Inputs, target: {repository: string; diffB// with our empty private credential home. Bedrock selects native AWS auth.const auth = inputs.dryRun || inputs.provider === 'amazon-bedrock' ? 'auto' : 'api-key';const args = ['scan', target.repository, '--auth', auth, '--provider', inputs.provider, '--mode', inputs.mode,- ...(inputs.model ? [`--model=${inputs.model}`] : []), '--effort', inputs.effort, '--headless',+ ...(inputs.model ? [`--model=${inputs.model}`] : []), `--effort=${inputs.effort}`, '--headless','--output-dir', resultsDirectory, '--format', 'json'];// Preserve the pinned CLI's sandbox and automatic approval-review defaults.// Forcing approval_policy="never" prevents recovery from hosted Linux sandbox errors.diff --git a/github-action/tests/inputs.test.ts b/github-action/tests/inputs.test.tsindex 211ecdead..7d4ef0414 100644--- a/github-action/tests/inputs.test.ts+++ b/github-action/tests/inputs.test.ts@@ -35,6 +35,14 @@ test('provider and model inputs map directly to scan CLI arguments in both modes}assert.equal(parse({provider:'openai'}).model, 'gpt-5.6-sol');});+test('reasoning efforts pass through to both scan modes', () => {+ for (const mode of ['standard', 'deep']) for (const effort of ['ultra', 'synthetic-future-effort', '--help']) {+ const args = scanArguments(parse({mode, effort}), {repository:'/checkout'}, '/results');+ assert.ok(args.includes(`--effort=${effort}`));+ assert.ok(!args.includes(effort));+ }+ assert.equal(parse({effort:' '}).effort, 'xhigh');+});test('Cyber access selections reach both standard and Deep scan CLI invocations', () => {for (const mode of ['standard', 'deep']) for (const program of ['standard', 'daybreak_blue', 'daybreak_red']) {const args = scanArguments(parse({mode, 'cyber-access-program':program}), {repository:'/checkout'}, '/results');@@ -117,7 +125,7 @@ test('CLI arguments preserve literal values and enforce CI policy', () => {assert.ok(!args.some(arg => arg.startsWith('approval_policy=')));assert.ok(!args.some(arg => arg.startsWith('approvals_reviewer=')));assert.ok(args.includes('analytics.enabled=false'));- assert.equal(args[args.indexOf('--effort') + 1], 'medium');+ assert.ok(args.includes('--effort=medium'));assert.equal(args[args.indexOf('--max-cost') + 1], '5');assert.equal(args[args.indexOf('--fail-on-severity') + 1], 'high');assert.ok(!args.some(value => value.includes('API_KEY')));diff --git a/github-action/tests/main.test.ts b/github-action/tests/main.test.tsindex c30f3d074..acf53cd0a 100644--- a/github-action/tests/main.test.ts+++ b/github-action/tests/main.test.ts@@ -171,7 +171,7 @@ test('PR severity failure retains SARIF outputs despite unrelated scope notes',assert.equal(result.outputs['scanned-sha'], app.sha); assert.equal(result.outputs['high-count'], '1');assert.equal(result.outputs['estimated-cost'], '0.125'); assert.ok(result.outputs['sarif-path']);assert.ok(result.args.includes('--model=gpt-5.6-luna'));- assert.equal(result.args[result.args.indexOf('--effort') + 1], 'medium');+ assert.ok(result.args.includes('--effort=medium'));assert.ok(!result.args.includes('--max-cost'));assert.match(result.logs, /::error::Scan completed\. Findings meet the configured failure threshold\./);assert.match(result.summary, /^## Codex Security\n\n\*\*Scan completed\. Findings meet the configured failure threshold\.\*\*/);@@ -205,7 +205,7 @@ test('unrelated ambient input variables do not reject a valid scan', async (t) =app.setInput('effort', 'medium');const result = await app.run();assert.equal(result.exitCode, 0); assert.equal(result.outputs['scan-status'], 'completed');- assert.equal(result.args[result.args.indexOf('--effort') + 1], 'medium');+ assert.ok(result.args.includes('--effort=medium'));});test('Deep scans forward their budget and publish completed reports with cleanup', async (t) => {diff --git a/plugins/codex-security/mcp-app/src/deep-scan/executor.ts b/plugins/codex-security/mcp-app/src/deep-scan/executor.tsindex 9e2d3a8d8..87a46dedc 100644--- a/plugins/codex-security/mcp-app/src/deep-scan/executor.ts+++ b/plugins/codex-security/mcp-app/src/deep-scan/executor.ts@@ -532,21 +532,12 @@ async function workerRuntimeSettings(? profiles[config.profile]: undefined;const selected = { ...config, ...(isRecord(profile) ? profile : {}) };- for (const key of ["analytics", "responses_api_metadata"]) {+ for (const key of ["analytics", "responses_api_metadata", "features"]) {if (isRecord(config[key]) && isRecord(profile) && isRecord(profile[key])) {selected[key] = { ...config[key], ...profile[key] };}}- const inherited = Object.fromEntries(- [- "model_reasoning_summary",- "service_tier",- "analytics",- "responses_api_metadata",- "skills",- ].map((key) => [key, selected[key]]),- );- const settings: CodexSdkWorkerRuntimeSettings = { config: inherited };+ const settings: CodexSdkWorkerRuntimeSettings = { config: selected };const workerConfigPath = environmentVariable(environment,"CODEX_SECURITY_DEEP_SCAN_CONFIG_PATH",@@ -606,19 +597,32 @@ async function workerRuntimeSettings(settings.cyberAccessProgram =security.cyber_access_program as CyberAccessProgram;}- const features = isRecord(config.features) ? config.features : {};settings.config = {- ...inherited,+ ...selected,...workerConfig,features: {- ...Object.fromEntries(- ["api_key_cyber_access_programs", "api_key_model_discovery"].map(- (key) => [key, features[key]],- ),- ),+ ...(isRecord(selected.features) ? selected.features : {}),...(isRecord(workerConfig.features) ? workerConfig.features : {}),},};+ // Profiles are resolved above; providers stay in their private native file.+ // Workers register their own tools and verified read-only permission profile.+ for (const key of [+ "profile",+ "profiles",+ "projects",+ "model_providers",+ "codex_security",+ "mcp_servers",+ "plugins",+ "marketplaces",+ "permissions",+ "sandbox_mode",+ "sandbox_workspace_write",+ "approvals_reviewer",+ ]) {+ delete settings.config[key];+ }return settings;}diff --git a/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.ts b/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.tsindex 2db8f678b..131b5d74a 100644--- a/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.ts+++ b/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.ts@@ -1519,7 +1519,6 @@ env_key = "SYNTHETIC_GATEWAY_KEY"`,},],};- // Cover missing settings, native config inheritance, and snapshot overrides.const mergeProfileTelemetry = index === 0 && configuration !== "";const telemetry =index === 0 && configuration === ""@@ -1616,7 +1615,15 @@ env_key = "SYNTHETIC_GATEWAY_KEY"`,env: { CLIENT_SECRET: `synthetic-client-secret-${index}` },},};+ const nativePaths = {+ experimental_compact_prompt_file: path.join(+ fixture.root,+ `compact-${index}.md`,+ ),+ sqlite_home: path.join(codexHome, `sqlite-${index}`),+ };return {+ nativePaths,knowledgePath: path.join(fixture.root, `knowledge-${index}`),knowledgeDocuments: {"1-architecture.md.txt": `Synthetic architecture for scan ${index}.`,@@ -1682,6 +1689,12 @@ env_key = "SYNTHETIC_GATEWAY_KEY"`,configuration: {...parsedConfiguration,...inheritedTelemetry,+ ...Object.fromEntries(+ Object.entries(nativePaths).map(([key, value]) => [+ key,+ index === 0 ? value : "parent",+ ]),+ ),...(skills === undefined? {}: {@@ -1757,6 +1770,13 @@ env_key = "SYNTHETIC_GATEWAY_KEY"`,worker_runtime: {...entry.authentication,...entry.workerTelemetry,+ ...entry.nativePaths,+ approval_policy: "on-request",+ default_permissions: "parent",+ permissions: { parent: { filesystem: { ":root": "write" } } },+ sandbox_mode: "danger-full-access",+ sandbox_workspace_write: { network_access: true },+ mcp_servers: { parent: { command: "synthetic-parent-tool" } },...(entry.skills === undefined? {}: { skills: entry.skills }),@@ -1870,7 +1890,7 @@ env_key = "SYNTHETIC_GATEWAY_KEY"`,launches.length = 0;await Promise.all(executors.map((executor, index) => {- // Each concurrent launch snapshots its own scan environment.+ // Snapshot each scan environment independently.process.env.CODEX_MCP_NODE_PATH = nodePaths[index];process.env.CODEX_SECURITY_STATE_DIR = path.join(fixture.root,@@ -2238,6 +2258,11 @@ env_key = "SYNTHETIC_GATEWAY_KEY"`,},enable_fanout: false,});+ assertConfigOverrides(invocation.argv, {+ ...selectedProvider.nativePaths,+ sandbox_mode: undefined,+ "mcp_servers.parent": undefined,+ });assertReadOnlyWorkerPolicy(invocation.argv);assertWorkerSubagentPolicy(invocation.argv, 0);}@@ -2271,6 +2296,7 @@ env_key = "SYNTHETIC_GATEWAY_KEY"`,assertConfigOverrides(preflight.argv, {openai_base_url: selectedProvider.endpoint,model_instructions_file: selectedProvider.instructionsFile,+ ...selectedProvider.nativePaths,model_verbosity: selectedProvider.verbosity,model_context_window: selectedProvider.modelContextWindow,model_auto_compact_token_limit:@@ -2350,11 +2376,11 @@ env_key = "SYNTHETIC_GATEWAY_KEY"`,Promise.all([writeFile(entry.path,- 'model_reasoning_summary = "detailed"\nservice_tier = "changed"\nmodel_provider = "changed"\n[analytics]\nenabled = false\n[responses_api_metadata]\ncustom_tag = "changed"\n',+ 'sqlite_home = "changed"\nmodel_reasoning_summary = "detailed"\nservice_tier = "changed"\nmodel_provider = "changed"\n[analytics]\nenabled = false\n[responses_api_metadata]\ncustom_tag = "changed"\n',),writeFile(entry.deepPath,- '[worker_runtime.features]\nshell_tool = true\nunified_exec = true\nview_image = true\n[worker_runtime]\nopenai_base_url = "https://changed-snapshot.example.test/v1"\nweb_search = "live"\nmodel_provider = "changed"\nnative_profile = "changed"\nmodel_instructions_file = "changed-instructions.md"\nmodel_verbosity = "changed"\nmodel_context_window = 999000\nmodel_auto_compact_token_limit = 888000\n[worker_runtime.shell_environment_policy]\ninherit = "all"\n[worker_runtime.shell_environment_policy.set]\nSYNTHETIC_SHELL_MARKER = "changed"\n[worker_runtime.windows]\nsandbox = "changed"\n[worker_runtime.environment]\nSYNTHETIC_GATEWAY_KEY = "changed"\nSYNTHETIC_HEADER_VALUE = "changed"\n[worker_runtime.analytics]\nenabled = false\n[worker_runtime.responses_api_metadata]\ncustom_tag = "changed"\n',+ '[worker_runtime.features]\nshell_tool = true\nunified_exec = true\nview_image = true\n[worker_runtime]\nsqlite_home = "changed"\nopenai_base_url = "https://changed-snapshot.example.test/v1"\nweb_search = "live"\nmodel_provider = "changed"\nnative_profile = "changed"\nmodel_instructions_file = "changed-instructions.md"\nmodel_verbosity = "changed"\nmodel_context_window = 999000\nmodel_auto_compact_token_limit = 888000\n[worker_runtime.shell_environment_policy]\ninherit = "all"\n[worker_runtime.shell_environment_policy.set]\nSYNTHETIC_SHELL_MARKER = "changed"\n[worker_runtime.windows]\nsandbox = "changed"\n[worker_runtime.environment]\nSYNTHETIC_GATEWAY_KEY = "changed"\nSYNTHETIC_HEADER_VALUE = "changed"\n[worker_runtime.analytics]\nenabled = false\n[worker_runtime.responses_api_metadata]\ncustom_tag = "changed"\n',),]),),diff --git a/sdk/typescript/src/api.ts b/sdk/typescript/src/api.tsindex 584881145..98102c51b 100644--- a/sdk/typescript/src/api.ts+++ b/sdk/typescript/src/api.ts@@ -1796,6 +1796,11 @@ export class CodexSecurity {scanDir,workerProviderEnvironment,);+ const sqliteHome = workerRuntimeConfig["sqlite_home"];+ const sqliteEnvironment: Record<string, string> =+ mode === "deep" && typeof sqliteHome === "string"+ ? { CODEX_SQLITE_HOME: sqliteHome }+ : {};const workerSnapshot: JsonObject = {...workerRuntimeConfig,responses_api_metadata: {@@ -2061,6 +2066,7 @@ export class CodexSecurity {pluginRoot: runtime.plugin.pluginRoot,environment: {...environmentWithGit(git.environment, git),+ ...sqliteEnvironment,CODEX_SECURITY_STATE_DIR: stateDirectory,},signal,@@ -2336,6 +2342,7 @@ export class CodexSecurity {): null;const runtimePaths = {+ ...sqliteEnvironment,PYTHON: python,CODEX_SECURITY_STARTED_AT:options.resumeScanId !== undefined &&@@ -5591,33 +5598,20 @@ function selectedWorkerRuntimeConfig(return value === undefined ? [] : [[name, value]];}),);- const instructionsFile = resolved["model_instructions_file"];- if (typeof instructionsFile === "string") {- resolved["model_instructions_file"] = resolve(- workingDirectory,- expandHome(instructionsFile, environment),- );+ // Workers use separate directories; preserve the parent scan's native paths.+ for (const key of [+ "model_instructions_file",+ "experimental_compact_prompt_file",+ "model_catalog_json",+ "sqlite_home",+ ]) {+ const file = resolved[key];+ if (typeof file === "string") {+ resolved[key] = resolve(workingDirectory, expandHome(file, environment));+ }}return {- ...Object.fromEntries(- [- ...CODEX_AUTH_CONFIG_KEYS,- "analytics",- "responses_api_metadata",- "openai_base_url",- "features",- "model_auto_compact_token_limit",- "model_context_window",- "model_instructions_file",- "model_verbosity",- "shell_environment_policy",- "skills",- "web_search",- "windows",- ]- .filter((key) => resolved[key] !== undefined)- .map((key) => [key, resolved[key]!]),- ),+ ...structuredCodexConfig(resolved),...(provider === undefined ? {} : { model_provider: provider }),...(Object.keys(providerEnvironment).length === 0? {}diff --git a/sdk/typescript/tests-ts/api.test.ts b/sdk/typescript/tests-ts/api.test.tsindex 78ac1eb19..bc0bd29c5 100644--- a/sdk/typescript/tests-ts/api.test.ts+++ b/sdk/typescript/tests-ts/api.test.ts@@ -6584,7 +6584,7 @@ describe("CodexSecurity orchestration", () => {await client.close();});- test("isolates selected skill settings in current Deep worker snapshots", async () => {+ test("isolates selected native settings in current Deep worker snapshots", async () => {const root = await temporaryDirectory();const started = Promise.withResolvers<void>();let starts = 0;@@ -6594,6 +6594,7 @@ describe("CodexSecurity orchestration", () => {const repository = join(root, `repository-${index}`);const codexHome = join(root, `home-${index}`);const scanDir = join(root, `scan-${index}`);+ const sqliteHome = join(scanDir, "sqlite");const configPath = join(root, `worker-config-${index}.toml`);const installedRoot = join(codexHome, "plugins", "cache", "selected");const customSkill = {@@ -6605,9 +6606,20 @@ describe("CodexSecurity orchestration", () => {mkdir(directory, { mode: 0o700 }),),);+ const nativeFile = join(root, `native-${index}.json`);+ await writeFile(nativeFile, JSON.stringify({ models: [] }));const config: JsonObject = {profile: "selected",- profiles: { selected: { skills: { config: [customSkill] } } },+ synthetic_native: { root: index, selected: "root" },+ profiles: {+ selected: {+ skills: { config: [customSkill] },+ synthetic_native: { selected: `scan-${index}` },+ experimental_compact_prompt_file: `../native-${index}.json`,+ model_catalog_json: `../native-${index}.json`,+ sqlite_home: index === 0 ? "sqlite" : sqliteHome,+ },+ },};const client = new TestClient({ codexOverrides: config },@@ -6615,8 +6627,15 @@ describe("CodexSecurity orchestration", () => {...scanRuntimeDependencies(codexHome, scanDir),prepareRuntime: runtimePreparer(codexHome, () => ({configPath,+ environment: { CODEX_SQLITE_HOME: join(root, "overridden") },plugin: { ...preparedRuntime(codexHome).plugin, installedRoot },})),+ runWorkbench: async (options, args, input) => {+ expect(options.environment?.["CODEX_SQLITE_HOME"]).toBe(+ sqliteHome,+ );+ return mockWorkbench(args, input);+ },createCodex: (options) => ({startThread: () => ({id: null,@@ -6629,6 +6648,7 @@ describe("CodexSecurity orchestration", () => {expect(options.env?.["CODEX_SECURITY_CONFIG_PATH"]).toBe(configPath,);+ expect(options.env?.["CODEX_SQLITE_HOME"]).toBe(sqliteHome);paths.add(configPath);const saved = resolveCodexProfile(parseToml(await readFile(configPath, "utf8")) as JsonObject,@@ -6637,6 +6657,9 @@ describe("CodexSecurity orchestration", () => {options.config as JsonObject,);expect(saved["skills"]).toEqual(effective["skills"]);+ expect(effective["sqlite_home"]).toBe(+ index === 0 ? "sqlite" : sqliteHome,+ );const snapshot = parseToml(await readFile(options.env!["CODEX_SECURITY_DEEP_SCAN_CONFIG_PATH"]!,@@ -6646,6 +6669,26 @@ describe("CodexSecurity orchestration", () => {expect((snapshot["worker_runtime"] as JsonObject)["skills"],).toEqual(effective["skills"]);+ expect(+ (snapshot["worker_runtime"] as JsonObject)[+ "synthetic_native"+ ],+ ).toEqual({ root: index, selected: `scan-${index}` });+ for (const key of [+ "experimental_compact_prompt_file",+ "model_catalog_json",+ ]) {+ const file = (snapshot["worker_runtime"] as JsonObject)[+ key+ ];+ expect(file).toBe(nativeFile);+ expect(await readFile(file as string, "utf8")).toBe(+ JSON.stringify({ models: [] }),+ );+ }+ expect(+ (snapshot["worker_runtime"] as JsonObject)["sqlite_home"],+ ).toBe(sqliteHome);const selections = (saved["skills"] as JsonObject)["config"] as JsonObject[];