fix[notask]: harden benchmark servers against RCE, path traversal, injection, DoS, and CSRF#1086
Merged
Merged
Conversation
…jection, DoS, and CSRF Security audit identified 5 vulnerabilities in the whispercpp and parakeet benchmark servers: 1. RCE via dynamic require() of user-controlled package name — add ALLOWED_LIBS allowlist to both runAddon.js files 2. Arbitrary file read via unsanitized inputs paths — add validateFilePath() that resolves and checks existence 3. CLI argument injection via crafted file paths — add path validation and -- separator in runAddon.cli.js ffmpeg args 4. No request body size limit in parakeet helper.js — add 1 MB cap matching the whisper server implementation 5. Wildcard CORS (Access-Control-Allow-Origin: *) — restrict to localhost/127.0.0.1 origins in both server.js files Made-with: Cursor
GustavoA1604
previously approved these changes
Mar 23, 2026
Contributor
Tier-based Approval Status |
Contributor
|
the hardening is incomplete. validateFilePath() still allows reading any existing file, the whisper version field still feeds npm install, and the ffmpeg -i -- file change is likely wrong. |
1. validateFilePath now restricts to ALLOWED_AUDIO_DIRS (cwd, models, examples) instead of just checking existence — prevents reading arbitrary files outside the benchmark directory 2. Remove ensurePackage/npm install entirely — the ALLOWED_LIBS check already prevents arbitrary packages, so just use getPackageVersion for version reporting on pre-installed packages 3. Revert ffmpeg -- syntax — -i expects the filename as immediate next arg, -- is not valid between a flag and its value 4. Remove unused spawn/version destructuring to fix lint errors Made-with: Cursor
GustavoA1604
approved these changes
Mar 24, 2026
ogad-tether
approved these changes
Mar 24, 2026
Contributor
Author
|
/review |
Contributor
Author
|
/review |
Proletter
pushed a commit
that referenced
this pull request
May 24, 2026
…jection, DoS, and CSRF (#1086) * fix[notask]: harden benchmark servers against RCE, path traversal, injection, DoS, and CSRF Security audit identified 5 vulnerabilities in the whispercpp and parakeet benchmark servers: 1. RCE via dynamic require() of user-controlled package name — add ALLOWED_LIBS allowlist to both runAddon.js files 2. Arbitrary file read via unsanitized inputs paths — add validateFilePath() that resolves and checks existence 3. CLI argument injection via crafted file paths — add path validation and -- separator in runAddon.cli.js ffmpeg args 4. No request body size limit in parakeet helper.js — add 1 MB cap matching the whisper server implementation 5. Wildcard CORS (Access-Control-Allow-Origin: *) — restrict to localhost/127.0.0.1 origins in both server.js files Made-with: Cursor * fix[notask]: address review feedback on benchmark server hardening 1. validateFilePath now restricts to ALLOWED_AUDIO_DIRS (cwd, models, examples) instead of just checking existence — prevents reading arbitrary files outside the benchmark directory 2. Remove ensurePackage/npm install entirely — the ALLOWED_LIBS check already prevents arbitrary packages, so just use getPackageVersion for version reporting on pre-installed packages 3. Revert ffmpeg -- syntax — -i expects the filename as immediate next arg, -- is not valid between a flag and its value 4. Remove unused spawn/version destructuring to fix lint errors Made-with: Cursor --------- Co-authored-by: Raju <raju.sharma>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Findings Addressed
1. 🔴 Critical — RCE via dynamic
require()of user-controlled package nameBoth
runAddon.jsfiles accepted a user-controlledlibfield, rannpm installon it, thenrequire()'d it. AddedALLOWED_LIBSallowlist — rejects any library not in the list beforeensurePackage()is called.2. 🔴 Critical — Arbitrary file read via user-controlled file paths
The
inputsarray andconfig.pathwere passed tofs.readFileSync()without validation. AddedvalidateFilePath()that resolves the path and verifies existence before any file I/O.3. :large_orange_circle: High — CLI argument injection in
runAddon.cli.jsUser-supplied file paths were passed directly to
spawn('ffmpeg', ...). AddedvalidatePath()+--argument separator to prevent flag injection, and fixed.replace('.raw', '.wav')to use regex anchor\.raw$.4. :large_orange_circle: High — No request body size limit in parakeet
helper.jsThe parakeet server's
processJsonRequest()had no size limit (the whisper server already had one). Added 1 MB cap matching the whisper implementation.5. :large_orange_circle: High — Wildcard CORS (
Access-Control-Allow-Origin: *)Both servers allowed any origin. Replaced with dynamic origin validation that only allows
localhostand127.0.0.1origins, withVary: Originheader.Files Changed (6)
whispercpp/benchmarks/server/src/services/runAddon.jswhispercpp/benchmarks/server/src/services/runAddon.cli.jswhispercpp/benchmarks/server/src/server.jsparakeet/benchmarks/server/src/services/runAddon.jsparakeet/benchmarks/server/src/server.jsparakeet/benchmarks/server/src/utils/helper.jsHow was it tested?
whispercpp-filesystem.tsproduces identical outputstandardlinter with zero errorsMade with Cursor