Skip to content

Commit 64699af

Browse files
committed
fix(sdk,core): unblock CI on PR #3173
- typesVersions: add `ai/skills-runtime` mapping (was missing → check-exports failed with NoResolution on `@trigger.dev/sdk/ai/skills-runtime`). - chat.store JSON Patch: reject `__proto__`, `constructor`, `prototype` segments at parseJsonPointer. Closes the two CodeQL prototype-pollution alerts on chat-client.ts:108 / :120 — a malicious patch like `{ op: "replace", path: "/__proto__/x", value: 1 }` would otherwise walk into Object.prototype via `parent[lastToken] = value`. Throws a clear error on the whole patch instead.
1 parent bc751bd commit 64699af

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

packages/core/src/v3/chat-client.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,27 @@ export type ChatStoreChunk = ChatStoreSnapshotChunk | ChatStoreDeltaChunk;
4949
// JSON Pointer paths. Used by `chat.store.patch()` on the agent and
5050
// the matching client-side `applyStorePatch` on the transport.
5151

52+
// Reject these segments at the parser to prevent prototype pollution: a
53+
// malicious patch like `{ op: "replace", path: "/__proto__/polluted", value: 1 }`
54+
// would otherwise mutate Object.prototype. Patches with these keys aren't
55+
// legitimate for chat.store, so reject the whole patch with a clear error.
56+
const FORBIDDEN_POINTER_SEGMENTS = new Set(["__proto__", "constructor", "prototype"]);
57+
5258
function parseJsonPointer(path: string): string[] {
5359
if (path === "") return [];
5460
if (!path.startsWith("/")) {
5561
throw new Error(`Invalid JSON Pointer (must start with "/"): ${path}`);
5662
}
57-
return path
63+
const tokens = path
5864
.slice(1)
5965
.split("/")
6066
.map((segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~"));
67+
for (const token of tokens) {
68+
if (FORBIDDEN_POINTER_SEGMENTS.has(token)) {
69+
throw new Error(`Invalid JSON Pointer segment "${token}" in path "${path}"`);
70+
}
71+
}
72+
return tokens;
6173
}
6274

6375
function cloneValue<T>(value: T): T {

packages/trigger-sdk/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
"ai": [
4343
"dist/commonjs/v3/ai.d.ts"
4444
],
45+
"ai/skills-runtime": [
46+
"dist/commonjs/v3/agentSkillsRuntime.d.ts"
47+
],
4548
"ai/test": [
4649
"dist/commonjs/v3/test/index.d.ts"
4750
],

0 commit comments

Comments
 (0)