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(auth): reject plaintext remote login URLs (#1331)
Anirudh N Shandilya4c1dcbb64ca7
diff --git a/sdk/typescript/src/auth.ts b/sdk/typescript/src/auth.tsindex 88ccf5769..718856d85 100644--- a/sdk/typescript/src/auth.ts+++ b/sdk/typescript/src/auth.ts@@ -325,8 +325,10 @@ function preferredAuthUrl(value: string): string | null {)) {const url = match[0].replace(/[.,;:!?)\]}]+$/, "");try {- const hostname = new URL(url).hostname.toLowerCase().replace(/\.$/, "");+ const parsed = new URL(url);+ const hostname = parsed.hostname.toLowerCase().replace(/\.$/, "");if (+ parsed.protocol === "https:" &&hostname !== "localhost" &&!hostname.endsWith(".localhost") &&!(isIP(hostname) === 4 && hostname.startsWith("127.")) &&diff --git a/sdk/typescript/tests-ts/auth.test.ts b/sdk/typescript/tests-ts/auth.test.tsindex b8a4e276c..ad7f9e588 100644--- a/sdk/typescript/tests-ts/auth.test.ts+++ b/sdk/typescript/tests-ts/auth.test.ts@@ -170,6 +170,35 @@ describe("Codex authentication process boundary", () => {},);+ test.each([+ ["HTTP-only output", "", null],+ [+ "HTTP followed by HTTPS",+ "Open https://auth.example.test/device\n",+ "https://auth.example.test/device",+ ],+ ] as const)(+ "ignores external plaintext HTTP authentication URLs: %s",+ async (_description, httpsOutput, verificationUrl) => {+ const root = await temporaryDirectory("codex-security-auth-http-");+ const script = join(root, "login.mjs");+ await writeFile(+ script,+ `process.stderr.write(${JSON.stringify(`Open http://auth.example.test/device\n${httpsOutput}User code: ABCD-EFGH\n`)}, () => process.exit(0));\n`,+ );+ const handle = new CodexLoginHandle(+ nodeCommand(),+ [script],+ process.env,+ () => {},+ );++ await expect(handle.wait()).resolves.toMatchObject({ success: true });+ expect(handle.verificationUrl).toBe(verificationUrl);+ expect(handle.userCode).toBe("ABCD-EFGH");+ },+ );+test("retains large interactive output and login instructions", async () => {const root = await temporaryDirectory("codex-security-auth-output-");const script = join(root, "login.mjs");