Skip to content

Commit 23e9269

Browse files
Skryptclaude
andcommitted
Fix type confusion through parameter tampering in DFS PathHandler
Guard against Express query params and request body being arrays instead of strings. CodeQL flagged req.query.position and req.body as potential vectors for type confusion in appendData and flushData. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 07b32a8 commit 23e9269

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/blob/dfs/handlers/PathHandler.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,14 @@ export default class PathHandler {
420420
const account = ctx.account || EMULATOR_ACCOUNT_NAME;
421421
const filesystem = ctx.filesystem!;
422422
const pathName = ctx.path!;
423-
const position = parseInt(req.query.position as string || "0", 10);
423+
const positionParam = Array.isArray(req.query.position)
424+
? req.query.position[0]
425+
: req.query.position;
426+
const position = parseInt(String(positionParam || "0"), 10);
424427

425428
try {
426-
const body = Buffer.isBuffer(req.body) ? req.body : Buffer.from(req.body || "");
429+
const rawBody = Array.isArray(req.body) ? Buffer.from(req.body) : req.body;
430+
const body = Buffer.isBuffer(rawBody) ? rawBody : Buffer.from(rawBody || "");
427431

428432
// Content-MD5 validation
429433
const contentMD5 = req.headers["content-md5"] as string | undefined;
@@ -487,7 +491,10 @@ export default class PathHandler {
487491
const account = ctx.account || EMULATOR_ACCOUNT_NAME;
488492
const filesystem = ctx.filesystem!;
489493
const pathName = ctx.path!;
490-
const position = parseInt(req.query.position as string || "0", 10);
494+
const flushPositionParam = Array.isArray(req.query.position)
495+
? req.query.position[0]
496+
: req.query.position;
497+
const position = parseInt(String(flushPositionParam || "0"), 10);
491498

492499
try {
493500
// Get current blob to find uncommitted blocks

0 commit comments

Comments
 (0)