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(core): detect filesystem case sensitivity for uploads (#4036)

Alberto Schiabel51056129ee11
diff --git a/.changeset/precise-sensitive-path-casing.md b/.changeset/precise-sensitive-path-casing.md
new file mode 100644
index 000000000..b01fa697d
--- /dev/null
+++ b/.changeset/precise-sensitive-path-casing.md
@@ -0,0 +1,5 @@
+---
+'@composio/core': patch
+---
+
+Match sensitive upload path segments using the target filesystem's actual case sensitivity so case-insensitive mounts cannot bypass the denylist without over-blocking distinct paths on case-sensitive mounts.
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a53a16195..ac2182374 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -681,7 +681,7 @@ importers:
version: 2.13.0(@modelcontextprotocol/[email protected](@cfworker/[email protected])([email protected]))
'@modelcontextprotocol/sdk':
specifier: 'catalog:'
- version: 1.29.0(@cfworker/[email protected])([email protected])
dotenv:
specifier: 'catalog:'
version: 17.4.2
@@ -833,7 +833,7 @@ importers:
version: link:../../packages/providers/vercel
'@modelcontextprotocol/sdk':
specifier: 'catalog:'
- version: 1.29.0(@cfworker/[email protected])([email protected])
ai:
specifier: 'catalog:'
version: 7.0.37([email protected])
@@ -886,7 +886,7 @@ importers:
version: link:../../packages/providers/openai-agents
'@modelcontextprotocol/sdk':
specifier: 'catalog:'
- version: 1.29.0(@cfworker/[email protected])([email protected])
'@openai/agents':
specifier: ^0.13.5
@@ -1087,7 +1087,7 @@ importers:
version: link:../../packages/providers/vercel
'@modelcontextprotocol/sdk':
specifier: 'catalog:'
- version: 1.29.0(@cfworker/[email protected])([email protected])
ai:
specifier: 'catalog:'
version: 7.0.37([email protected])
@@ -1170,7 +1170,7 @@ importers:
'@modelcontextprotocol/sdk':
specifier: 'catalog:'
- version: 1.29.0(@cfworker/[email protected])([email protected])
'@zed-industries/claude-code-acp':
specifier: ^0.16.2
version: 0.16.2(@cfworker/[email protected])([email protected])
@@ -1306,7 +1306,7 @@ importers:
version: link:../core
'@modelcontextprotocol/sdk':
specifier: 'catalog:'
- version: 1.29.0(@cfworker/[email protected])([email protected])
extract-zip:
specifier: ^2.0.1
version: 2.0.1([email protected])
@@ -1341,6 +1341,9 @@ importers:
'@types/json-schema':
specifier: ^7.0.15
version: 7.0.15
+ is-fs-case-sensitive:
+ specifier: ^2.0.0
+ version: 2.0.0
openai:
specifier: 'catalog:'
@@ -1680,6 +1683,9 @@ importers:
'@types/json-schema':
specifier: ^7.0.15
version: 7.0.15
+ is-fs-case-sensitive:
+ specifier: ^2.0.0
+ version: 2.0.0
openai:
specifier: 'catalog:'
@@ -5145,6 +5151,9 @@ packages:
resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==}
engines: {node: '>=0.10.0'}
+ resolution: {integrity: sha512-JoCsyGITdYPM+pUbeMQ4IiEuQ4wjPdeWORlG7n644isewbcxiQIr+9gmF5k7UabTP/jLBRkbgydEamR7JZBKHA==}
+
resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==}
engines: {node: '>=8'}
@@ -7031,7 +7040,7 @@ snapshots:
dependencies:
'@anthropic-ai/sdk': 0.114.0([email protected])
- '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])
+ '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])([email protected])
zod: 4.4.3
optionalDependencies:
'@anthropic-ai/claude-agent-sdk-darwin-arm64': 0.3.218
@@ -7803,7 +7812,7 @@ snapshots:
protobufjs: 7.6.5
ws: 8.21.1
optionalDependencies:
- '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])
+ '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])([email protected])
transitivePeerDependencies:
- bufferutil
- supports-color
@@ -7816,7 +7825,7 @@ snapshots:
protobufjs: 7.6.5
ws: 8.21.1
optionalDependencies:
- '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])
+ '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])([email protected])
transitivePeerDependencies:
- bufferutil
- supports-color
@@ -8065,7 +8074,7 @@ snapshots:
dependencies:
- '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])
+ '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])([email protected])
debug: 4.4.3([email protected])
zod: 4.4.3
optionalDependencies:
@@ -8141,7 +8150,7 @@ snapshots:
optionalDependencies:
- '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])
+ '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])([email protected])
hono: 4.12.31
zod: 4.4.3
@@ -8300,7 +8309,7 @@ snapshots:
'@isaacs/ttlcache': 2.1.5
'@lukeed/uuid': 2.0.1
'@mastra/schema-compat': 1.3.4([email protected])
- '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])
+ '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])([email protected])
'@sindresorhus/slugify': 2.2.1
'@standard-schema/spec': 1.1.0
ajv: 8.20.0
@@ -8351,7 +8360,7 @@ snapshots:
dependencies:
'@modelcontextprotocol/ext-apps': 1.7.5(@modelcontextprotocol/[email protected](@cfworker/[email protected])([email protected]))([email protected])
- '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])
+ '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])([email protected])
exit-hook: 5.1.0
fast-deep-equal: 3.1.3
transitivePeerDependencies:
@@ -8397,7 +8406,7 @@ snapshots:
'@modelcontextprotocol/[email protected](@modelcontextprotocol/[email protected](@cfworker/[email protected])([email protected]))([email protected])':
dependencies:
- '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])
+ '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])([email protected])
'@standard-schema/spec': 1.1.0
zod: 4.4.3
@@ -8412,7 +8421,7 @@ snapshots:
eventsource: 3.0.7
eventsource-parser: 3.1.0
express: 5.2.1
- express-rate-limit: 8.6.0([email protected])
+ express-rate-limit: 8.6.0([email protected])([email protected])
hono: 4.12.31
jose: 6.2.4
json-schema-typed: 8.0.2
@@ -8425,7 +8434,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
- '@modelcontextprotocol/[email protected](@cfworker/[email protected])([email protected])':
dependencies:
'@hono/node-server': 2.0.11([email protected])
ajv: 8.20.0
@@ -8436,20 +8445,20 @@ snapshots:
eventsource: 3.0.7
eventsource-parser: 3.1.0
express: 5.2.1
- express-rate-limit: 8.6.0([email protected])
+ express-rate-limit: 8.6.0([email protected])([email protected])
hono: 4.12.31
jose: 6.2.4
json-schema-typed: 8.0.2
pkce-challenge: 5.0.1
raw-body: 3.0.2
- zod: 3.25.76
- zod-to-json-schema: 3.25.2([email protected])
+ zod: 4.4.3
+ zod-to-json-schema: 3.25.2([email protected])
optionalDependencies:
'@cfworker/json-schema': 4.1.1
transitivePeerDependencies:
- supports-color
- '@modelcontextprotocol/[email protected](@cfworker/[email protected])([email protected])':
+ '@modelcontextprotocol/[email protected](@cfworker/[email protected])([email protected])':
dependencies:
'@hono/node-server': 2.0.11([email protected])
ajv: 8.20.0
@@ -8460,14 +8469,14 @@ snapshots:
eventsource: 3.0.7
eventsource-parser: 3.1.0
express: 5.2.1
- express-rate-limit: 8.6.0([email protected])
+ express-rate-limit: 8.6.0([email protected])([email protected])
hono: 4.12.31
jose: 6.2.4
json-schema-typed: 8.0.2
pkce-challenge: 5.0.1
raw-body: 3.0.2
- zod: 4.4.3
- zod-to-json-schema: 3.25.2([email protected])
+ zod: 3.25.76
+ zod-to-json-schema: 3.25.2([email protected])
optionalDependencies:
'@cfworker/json-schema': 4.1.1
transitivePeerDependencies:
@@ -8515,7 +8524,7 @@ snapshots:
debug: 4.4.3([email protected])
optionalDependencies:
- '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])
+ '@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])([email protected])
zod: 4.4.3
transitivePeerDependencies:
- '@aws-sdk/credential-provider-node'
@@ -9879,7 +9888,7 @@ snapshots:
dependencies:
debug: 4.4.3([email protected])
express: 5.2.1
@@ -10237,6 +10246,8 @@ snapshots:
+
diff --git a/ts/packages/core/package.json b/ts/packages/core/package.json
index e618be1f0..b4292998f 100644
--- a/ts/packages/core/package.json
+++ b/ts/packages/core/package.json
@@ -114,6 +114,7 @@
"@composio/client": "catalog:",
"@composio/json-schema-to-zod": "workspace:*",
"@types/json-schema": "^7.0.15",
+ "is-fs-case-sensitive": "^2.0.0",
"openai": "catalog:",
"picocolors": "catalog:",
"pusher-js": "^8.6.0",
diff --git a/ts/packages/core/src/platform/node.ts b/ts/packages/core/src/platform/node.ts
index 7f6804ef8..4c7fd26cf 100644
--- a/ts/packages/core/src/platform/node.ts
+++ b/ts/packages/core/src/platform/node.ts
@@ -1,8 +1,37 @@
import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
+import { isFsCaseSensitive } from 'is-fs-case-sensitive';
import type { Platform, Uint8ArrayEncoding } from './types';
+const findNearestExistingDirectory = (filePath: string): string => {
+ let candidate = path.resolve(filePath);
+
+ try {
+ if (!fs.statSync(candidate).isDirectory()) {
+ candidate = path.dirname(candidate);
+ }
+ } catch {
+ candidate = path.dirname(candidate);
+ }
+
+ while (true) {
+ try {
+ if (fs.statSync(candidate).isDirectory()) {
+ return candidate;
+ }
+ } catch {
+ // Walk toward the filesystem root until an existing directory is found.
+ }
+
+ const parent = path.dirname(candidate);
+ if (parent === candidate) {
+ return candidate;
+ }
+ candidate = parent;
+ }
+};
+
/**
* Node.js platform implementation.
* Provides full file system and OS operations using Node.js built-in modules.
@@ -42,6 +71,17 @@ export const platform = {
return fs.realpathSync(filePath);
},
+ isFileSystemCaseSensitive(filePath: string): boolean {
+ try {
+ return isFsCaseSensitive(findNearestExistingDirectory(filePath));
+ } catch {
+ // Detection must not weaken this security guard. If the target mount
+ // cannot be inspected, compare case-insensitively and accept possible
+ // false positives instead of allowing a casing bypass.
+ return false;
+ }
+ },
+
mkdirSync(dirPath: string): void {
fs.mkdirSync(dirPath, { recursive: true });
},
diff --git a/ts/packages/core/src/platform/types.ts b/ts/packages/core/src/platform/types.ts
index 1682eebf3..42a335378 100644
--- a/ts/packages/core/src/platform/types.ts
+++ b/ts/packages/core/src/platform/types.ts
@@ -52,6 +52,15 @@ export interface Platform {
*/
realpathSync(filePath: string): string;
+ /**
+ * Returns whether paths on the filesystem containing `filePath` are
+ * case-sensitive. Node checks the nearest existing directory so the result
+ * follows the target mount rather than the operating-system default.
+ * Runtimes without a filesystem return true to preserve exact path matching.
+ * @param filePath - A file or directory on the filesystem to inspect.
+ */
+ isFileSystemCaseSensitive?(filePath: string): boolean;
+
/**
* Creates a directory at the given path, including parent directories if needed.
* @param dirPath - The directory path to create.
diff --git a/ts/packages/core/src/platform/workerd.ts b/ts/packages/core/src/platform/workerd.ts
index f671741b6..97c459861 100644
--- a/ts/packages/core/src/platform/workerd.ts
+++ b/ts/packages/core/src/platform/workerd.ts
@@ -82,6 +82,11 @@ export const platform: Platform = {
return filePath;
},
+ isFileSystemCaseSensitive(_filePath: string): boolean {
+ // Preserve exact matching when there is no filesystem to inspect.
+ return true;
+ },
+
mkdirSync(_dirPath: string): void {
// No-op in edge runtimes - directories cannot be created
},
diff --git a/ts/packages/core/src/utils/sensitiveFileUploadPaths.ts b/ts/packages/core/src/utils/sensitiveFileUploadPaths.ts
index da8e01be9..8ae2b5350 100644
--- a/ts/packages/core/src/utils/sensitiveFileUploadPaths.ts
+++ b/ts/packages/core/src/utils/sensitiveFileUploadPaths.ts
@@ -12,7 +12,8 @@ import { ComposioSensitiveFilePathBlockedError } from '../errors/FileModifierErr
/**
* Path segments (a single path component) that indicate a sensitive directory when
- * they appear anywhere in a resolved local path. Compared case-insensitively on Windows.
+ * they appear anywhere in a resolved local path. Matching follows the case sensitivity
+ * of the filesystem containing that path.
*/
export const BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS: readonly string[] = [
'.ssh',
@@ -30,12 +31,10 @@ const SECRET_LIKE_BASENAME = /^(\.env(\.|$)|\.netrc$|\.pgpass$)/i;
/** Default SSH private key basenames (public keys like id_rsa.pub are allowed). */
const DEFAULT_PRIVATE_KEY_BASENAME = /^id_(rsa|ed25519|ecdsa|dsa|ecdsa_sk)(\.old)?$/i;
-const isWindows = typeof process !== 'undefined' && process.platform === 'win32';
-
/**
* Returns normalized path segments, resolving symlinks when the path exists.
*/
-function normalizePathSegments(filePath: string): string[] {
+function normalizePath(filePath: string): { resolvedPath: string; segments: string[] } {
const absolute = platform.resolvePath(filePath);
let resolved = absolute;
try {
@@ -45,7 +44,10 @@ function normalizePathSegments(filePath: string): string[] {
} catch {
// If realpath fails (e.g. race), use resolved path
}
- return resolved.split(/[/\\]+/).filter(Boolean);
+ return {
+ resolvedPath: resolved,
+ segments: resolved.split(/[/\\]+/).filter(Boolean),
+ };
}
/**
@@ -63,16 +65,17 @@ function getSensitiveFileUploadPathBlockReason(
filePath: string,
additionalDenySegments?: string[]
): string | null {
- const segments = normalizePathSegments(filePath);
+ const { resolvedPath, segments } = normalizePath(filePath);
+ const isCaseSensitive = platform.isFileSystemCaseSensitive?.(resolvedPath) ?? true;
+ const normalizeSegment = (segment: string) => (isCaseSensitive ? segment : segment.toLowerCase());
const deny = new Set(
[
...BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS,
...(additionalDenySegments ?? []).map(s => s.trim()).filter(Boolean),
- ].map(s => (isWindows ? s.toLowerCase() : s))
+ ].map(normalizeSegment)
);
- // Windows: compare segments case-insensitively; map once instead of toLowerCase per iteration.
- const segmentsForMatch = isWindows ? segments.map(s => s.toLowerCase()) : segments;
+ const segmentsForMatch = isCaseSensitive ? segments : segments.map(normalizeSegment);
for (let i = 0; i < segments.length; i++) {
if (deny.has(segmentsForMatch[i]!)) {
return `path segment "${segments[i]}" is in the sensitive file upload denylist`;
diff --git a/ts/packages/core/test/platform/node.test.ts b/ts/packages/core/test/platform/node.test.ts
new file mode 100644
index 000000000..3abbdde3c
--- /dev/null
+++ b/ts/packages/core/test/platform/node.test.ts
@@ -0,0 +1,37 @@
+import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import * as os from 'node:os';
+import * as path from 'node:path';
+import { describe, expect, it } from 'vitest';
+import { platform } from '../../src/platform/node';
+
+const invertAsciiCase = (value: string): string =>
+ [...value]
+ .map(character => {
+ const upper = character.toUpperCase();
+ return character === upper ? character.toLowerCase() : upper;
+ })
+ .join('');
+
+describe('node platform filesystem case detection', () => {
+ it('detects the target filesystem for existing and not-yet-created paths', () => {
+ const root = mkdtempSync(path.join(os.tmpdir(), 'composio-case-sensitivity-'));
+ try {
+ const probeDirectory = path.join(root, 'CaseProbe');
+ mkdirSync(probeDirectory);
+ const existingFile = path.join(probeDirectory, 'config.json');
+ writeFileSync(existingFile, '{}');
+
+ const caseVariantExists = existsSync(path.join(root, invertAsciiCase('CaseProbe')));
+ const expected = !caseVariantExists;
+
+ expect(platform.isFileSystemCaseSensitive(existingFile)).toBe(expected);
+ expect(
+ platform.isFileSystemCaseSensitive(
+ path.join(probeDirectory, 'not-created-yet', 'config.json')
+ )
+ ).toBe(expected);
+ } finally {
+ rmSync(root, { recursive: true, force: true });
+ }
+ });
+});
diff --git a/ts/packages/core/test/platform/workerd.test.ts b/ts/packages/core/test/platform/workerd.test.ts
index 7832e5f3c..7f4b6747e 100644
--- a/ts/packages/core/test/platform/workerd.test.ts
+++ b/ts/packages/core/test/platform/workerd.test.ts
@@ -87,6 +87,10 @@ describe('workerd platform path helpers (js/polynomial-redos regression)', () =>
expect(platform.joinPath(allSlashes, `${allSlashes}name.txt${allSlashes}`)).toBe('name.txt');
});
+ it('preserves exact path matching when no filesystem is available', () => {
+ expect(platform.isFileSystemCaseSensitive('/virtual/.Kube/config')).toBe(true);
+ });
+
it('rejects backtracking-prone slash-trim regexes at the source level', () => {
const source = readFileSync(WORKERD_SOURCE, 'utf8');
// Matches an escaped slash immediately followed by a `+`/`*` or a
diff --git a/ts/packages/core/test/utils/sensitiveFileUploadPaths.test.ts b/ts/packages/core/test/utils/sensitiveFileUploadPaths.test.ts
index bf52eff0a..011e7192b 100644
--- a/ts/packages/core/test/utils/sensitiveFileUploadPaths.test.ts
+++ b/ts/packages/core/test/utils/sensitiveFileUploadPaths.test.ts
@@ -1,4 +1,4 @@
-import { describe, it, expect } from 'vitest';
+import { afterEach, describe, it, expect, vi } from 'vitest';
import * as path from 'node:path';
import * as os from 'node:os';
import { mkdtempSync, writeFileSync, symlinkSync, rmSync, mkdirSync } from 'node:fs';
@@ -6,9 +6,14 @@ import {
assertSafeFileUploadPath,
isBlockedSensitiveFileUploadPath,
} from '../../src/utils/sensitiveFileUploadPaths';
+import { platform } from '../../src/platform/node';
import * as publicApi from '../../src';
describe('sensitiveFileUploadPaths', () => {
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
it('allows normal project files', () => {
const p = path.join('/tmp', 'composio-test', 'document.pdf');
expect(isBlockedSensitiveFileUploadPath(p)).toBe(false);
@@ -49,6 +54,22 @@ describe('sensitiveFileUploadPaths', () => {
);
});
+ it('matches deny segments without case on a case-insensitive filesystem', () => {
+ vi.spyOn(platform, 'isFileSystemCaseSensitive').mockReturnValue(false);
+
+ expect(isBlockedSensitiveFileUploadPath('/Users/me/.Kube/config')).toBe(true);
+ expect(isBlockedSensitiveFileUploadPath('/data/Secrets/x.txt', ['secrets'])).toBe(true);
+ });
+
+ it('preserves distinct segment casing on a case-sensitive filesystem', () => {
+ vi.spyOn(platform, 'isFileSystemCaseSensitive').mockReturnValue(true);
+
+ expect(isBlockedSensitiveFileUploadPath('/home/me/.kube/config')).toBe(true);
+ expect(isBlockedSensitiveFileUploadPath('/home/me/.Kube/config')).toBe(false);
+ expect(isBlockedSensitiveFileUploadPath('/data/secrets/x.txt', ['secrets'])).toBe(true);
+ expect(isBlockedSensitiveFileUploadPath('/data/Secrets/x.txt', ['secrets'])).toBe(false);
+ });
+
it('is re-exported from the package root for downstream consumers (e.g. @composio/cli)', () => {
// The CLI imports the guard from `@composio/core` to share this one denylist
// (issue #3746). Lock the public surface so a refactor cannot silently drop it.
diff --git a/ts/packages/slim/package.json b/ts/packages/slim/package.json
index ac188f042..31ef930d2 100644
--- a/ts/packages/slim/package.json
+++ b/ts/packages/slim/package.json
@@ -107,6 +107,7 @@
"@composio/client": "catalog:",
"@composio/json-schema-to-zod": "workspace:*",
"@types/json-schema": "^7.0.15",
+ "is-fs-case-sensitive": "^2.0.0",
"openai": "catalog:",
"picocolors": "catalog:",
"pusher-js": "^8.6.0",