Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(cli): refuse symlink entries when extracting archives (#4210)

Alberto Schiabelf926058147ce
diff --git a/ts/packages/cli-local-tools/src/bundled-binaries.ts b/ts/packages/cli-local-tools/src/bundled-binaries.ts
index 8218e768e..3e5a58c34 100644
--- a/ts/packages/cli-local-tools/src/bundled-binaries.ts
+++ b/ts/packages/cli-local-tools/src/bundled-binaries.ts
@@ -3,7 +3,7 @@ import fs from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
-import extractZip from 'extract-zip';
+import { extractZipSafely } from './extract-zip-safely';
import { detectCliPlatform, supportsCliPlatform } from './platform';
import type {
LocalBundledBinaryDeclaration,
@@ -233,7 +233,7 @@ const repairInstalledLocalToolsBundle = async (): Promise<boolean> => {
const zipPath = path.join(tempDir, asset.name);
const extractDir = path.join(tempDir, 'extract');
await fs.writeFile(zipPath, archiveData);
- await extractZip(zipPath, { dir: extractDir });
+ await extractZipSafely(zipPath, extractDir);
const archiveBundleRoot = path.join(
extractDir,
diff --git a/ts/packages/cli-local-tools/src/extract-zip-safely.test.ts b/ts/packages/cli-local-tools/src/extract-zip-safely.test.ts
new file mode 100644
index 000000000..484b93e98
--- /dev/null
+++ b/ts/packages/cli-local-tools/src/extract-zip-safely.test.ts
@@ -0,0 +1,54 @@
+import fs from 'node:fs';
+import os from 'node:os';
+import path from 'node:path';
+import { describe, expect, it } from 'vitest';
+import { extractZipSafely, isSymlinkZipEntry, UnsafeZipEntryError } from './extract-zip-safely';
+
+const FIXTURES_DIR = path.join(__dirname, 'zip-fixtures');
+
+const withTempDir = async (use: (dir: string) => Promise<void>): Promise<void> => {
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'local-tools-extract-'));
+ try {
+ await use(dir);
+ } finally {
+ fs.rmSync(dir, { recursive: true, force: true });
+ }
+};
+
+describe('isSymlinkZipEntry', () => {
+ it.each([
+ ['symbolic link', 0o120755, true],
+ ['regular file', 0o100644, false],
+ ['directory', 0o40755, false],
+ ])('classifies a %s', (_label, mode, expected) => {
+ expect(isSymlinkZipEntry(mode << 16)).toBe(expected);
+ });
+
+ it('accepts a Windows-authored entry that carries no Unix mode', () => {
+ expect(isSymlinkZipEntry(0)).toBe(false);
+ });
+});
+
+describe('extractZipSafely', () => {
+ it('extracts an archive of regular files and directories', async () => {
+ await withTempDir(async dir => {
+ await extractZipSafely(path.join(FIXTURES_DIR, 'benign.zip'), dir);
+
+ expect(fs.readFileSync(path.join(dir, 'a.txt'), 'utf8').trim()).toBe('hello');
+ expect(fs.readFileSync(path.join(dir, 'sub', 'b.txt'), 'utf8').trim()).toBe('world');
+ });
+ });
+
+ it.each(['symlink-absolute.zip', 'symlink-relative.zip'])(
+ 'refuses %s and plants nothing',
+ async fixture => {
+ await withTempDir(async dir => {
+ await expect(extractZipSafely(path.join(FIXTURES_DIR, fixture), dir)).rejects.toThrow(
+ UnsafeZipEntryError
+ );
+
+ expect(fs.readdirSync(dir)).toEqual([]);
+ });
+ }
+ );
+});
diff --git a/ts/packages/cli-local-tools/src/extract-zip-safely.ts b/ts/packages/cli-local-tools/src/extract-zip-safely.ts
new file mode 100644
index 000000000..7f9ead8d2
--- /dev/null
+++ b/ts/packages/cli-local-tools/src/extract-zip-safely.ts
@@ -0,0 +1,40 @@
+import extractZip from 'extract-zip';
+
+/**
+ * Zip extraction that refuses symlink entries.
+ *
+ * `extract-zip` writes a symlink entry without validating its target
+ * (CVE-2026-56876 / GHSA-jmr9-qjv8-65gv), and the advisory has no fixed
+ * version. Sidecar archives never contain symlinks, so rejecting the entry type
+ * removes the vector. See the matching helper in `@composio/cli` for why this
+ * is a local workaround rather than an upstream fix, and when it can go; the
+ * two are kept separate because this package must not be pulled into the CLI's
+ * standalone companion bundles.
+ */
+
+// Unix mode lives in the high 16 bits of a zip entry's external attributes.
+const UNIX_MODE_SHIFT = 16;
+const FILE_TYPE_MASK = 0o170000;
+const SYMLINK_FILE_TYPE = 0o120000;
+
+export class UnsafeZipEntryError extends Error {
+ constructor(readonly entryName: string) {
+ super(
+ `Refusing to extract archive: "${entryName}" is a symbolic link, which this CLI never ships.`
+ );
+ this.name = 'UnsafeZipEntryError';
+ }
+}
+
+export const isSymlinkZipEntry = (externalFileAttributes: number): boolean =>
+ ((externalFileAttributes >>> UNIX_MODE_SHIFT) & FILE_TYPE_MASK) === SYMLINK_FILE_TYPE;
+
+export const extractZipSafely = (zipPath: string, dir: string): Promise<void> =>
+ extractZip(zipPath, {
+ dir,
+ onEntry: entry => {
+ if (isSymlinkZipEntry(entry.externalFileAttributes)) {
+ throw new UnsafeZipEntryError(entry.fileName);
+ }
+ },
+ });
diff --git a/ts/packages/cli-local-tools/src/zip-fixtures/benign.zip b/ts/packages/cli-local-tools/src/zip-fixtures/benign.zip
new file mode 100644
index 000000000..75e30af4b
Binary files /dev/null and b/ts/packages/cli-local-tools/src/zip-fixtures/benign.zip differ
diff --git a/ts/packages/cli-local-tools/src/zip-fixtures/symlink-absolute.zip b/ts/packages/cli-local-tools/src/zip-fixtures/symlink-absolute.zip
new file mode 100644
index 000000000..0a438d56e
Binary files /dev/null and b/ts/packages/cli-local-tools/src/zip-fixtures/symlink-absolute.zip differ
diff --git a/ts/packages/cli-local-tools/src/zip-fixtures/symlink-relative.zip b/ts/packages/cli-local-tools/src/zip-fixtures/symlink-relative.zip
new file mode 100644
index 000000000..ac4bf4b72
Binary files /dev/null and b/ts/packages/cli-local-tools/src/zip-fixtures/symlink-relative.zip differ
diff --git a/ts/packages/cli/CHANGELOG.md b/ts/packages/cli/CHANGELOG.md
index ad3f7052a..f947b830e 100644
--- a/ts/packages/cli/CHANGELOG.md
+++ b/ts/packages/cli/CHANGELOG.md
@@ -4,6 +4,11 @@
### Patch Changes
+- Archives are no longer extracted with symbolic links in them. `extract-zip`
+ creates a symlink entry without validating its target (CVE-2026-56876), which
+ has no fixed release, and anything that later reads the extracted tree can be
+ walked out of it. No archive this CLI extracts legitimately contains a
+ symlink, so such an entry is now refused before it is written.
- `composio search` now uses schemas returned by Tool Router for dashboard-registered custom MCP tools instead of querying the legacy managed-tool endpoint, which returned 404 for `CUSTOM_*` tool slugs.
- `composio upgrade` works again from any previously released CLI. Release
archives had been narrowed to carry only the `codex-acp` binary their own
diff --git a/ts/packages/cli/src/effects/install-skill.ts b/ts/packages/cli/src/effects/install-skill.ts
index 4661793ff..c46ea8d6e 100644
--- a/ts/packages/cli/src/effects/install-skill.ts
+++ b/ts/packages/cli/src/effects/install-skill.ts
@@ -11,7 +11,7 @@ import {
type GitHubRelease,
type GitHubRepoConfig,
} from 'src/effects/resolve-cli-release';
-import extractZip from 'extract-zip';
+import { extractZipSafely } from 'src/utils/extract-zip-safely';
const SKILL_NAME = 'composio-cli';
const SKILL_ASSET_NAME = 'composio-skill.zip';
@@ -218,7 +218,7 @@ export const installSkill = (options?: {
yield* fs.writeFile(zipPath, new Uint8Array(zipData));
yield* Effect.tryPromise({
- try: () => extractZip(zipPath, { dir: tmpDir }),
+ try: () => extractZipSafely(zipPath, tmpDir),
catch: cause =>
new SkillInstallError({
cause,
diff --git a/ts/packages/cli/src/services/run-companion-modules.ts b/ts/packages/cli/src/services/run-companion-modules.ts
index 065a5b784..51c6224bd 100644
--- a/ts/packages/cli/src/services/run-companion-modules.ts
+++ b/ts/packages/cli/src/services/run-companion-modules.ts
@@ -5,7 +5,7 @@
import { FileSystem, Path } from '@effect/platform';
import type { PlatformError } from '@effect/platform/Error';
import { Config, ConfigProvider, Data, Effect, Option, Schema } from 'effect';
-import extractZip from 'extract-zip';
+import { extractZipSafely } from 'src/utils/extract-zip-safely';
import { IS_RELEASE_BUILD } from 'src/constants';
import { GitHubRelease } from 'src/effects/resolve-cli-release';
import { BaseConfigProviderLive, extendConfigProvider } from 'src/services/config';
@@ -713,7 +713,7 @@ export const repairMissingInstalledRunCompanionModules = ({
yield* fs.writeFile(archivePath, archiveData);
yield* fs.makeDirectory(extractDirectory, { recursive: true });
yield* Effect.tryPromise({
- try: () => extractZip(archivePath, { dir: extractDirectory }),
+ try: () => extractZipSafely(archivePath, extractDirectory),
catch: toRepairError,
});
diff --git a/ts/packages/cli/src/services/upgrade-binary.ts b/ts/packages/cli/src/services/upgrade-binary.ts
index 76fb9fa32..698f0c6d4 100644
--- a/ts/packages/cli/src/services/upgrade-binary.ts
+++ b/ts/packages/cli/src/services/upgrade-binary.ts
@@ -23,7 +23,7 @@ import {
} from 'src/utils/atomic-replace';
// Note: `node:zlib` does not support Github's zip files
-import extractZip from 'extract-zip';
+import { extractZipSafely } from 'src/utils/extract-zip-safely';
import { renderPrettyError } from './utils/pretty-error';
import { TerminalUI } from './terminal-ui';
import {
@@ -366,7 +366,7 @@ const extractBinary = (
yield* Effect.tryPromise({
try: async () => {
- await extractZip(zipPath, { dir: extractDir });
+ await extractZipSafely(zipPath, extractDir);
},
catch: error =>
new UpgradeBinaryError({
diff --git a/ts/packages/cli/src/utils/extract-zip-safely.ts b/ts/packages/cli/src/utils/extract-zip-safely.ts
new file mode 100644
index 000000000..98b23f558
--- /dev/null
+++ b/ts/packages/cli/src/utils/extract-zip-safely.ts
@@ -0,0 +1,61 @@
+import extractZip from 'extract-zip';
+
+/**
+ * Zip extraction that refuses symlink entries.
+ *
+ * `extract-zip` writes a symlink entry without validating its target
+ * (CVE-2026-56876 / GHSA-jmr9-qjv8-65gv). It does block writes that *traverse* a
+ * symlink, so an archive cannot plant a file outside the extraction directory,
+ * but the dangling symlink itself is created — pointing anywhere, including an
+ * absolute path. Anything that later reads or copies the extracted tree can be
+ * walked out of it. The advisory has no fixed version: 2.0.1 is the newest
+ * release, and GitHub records `first_patched_version` as null.
+ *
+ * No archive this CLI extracts — release binaries, companion assets, skills —
+ * legitimately contains a symlink, so rejecting the entry type outright removes
+ * the vector without narrowing what a valid archive may hold. The check runs
+ * before the entry is written, so a rejected archive plants nothing.
+ *
+ * This is deliberately a local workaround rather than an upstream fix. Refusing
+ * every symlink suits an application whose archives never carry one, but it
+ * would break a general-purpose library, where the correct fix is to validate
+ * that a link's resolved target stays inside the extraction root. That fix is
+ * already proposed upstream several times over — max-mapper/extract-zip#158,
+ * #160 and #161 — and none of them has moved: the repository's last commit was
+ * August 2021, and the issue asking whether a patched release is planned
+ * (max-mapper/extract-zip#159) has drawn replies only from other stranded
+ * consumers. Drop this helper once a release actually carries the fix.
+ */
+
+// Unix mode lives in the high 16 bits of a zip entry's external attributes.
+const UNIX_MODE_SHIFT = 16;
+const FILE_TYPE_MASK = 0o170000;
+const SYMLINK_FILE_TYPE = 0o120000;
+
+export class UnsafeZipEntryError extends Error {
+ constructor(readonly entryName: string) {
+ super(
+ `Refusing to extract archive: "${entryName}" is a symbolic link, which this CLI never ships.`
+ );
+ this.name = 'UnsafeZipEntryError';
+ }
+}
+
+/**
+ * Whether a zip entry's external attributes describe a symbolic link.
+ *
+ * Archives written on Windows leave the Unix mode bits empty, which reads as a
+ * regular file — the correct answer, since such an archive has no symlinks.
+ */
+export const isSymlinkZipEntry = (externalFileAttributes: number): boolean =>
+ ((externalFileAttributes >>> UNIX_MODE_SHIFT) & FILE_TYPE_MASK) === SYMLINK_FILE_TYPE;
+
+export const extractZipSafely = (zipPath: string, dir: string): Promise<void> =>
+ extractZip(zipPath, {
+ dir,
+ onEntry: entry => {
+ if (isSymlinkZipEntry(entry.externalFileAttributes)) {
+ throw new UnsafeZipEntryError(entry.fileName);
+ }
+ },
+ });
diff --git a/ts/packages/cli/test/src/utils/extract-zip-safely.test.ts b/ts/packages/cli/test/src/utils/extract-zip-safely.test.ts
new file mode 100644
index 000000000..ba7d15e1d
--- /dev/null
+++ b/ts/packages/cli/test/src/utils/extract-zip-safely.test.ts
@@ -0,0 +1,69 @@
+import * as fs from 'node:fs';
+import * as os from 'node:os';
+import * as path from 'node:path';
+import { describe, expect, it } from '@effect/vitest';
+import {
+ extractZipSafely,
+ isSymlinkZipEntry,
+ UnsafeZipEntryError,
+} from 'src/utils/extract-zip-safely';
+
+const FIXTURES_DIR = path.join(__dirname, 'zip-fixtures');
+
+const withTempDir = async (use: (dir: string) => Promise<void>): Promise<void> => {
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'extract-zip-safely-'));
+ try {
+ await use(dir);
+ } finally {
+ fs.rmSync(dir, { recursive: true, force: true });
+ }
+};
+
+/**
+ * `mode << 16` is how a zip stores the Unix mode in its external attributes.
+ */
+const externalAttributesFor = (mode: number): number => mode << 16;
+
+describe('isSymlinkZipEntry', () => {
+ it('detects a symbolic link', () => {
+ expect(isSymlinkZipEntry(externalAttributesFor(0o120755))).toBe(true);
+ });
+
+ it('accepts a regular file', () => {
+ expect(isSymlinkZipEntry(externalAttributesFor(0o100644))).toBe(false);
+ });
+
+ it('accepts a directory', () => {
+ expect(isSymlinkZipEntry(externalAttributesFor(0o40755))).toBe(false);
+ });
+
+ it('accepts a Windows-authored entry that carries no Unix mode', () => {
+ expect(isSymlinkZipEntry(0)).toBe(false);
+ });
+});
+
+describe('extractZipSafely', () => {
+ it('extracts an archive of regular files and directories', async () => {
+ await withTempDir(async dir => {
+ await extractZipSafely(path.join(FIXTURES_DIR, 'benign.zip'), dir);
+
+ expect(fs.readFileSync(path.join(dir, 'a.txt'), 'utf8').trim()).toBe('hello');
+ expect(fs.readFileSync(path.join(dir, 'sub', 'b.txt'), 'utf8').trim()).toBe('world');
+ });
+ });
+
+ it.each([
+ ['symlink-absolute.zip', 'escape-abs'],
+ ['symlink-relative.zip', 'escape-rel'],
+ ])('refuses %s and plants nothing', async (fixture, entryName) => {
+ await withTempDir(async dir => {
+ await expect(extractZipSafely(path.join(FIXTURES_DIR, fixture), dir)).rejects.toThrow(
+ UnsafeZipEntryError
+ );
+
+ // The guard runs before the entry is written, so the target stays empty.
+ expect(fs.readdirSync(dir)).toEqual([]);
+ expect(fs.existsSync(path.join(dir, entryName))).toBe(false);
+ });
+ });
+});
diff --git a/ts/packages/cli/test/src/utils/zip-fixtures/benign.zip b/ts/packages/cli/test/src/utils/zip-fixtures/benign.zip
new file mode 100644
index 000000000..75e30af4b
Binary files /dev/null and b/ts/packages/cli/test/src/utils/zip-fixtures/benign.zip differ
diff --git a/ts/packages/cli/test/src/utils/zip-fixtures/symlink-absolute.zip b/ts/packages/cli/test/src/utils/zip-fixtures/symlink-absolute.zip
new file mode 100644
index 000000000..0a438d56e
Binary files /dev/null and b/ts/packages/cli/test/src/utils/zip-fixtures/symlink-absolute.zip differ
diff --git a/ts/packages/cli/test/src/utils/zip-fixtures/symlink-relative.zip b/ts/packages/cli/test/src/utils/zip-fixtures/symlink-relative.zip
new file mode 100644
index 000000000..ac4bf4b72
Binary files /dev/null and b/ts/packages/cli/test/src/utils/zip-fixtures/symlink-relative.zip differ