Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(security): patch body-parser crash in Node services (#5348)

Abimael Martell4990a8e27ac7
diff --git a/apps/api/package.json b/apps/api/package.json
index 4d36b3983..48747c2a5 100644
--- a/apps/api/package.json
+++ b/apps/api/package.json
@@ -102,7 +102,7 @@
"async-mutex": "^0.5.0",
"autumn-js": "1.2.55",
"axios": "^1.20.0",
- "body-parser": "^1.20.6",
+ "body-parser": "^1.20.9",
"bullmq": "^5.56.7",
"cacheable-lookup": "^6.1.0",
"cheerio": "^1.0.0-rc.12",
diff --git a/apps/api/pnpm-lock.yaml b/apps/api/pnpm-lock.yaml
index 559f87138..dadf25b00 100644
--- a/apps/api/pnpm-lock.yaml
+++ b/apps/api/pnpm-lock.yaml
@@ -6,6 +6,8 @@ settings:
injectWorkspacePackages: true
overrides:
+ body-parser@<1.20.9: 1.20.9
+ body-parser@>=2.0.0 <2.4.0: 2.4.0
'@types/express': ^5.0.6
vite@>=8.0.0 <8.1.6: 8.1.6
bigint-buffer: npm:[email protected]
@@ -155,8 +157,8 @@ importers:
specifier: ^1.20.0
version: 1.20.0
body-parser:
- specifier: ^1.20.6
- version: 1.20.6
+ specifier: ^1.20.9
+ version: 1.20.9
bullmq:
specifier: ^5.56.7
version: 5.56.7
@@ -2452,12 +2454,12 @@ packages:
resolution: {integrity: sha512-VOMgTMwjAaUG580SXn3LacVgjurrbMme7ZZNYGSSV7mmtY6QQRh0Eg3pwIcntQ77DErK1L0NxkbetjcoXzVwKw==}
- resolution: {integrity: sha512-p5tAzS57i5MV9fZFDj9LeIiTZEufbSe2eDozP+ElheSUq1m74CRq1jI4mYNDdVs9vQztXFLuk/Gd6BWTdwRJ5g==}
+ resolution: {integrity: sha512-FISIQxV5u91Y9gvuFq3q/tA/qTqLJn3AhRcEvyozyhJTh5OBFFtv827AdHU7Rbyct4r+Ba1/99oFa1Y3yuFsdw==}
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
- resolution: {integrity: sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==}
+ resolution: {integrity: sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==}
engines: {node: '>=18'}
@@ -2600,6 +2602,10 @@ packages:
resolution: {integrity: sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==}
+ engines: {node: '>=18'}
+
resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
@@ -4043,6 +4049,10 @@ packages:
resolution: {integrity: sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==}
engines: {node: '>=0.6'}
+ resolution: {integrity: sha512-5Px6J7rfHBAGUhNQ3es4YzcOdBBw0SDcVtThJml4RdnKw4tKs2epA0kPZ+K8X+WiHktT93RHVcQ/3ym5aTCgtg==}
+ engines: {node: '>=0.6'}
+
resolution: {integrity: sha512-YlJmwNyi0RGYjlxYcuDncMsxFU7YyutbuI7gTm8ySxIGBlwx5yiBCOD5ig9ZNoHkawk/1Dey0N5mEfcUybMVAA==}
engines: {node: '>=18'}
@@ -6502,7 +6512,7 @@ snapshots:
dependencies:
bytes: 3.1.2
content-type: 1.0.5
@@ -6519,15 +6529,15 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
bytes: 3.1.2
- content-type: 2.0.0
+ content-type: 2.1.0
debug: 4.4.3
http-errors: 2.0.1
iconv-lite: 0.7.3
on-finished: 2.4.1
- qs: 6.16.0
+ qs: 6.16.1
raw-body: 3.0.2
type-is: 2.1.0
transitivePeerDependencies:
@@ -6683,6 +6693,8 @@ snapshots:
+
@@ -6947,7 +6959,7 @@ snapshots:
dependencies:
accepts: 2.0.0
- body-parser: 2.3.0
+ body-parser: 2.4.0
content-disposition: 1.1.0
content-type: 1.0.5
cookie: 0.7.1
@@ -8096,6 +8108,11 @@ snapshots:
es-define-property: 1.0.1
side-channel: 1.1.1
+ dependencies:
+ es-define-property: 1.0.1
+ side-channel: 1.1.1
+
dependencies:
decode-uri-component: 0.5.0
diff --git a/apps/api/pnpm-workspace.yaml b/apps/api/pnpm-workspace.yaml
index 94d968cdb..5f4e96f5f 100644
--- a/apps/api/pnpm-workspace.yaml
+++ b/apps/api/pnpm-workspace.yaml
@@ -3,6 +3,8 @@ packages:
injectWorkspacePackages: true
minimumReleaseAge: 720 # 12 hours
minimumReleaseAgeExclude:
+ # GHSA-27r3-jxmh-p828: allow today's patched releases through the age gate.
+ - "[email protected] || 2.4.0"
- fast-xml-parser
- follow-redirects
# TypeScript 7 resolves its native platform binaries (e.g.
@@ -12,6 +14,9 @@ minimumReleaseAgeExclude:
- "@typescript/typescript6"
- "@typescript/typescript-*"
overrides:
+ # GHSA-27r3-jxmh-p828: Express 5.2.1 also loads body-parser 2.x.
+ "body-parser@<1.20.9": "1.20.9"
+ "body-parser@>=2.0.0 <2.4.0": "2.4.0"
"@types/express": "^5.0.6"
# GHSA-698v-4r3x-3vcv: pin the 8.0 and 8.1 lines to 8.1.6. Cannot resolve to 8.2+.
"vite@>=8.0.0 <8.1.6": "8.1.6"
diff --git a/apps/api/src/__tests__/snips/v2/express5.test.ts b/apps/api/src/__tests__/snips/v2/express5.test.ts
index 6c9af6a1f..76412da67 100644
--- a/apps/api/src/__tests__/snips/v2/express5.test.ts
+++ b/apps/api/src/__tests__/snips/v2/express5.test.ts
@@ -1,4 +1,6 @@
import request, { TEST_API_URL, idmux, Identity } from "./lib";
+import http from "node:http";
+import { gzipSync } from "node:zlib";
let identity: Identity;
@@ -35,6 +37,64 @@ describe("Express 5 compatibility", () => {
});
});
+ const localApi = ["localhost", "127.0.0.1"].includes(
+ new URL(TEST_API_URL).hostname,
+ );
+
+ (localApi ? it : it.skip)(
+ "keeps serving requests after a gzip body with trailing bytes",
+ async () => {
+ const gzipBody = gzipSync(Buffer.from('{"ok":true}'));
+ const bodyWithTrailingBytes = Buffer.concat([
+ gzipBody,
+ Buffer.from([0x00]),
+ Buffer.alloc(100 * 1024, 0x58),
+ ]);
+ const headers = {
+ "Content-Type": "application/json",
+ "Content-Encoding": "gzip",
+ };
+
+ const valid = await fetch(`${TEST_API_URL}/e2e-test`, {
+ method: "POST",
+ headers,
+ body: gzipBody,
+ });
+ expect(valid.status).toBeGreaterThanOrEqual(400);
+ expect(valid.status).toBeLessThan(500);
+ await valid.arrayBuffer();
+
+ // Send raw bytes so the gzip decoder can finish before the trailing bytes
+ // arrive. The older body-parser responded, then crashed the process.
+ const responseStatus = await new Promise<number>((resolve, reject) => {
+ const req = http.request(
+ new URL("/e2e-test", TEST_API_URL),
+ {
+ method: "POST",
+ headers: {
+ ...headers,
+ "Content-Length": bodyWithTrailingBytes.length,
+ },
+ },
+ res => {
+ res.resume();
+ res.on("end", () => resolve(res.statusCode ?? 0));
+ res.on("error", reject);
+ },
+ );
+ req.on("error", reject);
+ req.setTimeout(5000, () => req.destroy(new Error("Request timed out")));
+ req.end(bodyWithTrailingBytes);
+ });
+ expect(responseStatus).toBe(valid.status);
+
+ // The vulnerable parser can crash after sending a response.
+ await new Promise(resolve => setTimeout(resolve, 200));
+ const liveness = await request(TEST_API_URL).get("/e2e-test");
+ expect(liveness.statusCode).toBe(200);
+ },
+ );
+
it("still captures route params before validation middleware", async () => {
const response = await request(TEST_API_URL)
.get("/v2/crawl/not-a-uuid")
diff --git a/apps/playwright-service-ts/pnpm-lock.yaml b/apps/playwright-service-ts/pnpm-lock.yaml
index d4901163f..9998c8c3e 100644
--- a/apps/playwright-service-ts/pnpm-lock.yaml
+++ b/apps/playwright-service-ts/pnpm-lock.yaml
@@ -5,7 +5,7 @@ settings:
excludeLinksFromLockfile: false
overrides:
- body-parser@>=2.0.0 <2.3.0: 2.3.0
+ body-parser@>=2.0.0 <2.4.0: 2.4.0
path-to-regexp@<8.4.0: '>=8.4.0'
qs@<6.16.0: '>=6.16.0 <7.0.0'
esbuild@>=0.17.0 <0.28.1: 0.28.1
@@ -253,8 +253,8 @@ packages:
resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==}
engines: {node: '>= 14'}
- resolution: {integrity: sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==}
+ resolution: {integrity: sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==}
engines: {node: '>=18'}
@@ -281,6 +281,10 @@ packages:
resolution: {integrity: sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==}
+ engines: {node: '>=18'}
+
resolution: {integrity: sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==}
engines: {node: '>=6.6.0'}
@@ -396,6 +400,10 @@ packages:
resolution: {integrity: sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==}
engines: {node: '>=0.10.0'}
+ resolution: {integrity: sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==}
+ engines: {node: '>=0.10.0'}
+
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
@@ -488,6 +496,10 @@ packages:
resolution: {integrity: sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==}
engines: {node: '>=0.6'}
+ resolution: {integrity: sha512-5Px6J7rfHBAGUhNQ3es4YzcOdBBw0SDcVtThJml4RdnKw4tKs2epA0kPZ+K8X+WiHktT93RHVcQ/3ym5aTCgtg==}
+ engines: {node: '>=0.6'}
+
resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==}
engines: {node: '>= 0.6'}
@@ -728,15 +740,15 @@ snapshots:
dependencies:
bytes: 3.1.2
- content-type: 2.0.0
+ content-type: 2.1.0
debug: 4.4.3
http-errors: 2.0.1
- iconv-lite: 0.7.2
+ iconv-lite: 0.7.3
on-finished: 2.4.1
- qs: 6.16.0
+ qs: 6.16.1
raw-body: 3.0.2
type-is: 2.1.0
transitivePeerDependencies:
@@ -760,6 +772,8 @@ snapshots:
+
@@ -826,7 +840,7 @@ snapshots:
dependencies:
accepts: 2.0.0
- body-parser: 2.3.0
+ body-parser: 2.4.0
content-disposition: 1.0.1
content-type: 1.0.5
cookie: 0.7.1
@@ -921,6 +935,10 @@ snapshots:
dependencies:
safer-buffer: 2.1.2
+ dependencies:
+ safer-buffer: 2.1.2
+
@@ -989,6 +1007,11 @@ snapshots:
es-define-property: 1.0.1
side-channel: 1.1.1
+ dependencies:
+ es-define-property: 1.0.1
+ side-channel: 1.1.1
+
diff --git a/apps/playwright-service-ts/pnpm-workspace.yaml b/apps/playwright-service-ts/pnpm-workspace.yaml
index e29199c1e..b2eeaa230 100644
--- a/apps/playwright-service-ts/pnpm-workspace.yaml
+++ b/apps/playwright-service-ts/pnpm-workspace.yaml
@@ -1,7 +1,10 @@
allowBuilds:
esbuild: true
+minimumReleaseAgeExclude:
+ # GHSA-27r3-jxmh-p828: allow today's patched release through the age gate.
overrides:
- "body-parser@>=2.0.0 <2.3.0": "2.3.0"
+ "body-parser@>=2.0.0 <2.4.0": "2.4.0"
"path-to-regexp@<8.4.0": ">=8.4.0"
"qs@<6.16.0": ">=6.16.0 <7.0.0"
"esbuild@>=0.17.0 <0.28.1": "0.28.1"