Title: fix(security): cap KB document download size to prevent memory-exhaustion DoS by waleedlatif1 · Pull Request #5240 · simstudioai/sim · GitHub
Open Graph Title: fix(security): cap KB document download size to prevent memory-exhaustion DoS by waleedlatif1 · Pull Request #5240 · simstudioai/sim
X Title: fix(security): cap KB document download size to prevent memory-exhaustion DoS by waleedlatif1 · Pull Request #5240 · simstudioai/sim
Description: Summary Knowledge-base document ingestion downloaded an attacker-controlled external fileUrl server-side with no byte cap: downloadFileWithTimeout → downloadFileFromUrl was called without maxBytes, which defaults to Number.MAX_SAFE_INTEGER, so the entire response body was buffered into the processing worker's memory uncapped. Any authenticated user with a KB they own could OOM the worker by pointing fileUrl at a server that streams an unbounded body (memory-exhaustion DoS, CWE-400/CWE-770). Fix: wire the documented 100MB file-size limit (MAX_FILE_SIZE, the same constant the KB upload path enforces) into the single ingestion download helper. All four KB download call sites route through it. The existing stream limiter rejects up front on an oversized Content-Length and aborts the read mid-stream once the cap is exceeded, so the body is never fully buffered. Type of Change Bug fix (security) Testing tsc clean (only pre-existing unrelated tailwind.config.ts error), biome clean, bun run check:api-validation passed. Reviewed all KB ingestion download paths (PDF page-count check, cloud-upload-for-OCR, base64-for-OCR, parseHttpFile) — all funnel through the capped helper. Notes Scoped to the reported KB ingestion vuln. The same DoS class exists in two executor callers (lib/execution/files.ts post-buffer check, executor/utils/file-tool-processor.ts no cap) plus the unbounded default in downloadFileFromUrl — tracked for a separate follow-up PR. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
Open Graph Description: Summary Knowledge-base document ingestion downloaded an attacker-controlled external fileUrl server-side with no byte cap: downloadFileWithTimeout → downloadFileFromUrl was called without maxBytes...
X Description: Summary Knowledge-base document ingestion downloaded an attacker-controlled external fileUrl server-side with no byte cap: downloadFileWithTimeout → downloadFileFromUrl was called without maxBytes...
Opengraph URL: https://github.com/simstudioai/sim/pull/5240
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:3aab04ac-a592-1918-6892-6c2555908f28 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8DD2:3FAE84:B11219:F352B7:6AFB52C0 |
| html-safe-nonce | 69c552bbed32ce6a030fb927678687882dc72c157b891ee40d4f599f9583454e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4REQyOjNGQUU4NDpCMTEyMTk6RjM1MkI3OjZBRkI1MkMwIiwidmlzaXRvcl9pZCI6IjQ2MTI5OTEzMDgwMjgxMzgxNzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3ee00f248b0280c6197b819fe38c15e2a920559c46d428eb01c7f2e7ea6a629b |
| hovercard-subject-tag | pull_request:3948673586 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/5240/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary Knowledge-base document ingestion downloaded an attacker-controlled external fileUrl server-side with no byte cap: downloadFileWithTimeout → downloadFileFromUrl was called without maxBytes... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cbf66c024bb6d10e6955baa7413c54cf13a201bb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width