Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

fix(package): preserve bundled MCP launcher permissions (#678)

soyeon-oai67bc0b7c0653
diff --git a/sdk/typescript/package.json b/sdk/typescript/package.json
index 26ba4cc99..86f06b4cc 100644
--- a/sdk/typescript/package.json
+++ b/sdk/typescript/package.json
@@ -36,7 +36,10 @@
"README.md"
],
"publishConfig": {
- "access": "public"
+ "access": "public",
+ "executableFiles": [
+ "_bundled_plugin/scripts/launch_codex_security_mcp"
+ ]
},
"scripts": {
"audit:prod": "pnpm audit --prod --audit-level high",
diff --git a/sdk/typescript/scripts/check-package.mjs b/sdk/typescript/scripts/check-package.mjs
index 87c7e0468..531f8146d 100644
--- a/sdk/typescript/scripts/check-package.mjs
+++ b/sdk/typescript/scripts/check-package.mjs
@@ -236,13 +236,15 @@ if (
) {
throw new Error("npm tarball contains an invalid tar entry.");
}
-const launcherPermissions =
- listingLines[entries.indexOf("package/bin/codex-security.mjs")]?.split(
- /\s/u,
- 1,
- )[0] ?? "";
-if ([3, 6, 9].some((index) => launcherPermissions[index] !== "x")) {
- throw new Error("npm package CLI launcher is not executable.");
+for (const [path, name] of [
+ ["package/bin/codex-security.mjs", "CLI"],
+ ["package/_bundled_plugin/scripts/launch_codex_security_mcp", "MCP"],
+]) {
+ const permissions =
+ listingLines[entries.indexOf(path)]?.split(/\s/u, 1)[0] ?? "";
+ if ([3, 6, 9].some((index) => permissions[index] !== "x")) {
+ throw new Error(`npm package ${name} launcher is not executable.`);
+ }
}
const packageJson = JSON.parse(
archiveFile("package/package.json").toString("utf8"),
diff --git a/sdk/typescript/scripts/smoke-package.mjs b/sdk/typescript/scripts/smoke-package.mjs
index 87a85fa26..80a442b47 100644
--- a/sdk/typescript/scripts/smoke-package.mjs
+++ b/sdk/typescript/scripts/smoke-package.mjs
@@ -203,6 +203,50 @@ async function smokeNestedDeepScanWorker(installedRoot, consumer) {
"The installed plugin must propagate the bundled Codex path into nested workers.",
);
+ const pluginRoot = join(installedRoot, "_bundled_plugin");
+ const mcpLauncher = join(pluginRoot, "scripts", "launch_codex_security_mcp");
+ const windows = process.platform === "win32";
+ const initialized = spawnSync(
+ windows
+ ? process.env.ComSpec ??
+ join(process.env.SystemRoot ?? "C:\\Windows", "System32", "cmd.exe")
+ : mcpLauncher,
+ windows
+ ? ["/d", "/s", "/c", "call", `${mcpLauncher}.cmd`, "--stdio"]
+ : ["--stdio"],
+ {
+ cwd: pluginRoot,
+ encoding: "utf8",
+ env: { ...workerEnvironment, CODEX_MCP_NODE_PATH: process.execPath },
+ input: `${JSON.stringify({
+ jsonrpc: "2.0",
+ id: 1,
+ method: "initialize",
+ params: {
+ protocolVersion: "2025-11-25",
+ capabilities: {},
+ clientInfo: {
+ name: "codex-security-package-smoke",
+ version: "0.1.0",
+ },
+ },
+ })}\n`,
+ timeout: PACKAGE_SMOKE_TIMEOUT_MS,
+ windowsHide: true,
+ },
+ );
+ if (initialized.error !== undefined) {
+ throw new Error("Installed MCP launcher did not start.", {
+ cause: initialized.error,
+ });
+ }
+ assert.equal(initialized.status, 0, initialized.stderr);
+ assert.equal(
+ JSON.parse(initialized.stdout.trim()).result.serverInfo.name,
+ "codex-security",
+ "The installed MCP launcher must initialize the bundled security server.",
+ );
+
const globalCodex = spawnSync("codex", ["--version"], {
cwd: consumer,
encoding: "utf8",
@@ -569,7 +613,7 @@ try {
await smokeNestedDeepScanWorker(installedRoot, consumer);
console.log(
- `Validated installed ${packageManifest.name}@${packageManifest.version}: public import, NodeNext types, CLI, credential locking, ${expectedPluginFiles.length} bundled plugin files, bundled Codex version, and a nested worker without global codex.`,
+ `Validated installed ${packageManifest.name}@${packageManifest.version}: public import, NodeNext types, CLI, credential locking, ${expectedPluginFiles.length} bundled plugin files, MCP initialization, bundled Codex version, and a nested worker without global codex.`,
);
} finally {
await rm(consumer, {