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: recognize OWNER RIGHTS on trusted Windows credential ancestors (#2379)
Michael D'Angelo9cc3f8a3a1e9
diff --git a/sdk/typescript/src/runtime.ts b/sdk/typescript/src/runtime.tsindex 661c1bb37..1c1a65a4d 100644--- a/sdk/typescript/src/runtime.ts+++ b/sdk/typescript/src/runtime.ts@@ -615,7 +615,10 @@ export function inspectWindowsCredentialAcl(if (!trustedPrincipal(principal)) {if (options.scope !== "ancestor" ||- windowsAceAllowsAncestorReplacement(rights!, inheritanceFlags)+ // OWNER RIGHTS applies to the owner already verified above. Every+ // descendant is inspected with its own security descriptor.+ (principal !== WINDOWS_OWNER_RIGHTS_SID &&+ windowsAceAllowsAncestorReplacement(rights!, inheritanceFlags))) {untrustedPrincipals.add(principal);}diff --git a/sdk/typescript/tests-ts/runtime.test.ts b/sdk/typescript/tests-ts/runtime.test.tsindex 7350d7419..35b359279 100644--- a/sdk/typescript/tests-ts/runtime.test.ts+++ b/sdk/typescript/tests-ts/runtime.test.ts@@ -4457,6 +4457,69 @@ describe("runtime directories and plugin Python boundary", () => {});});+ test("allows OWNER RIGHTS on a Windows ancestor only after verifying its owner", () => {+ const user = "S-1-5-21-111-222-333-1001";+ const stranger = "S-1-5-21-111-222-333-1002";+ for (const trustee of ["OW", "S-1-3-4"]) {+ for (const owner of [user, "SY", "BA"]) {+ const descriptor = `O:${owner}G:SYD:P(A;OICI;FA;;;${trustee})(A;;FA;;;${stranger})`;+ expect(+ inspectWindowsCredentialAcl(descriptor, user, { scope: "ancestor" })+ .untrustedPrincipals,+ ).toEqual([stranger]);+ }+ for (const owner of [stranger, "OW"]) {+ expect(() =>+ inspectWindowsCredentialAcl(+ `O:${owner}G:SYD:P(A;;FA;;;${trustee})`,+ user,+ { scope: "ancestor" },+ ),+ ).toThrow(/owner/u);+ }+ }+ });++ test.skipIf(process.platform !== "win32")(+ "prepares a Windows credential home beneath a protected OWNER RIGHTS ancestor",+ async () => {+ const parent = join(await temporaryDirectory(), "private-parent");+ await mkdir(parent);+ const environment = { ...process.env, QA_OWNER_RIGHTS_PARENT: parent };+ const grant = windowsTestCommand("icacls.exe", [+ parent,+ "/inheritance:r",+ "/grant:r",+ `*${windowsUserSid()}:(OI)(CI)F`,+ "*S-1-5-18:(OI)(CI)F",+ "*S-1-5-32-544:(OI)(CI)F",+ "*S-1-3-4:(OI)(CI)F",+ ]);+ expect(grant.status, grant.stderr).toBe(0);+ const readParent = () =>+ inspectWindowsTestAcl(+ [+ "$ErrorActionPreference = 'Stop'",+ '$env:PSModulePath = "$PSHOME\\Modules"',+ "(Microsoft.PowerShell.Security\\Get-Acl -LiteralPath $env:QA_OWNER_RIGHTS_PARENT).Sddl",+ ],+ environment,+ );+ const before = readParent();+ expect(before.status, before.stderr).toBe(0);+ expect(before.stdout).toMatch(/;;;(?:OW|S-1-3-4)\)/u);+ const state = join(parent, "state");+ expect(+ await prepareCodexSecurityCredentialHome({+ CODEX_SECURITY_STATE_DIR: state,+ }),+ ).toBe(join(state, "codex-home"));+ const after = readParent();+ expect(after.status, after.stderr).toBe(0);+ expect(after.stdout).toBe(before.stdout);+ },+ );+test("identifies broad, foreign, and inherited Windows ACL grants", () => {const user = "S-1-5-21-111-222-333-1001";const stranger = "S-1-5-21-111-222-333-1002";