@openai/codex-security 0.1.6 → 0.1.8
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/README.md +20 -3
- package/_bundled_plugin/.mcp.json +16 -0
- package/_bundled_plugin/mcp/server.mjs +1 -1
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/preflight/capability-profiles.toml +2 -2
- package/_bundled_plugin/references/config-preflight.md +6 -6
- package/_bundled_plugin/references/desktop-config-preflight.md +11 -0
- package/_bundled_plugin/references/final-report.md +10 -14
- package/_bundled_plugin/references/scan-artifacts.md +17 -17
- package/_bundled_plugin/references/shared-hard-rules.md +2 -2
- package/_bundled_plugin/scripts/deep_scan_workbench.py +422 -48
- package/_bundled_plugin/scripts/generate_rank_input.py +91 -0
- package/_bundled_plugin/scripts/workbench_cli.py +1 -50
- package/_bundled_plugin/scripts/workbench_constants.py +0 -2
- package/_bundled_plugin/scripts/workbench_db.py +7 -289
- package/_bundled_plugin/scripts/workbench_progress.py +11 -0
- package/_bundled_plugin/scripts/workbench_scan_history.py +0 -54
- package/_bundled_plugin/scripts/workbench_target.py +2 -6
- package/_bundled_plugin/scripts/workbench_validation.py +0 -211
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +10 -10
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +25 -43
- package/_bundled_plugin/skills/finding-discovery/SKILL.md +2 -4
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +11 -23
- package/_bundled_plugin/skills/security-scan/SKILL.md +89 -26
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +25 -0
- package/_bundled_plugin/skills/security-scan/references/repository-wide-scan.md +11 -38
- package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +5 -6
- package/_bundled_plugin/skills/triage-finding/SKILL.md +6 -14
- package/_bundled_plugin/skills/validation/SKILL.md +9 -9
- package/dist/api.d.ts +6 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +111 -31
- package/dist/api.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +77 -17
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +18 -10
- package/dist/config.js.map +1 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +4 -1
- package/dist/cost.js.map +1 -1
- package/dist/multiscan.d.ts +5 -1
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +206 -26
- package/dist/multiscan.js.map +1 -1
- package/dist/runtime.d.ts +13 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +122 -92
- package/dist/runtime.js.map +1 -1
- package/package.json +2 -2
- package/_bundled_plugin/mcp/mcp-app.html.br +0 -0
package/dist/runtime.js
CHANGED
|
@@ -230,6 +230,11 @@ class RepairableWindowsCredentialAclError extends Error {
|
|
|
230
230
|
super("Windows credential ACL requires repair", { cause });
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
+
class RepairableWindowsCredentialOwnerError extends Error {
|
|
234
|
+
constructor(cause) {
|
|
235
|
+
super(cause.message, { cause });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
233
238
|
/** Inspect a Windows DACL without translating locale-specific account names. */
|
|
234
239
|
export function inspectWindowsCredentialAcl(descriptor, currentUserSid, options = {}) {
|
|
235
240
|
if (!WINDOWS_SID.test(currentUserSid)) {
|
|
@@ -396,28 +401,37 @@ function windowsAceAllowsAncestorReplacement(rights, inheritanceFlags) {
|
|
|
396
401
|
}
|
|
397
402
|
return false;
|
|
398
403
|
}
|
|
399
|
-
export async function verifyStableWindowsCredentialDescendants(path, inspectDescriptors) {
|
|
404
|
+
export async function verifyStableWindowsCredentialDescendants(path, inspectDescriptors, options = {}) {
|
|
400
405
|
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
401
406
|
let descendants = 0;
|
|
402
407
|
const pending = [path];
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
408
|
+
try {
|
|
409
|
+
while (pending.length !== 0) {
|
|
410
|
+
const current = pending.pop();
|
|
411
|
+
const directory = await opendir(current);
|
|
412
|
+
for await (const entry of directory) {
|
|
413
|
+
const child = join(current, entry.name);
|
|
414
|
+
const metadata = await lstat(child);
|
|
415
|
+
if (metadata.isSymbolicLink()) {
|
|
416
|
+
throw new Error("Windows credential home contains a symbolic link or junction");
|
|
417
|
+
}
|
|
418
|
+
if (!metadata.isDirectory() && !metadata.isFile()) {
|
|
419
|
+
throw new Error("Windows credential home contains an unsafe entry");
|
|
420
|
+
}
|
|
421
|
+
descendants += 1;
|
|
422
|
+
if (metadata.isDirectory())
|
|
423
|
+
pending.push(child);
|
|
414
424
|
}
|
|
415
|
-
descendants += 1;
|
|
416
|
-
if (metadata.isDirectory())
|
|
417
|
-
pending.push(child);
|
|
418
425
|
}
|
|
419
426
|
}
|
|
420
|
-
|
|
427
|
+
catch (error) {
|
|
428
|
+
const failure = error;
|
|
429
|
+
if (failure.code === "ENOENT" && failure.path !== path) {
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
throw error;
|
|
433
|
+
}
|
|
434
|
+
if (descendants === 0 && options.inspectEmpty !== true)
|
|
421
435
|
return;
|
|
422
436
|
if ((await inspectDescriptors()) === descendants)
|
|
423
437
|
return;
|
|
@@ -473,6 +487,66 @@ export async function streamWindowsCredentialAclDescriptors(command, args, inspe
|
|
|
473
487
|
}
|
|
474
488
|
return descriptors;
|
|
475
489
|
}
|
|
490
|
+
export async function inspectWindowsCredentialAclSnapshot(path, currentUserSid, options) {
|
|
491
|
+
let ancestors = 0;
|
|
492
|
+
for (let ancestor = dirname(path);; ancestor = dirname(ancestor)) {
|
|
493
|
+
ancestors += 1;
|
|
494
|
+
if (ancestor === dirname(ancestor))
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
let home;
|
|
498
|
+
let descendantsArePrivate = true;
|
|
499
|
+
await verifyStableWindowsCredentialDescendants(path, async () => {
|
|
500
|
+
home = undefined;
|
|
501
|
+
descendantsArePrivate = true;
|
|
502
|
+
let inspected = 0;
|
|
503
|
+
const descriptors = await streamWindowsCredentialAclDescriptors(options.command, options.args, async (descriptor) => {
|
|
504
|
+
const index = inspected;
|
|
505
|
+
inspected += 1;
|
|
506
|
+
await options.resolveDescriptorAliases?.(descriptor);
|
|
507
|
+
if (index < ancestors) {
|
|
508
|
+
const ancestor = inspectWindowsCredentialAcl(descriptor, currentUserSid, {
|
|
509
|
+
resolvedAliases: options.resolvedAliases,
|
|
510
|
+
scope: "ancestor",
|
|
511
|
+
});
|
|
512
|
+
if (ancestor.untrustedPrincipals.length !== 0) {
|
|
513
|
+
throw new Error("Windows credential-home ancestor allows another identity to replace the directory");
|
|
514
|
+
}
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
if (index === ancestors) {
|
|
518
|
+
try {
|
|
519
|
+
home = inspectWindowsCredentialAcl(descriptor, currentUserSid, {
|
|
520
|
+
resolvedAliases: options.resolvedAliases,
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
catch (error) {
|
|
524
|
+
if (error instanceof UntrustedWindowsCredentialOwnerError) {
|
|
525
|
+
throw new RepairableWindowsCredentialOwnerError(error);
|
|
526
|
+
}
|
|
527
|
+
throw new RepairableWindowsCredentialAclError(error);
|
|
528
|
+
}
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
const descendant = inspectWindowsCredentialAcl(descriptor, currentUserSid, {
|
|
532
|
+
resolvedAliases: options.resolvedAliases,
|
|
533
|
+
scope: "file",
|
|
534
|
+
});
|
|
535
|
+
if (!descendant.grantsCurrentUserAccess ||
|
|
536
|
+
descendant.untrustedPrincipals.length !== 0) {
|
|
537
|
+
descendantsArePrivate = false;
|
|
538
|
+
}
|
|
539
|
+
}, { environment: options.environment });
|
|
540
|
+
if (descriptors <= ancestors) {
|
|
541
|
+
throw new Error("Windows credential-home ancestry could not be verified");
|
|
542
|
+
}
|
|
543
|
+
return descriptors - ancestors - 1;
|
|
544
|
+
}, { inspectEmpty: true });
|
|
545
|
+
if (home === undefined) {
|
|
546
|
+
throw new Error("Windows credential ACL could not be verified");
|
|
547
|
+
}
|
|
548
|
+
return { home, descendantsArePrivate };
|
|
549
|
+
}
|
|
476
550
|
async function secureWindowsCredentialHome(path) {
|
|
477
551
|
const systemRoot = process.env["SystemRoot"] ?? "C:\\Windows";
|
|
478
552
|
const systemDirectory = join(systemRoot, "System32");
|
|
@@ -497,7 +571,10 @@ async function secureWindowsCredentialHome(path) {
|
|
|
497
571
|
// arbitrary .NET constructors, static methods, and SID translation do not.
|
|
498
572
|
const script = [
|
|
499
573
|
"$ErrorActionPreference = 'Stop'",
|
|
574
|
+
"$path = $env:CODEX_SECURITY_CREDENTIAL_ACL_PATH",
|
|
575
|
+
"while ($true) { $parent = Microsoft.PowerShell.Management\\Split-Path -Path $path -Parent; if (-not $parent -or $parent -eq $path) { break }; Microsoft.PowerShell.Security\\Get-Acl -LiteralPath $parent | Microsoft.PowerShell.Utility\\Select-Object -ExpandProperty Sddl; $path = $parent }",
|
|
500
576
|
"Microsoft.PowerShell.Security\\Get-Acl -LiteralPath $env:CODEX_SECURITY_CREDENTIAL_ACL_PATH | Microsoft.PowerShell.Utility\\Select-Object -ExpandProperty Sddl",
|
|
577
|
+
"Microsoft.PowerShell.Management\\Get-ChildItem -LiteralPath $env:CODEX_SECURITY_CREDENTIAL_ACL_PATH -Recurse -Force | Microsoft.PowerShell.Security\\Get-Acl | Microsoft.PowerShell.Utility\\Select-Object -ExpandProperty Sddl",
|
|
501
578
|
].join("; ");
|
|
502
579
|
const resolvePrincipalScript = [
|
|
503
580
|
"$ErrorActionPreference = 'Stop'",
|
|
@@ -544,19 +621,17 @@ async function secureWindowsCredentialHome(path) {
|
|
|
544
621
|
remaining = rest;
|
|
545
622
|
}
|
|
546
623
|
};
|
|
624
|
+
let descendantsArePrivate = true;
|
|
547
625
|
const readAcl = async () => {
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
throw error;
|
|
558
|
-
throw new RepairableWindowsCredentialAclError(error);
|
|
559
|
-
}
|
|
626
|
+
const snapshot = await inspectWindowsCredentialAclSnapshot(path, sid, {
|
|
627
|
+
command: powershell,
|
|
628
|
+
args: ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", script],
|
|
629
|
+
environment: processOptions.env,
|
|
630
|
+
resolvedAliases,
|
|
631
|
+
resolveDescriptorAliases,
|
|
632
|
+
});
|
|
633
|
+
descendantsArePrivate = snapshot.descendantsArePrivate;
|
|
634
|
+
return snapshot.home;
|
|
560
635
|
};
|
|
561
636
|
const icacls = join(systemDirectory, "icacls.exe");
|
|
562
637
|
const installTrustedAcl = async (target = path) => {
|
|
@@ -569,69 +644,13 @@ async function secureWindowsCredentialHome(path) {
|
|
|
569
644
|
`*${WINDOWS_ADMINISTRATORS_SID}:(OI)(CI)F`,
|
|
570
645
|
], processOptions);
|
|
571
646
|
};
|
|
572
|
-
const ancestorScript = [
|
|
573
|
-
"$ErrorActionPreference = 'Stop'",
|
|
574
|
-
"$path = $env:CODEX_SECURITY_CREDENTIAL_ACL_PATH",
|
|
575
|
-
"while ($true) { $parent = Microsoft.PowerShell.Management\\Split-Path -Path $path -Parent; if (-not $parent -or $parent -eq $path) { break }; Microsoft.PowerShell.Security\\Get-Acl -LiteralPath $parent | Microsoft.PowerShell.Utility\\Select-Object -ExpandProperty Sddl; $path = $parent }",
|
|
576
|
-
].join("; ");
|
|
577
|
-
const ancestorPaths = [];
|
|
578
|
-
for (let ancestor = dirname(path);; ancestor = dirname(ancestor)) {
|
|
579
|
-
ancestorPaths.push(ancestor);
|
|
580
|
-
if (ancestor === dirname(ancestor))
|
|
581
|
-
break;
|
|
582
|
-
}
|
|
583
|
-
const ancestry = await execFile(powershell, ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", ancestorScript], processOptions);
|
|
584
|
-
const ancestorDescriptors = ancestry.stdout
|
|
585
|
-
.split(/\r?\n/u)
|
|
586
|
-
.filter((descriptor) => descriptor !== "");
|
|
587
|
-
if (ancestorDescriptors.length !== ancestorPaths.length) {
|
|
588
|
-
throw new Error("Windows credential-home ancestry could not be verified");
|
|
589
|
-
}
|
|
590
|
-
for (const descriptor of ancestorDescriptors) {
|
|
591
|
-
await resolveDescriptorAliases(descriptor);
|
|
592
|
-
const ancestor = inspectWindowsCredentialAcl(descriptor, sid, {
|
|
593
|
-
resolvedAliases,
|
|
594
|
-
scope: "ancestor",
|
|
595
|
-
});
|
|
596
|
-
if (ancestor.untrustedPrincipals.length === 0)
|
|
597
|
-
continue;
|
|
598
|
-
throw new Error("Windows credential-home ancestor allows another identity to replace the directory");
|
|
599
|
-
}
|
|
600
|
-
const descendantsArePrivate = async () => {
|
|
601
|
-
const descendantScript = [
|
|
602
|
-
"$ErrorActionPreference = 'Stop'",
|
|
603
|
-
"Microsoft.PowerShell.Management\\Get-ChildItem -LiteralPath $env:CODEX_SECURITY_CREDENTIAL_ACL_PATH -Recurse -Force | Microsoft.PowerShell.Security\\Get-Acl | Microsoft.PowerShell.Utility\\Select-Object -ExpandProperty Sddl",
|
|
604
|
-
].join("; ");
|
|
605
|
-
let privateDescendants = true;
|
|
606
|
-
await verifyStableWindowsCredentialDescendants(path, async () => {
|
|
607
|
-
privateDescendants = true;
|
|
608
|
-
return streamWindowsCredentialAclDescriptors(powershell, [
|
|
609
|
-
"-NoLogo",
|
|
610
|
-
"-NoProfile",
|
|
611
|
-
"-NonInteractive",
|
|
612
|
-
"-Command",
|
|
613
|
-
descendantScript,
|
|
614
|
-
], async (descriptor) => {
|
|
615
|
-
await resolveDescriptorAliases(descriptor);
|
|
616
|
-
const descendant = inspectWindowsCredentialAcl(descriptor, sid, {
|
|
617
|
-
resolvedAliases,
|
|
618
|
-
scope: "file",
|
|
619
|
-
});
|
|
620
|
-
if (!descendant.grantsCurrentUserAccess ||
|
|
621
|
-
descendant.untrustedPrincipals.length !== 0) {
|
|
622
|
-
privateDescendants = false;
|
|
623
|
-
}
|
|
624
|
-
}, { environment: processOptions.env });
|
|
625
|
-
});
|
|
626
|
-
return privateDescendants;
|
|
627
|
-
};
|
|
628
647
|
let existing;
|
|
629
648
|
for (let attempt = 0; existing === undefined && attempt < 3; attempt += 1) {
|
|
630
649
|
try {
|
|
631
650
|
existing = await readAcl();
|
|
632
651
|
}
|
|
633
652
|
catch (error) {
|
|
634
|
-
if (error instanceof
|
|
653
|
+
if (error instanceof RepairableWindowsCredentialOwnerError) {
|
|
635
654
|
await execFile(icacls, [path, "/setowner", `*${sid}`], processOptions);
|
|
636
655
|
}
|
|
637
656
|
else if (error instanceof RepairableWindowsCredentialAclError) {
|
|
@@ -683,9 +702,10 @@ async function secureWindowsCredentialHome(path) {
|
|
|
683
702
|
if (verified.untrustedPrincipals.length !== 0) {
|
|
684
703
|
throw new Error("Windows credential ACL grants access to another identity");
|
|
685
704
|
}
|
|
686
|
-
if (!
|
|
705
|
+
if (!descendantsArePrivate) {
|
|
687
706
|
await execFile(icacls, [join(path, "*"), "/reset", "/t", "/q"], processOptions);
|
|
688
|
-
|
|
707
|
+
await readAcl();
|
|
708
|
+
if (!descendantsArePrivate) {
|
|
689
709
|
throw new Error("Windows credential descendants remain accessible");
|
|
690
710
|
}
|
|
691
711
|
}
|
|
@@ -1568,12 +1588,18 @@ async function codexSecurityPluginRegistration(codexHome) {
|
|
|
1568
1588
|
}
|
|
1569
1589
|
export function resolveCodexCommand() {
|
|
1570
1590
|
const { packageName, targetTriple } = codexPlatformPackage();
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1591
|
+
let packageJson;
|
|
1592
|
+
try {
|
|
1593
|
+
const require = createRequire(import.meta.url);
|
|
1594
|
+
const codexPackageJson = require.resolve("@openai/codex/package.json");
|
|
1595
|
+
packageJson = createRequire(codexPackageJson).resolve(`${packageName}/package.json`);
|
|
1596
|
+
}
|
|
1597
|
+
catch (error) {
|
|
1598
|
+
throw new PluginBootstrapError(`The bundled Codex executable could not be resolved from ${packageName}. Reinstall @openai/codex with optional dependencies enabled, or set CODEX_CLI_PATH to an installed Codex executable.`, { cause: error });
|
|
1599
|
+
}
|
|
1574
1600
|
const command = join(dirname(packageJson), "vendor", targetTriple, "bin", process.platform === "win32" ? "codex.exe" : "codex");
|
|
1575
1601
|
if (!existsSync(command)) {
|
|
1576
|
-
throw new PluginBootstrapError(`The ${packageName} package does not contain the Codex executable for ${targetTriple}.`);
|
|
1602
|
+
throw new PluginBootstrapError(`The ${packageName} package does not contain the Codex executable for ${targetTriple}. Reinstall @openai/codex with optional dependencies enabled, or set CODEX_CLI_PATH to an installed Codex executable.`);
|
|
1577
1603
|
}
|
|
1578
1604
|
return { command, prefixArgs: [] };
|
|
1579
1605
|
}
|
|
@@ -1772,7 +1798,11 @@ export async function resolvePluginPython(options = {}) {
|
|
|
1772
1798
|
"Set pythonPath, --python, or PYTHON, install the Codex managed runtime, or add python3/python to PATH.");
|
|
1773
1799
|
}
|
|
1774
1800
|
export function pluginExecutionEnvironment(python, environment = process.env) {
|
|
1775
|
-
return {
|
|
1801
|
+
return {
|
|
1802
|
+
...environment,
|
|
1803
|
+
PYTHON: python,
|
|
1804
|
+
CODEX_CLI_PATH: environment["CODEX_CLI_PATH"]?.trim() || resolveCodexCommand().command,
|
|
1805
|
+
};
|
|
1776
1806
|
}
|
|
1777
1807
|
export async function cleanupSdkDirectory(path) {
|
|
1778
1808
|
await rm(path, { recursive: true, force: true });
|