Title: fix(file-parsers): guard .doc uploads against zip-bomb memory exhaustion by waleedlatif1 · Pull Request #6166 · simstudioai/sim · GitHub
Open Graph Title: fix(file-parsers): guard .doc uploads against zip-bomb memory exhaustion by waleedlatif1 · Pull Request #6166 · simstudioai/sim
X Title: fix(file-parsers): guard .doc uploads against zip-bomb memory exhaustion by waleedlatif1 · Pull Request #6166 · simstudioai/sim
Description: Summary Closes a zip-bomb memory-exhaustion path on document upload, in two parts. 1. .doc skipped the guard entirely. DocParser handed the raw upload straight to officeparser and then mammoth, without the assertOoxmlArchiveWithinLimits call its docx/pptx/xlsx siblings all make. The extension is only a routing hint — both libraries accept an OOXML container regardless of its name — so a bomb renamed .doc selected the unguarded parser and bypassed the guard that catches the identical bytes as .docx. The guard is now the first act of DocParser.parseBuffer, and is also enforced centrally in lib/file-parsers parseBuffer so a future parser can't silently opt out. 2. The guard itself was bypassable by lying. The declared uncompressed sizes live in the ZIP central directory, which is attacker-controlled. Under-report them and the size and ratio checks pass untouched; officeparser/mammoth only notice the mismatch after inflating each entry in full. Measured on a 498 KB archive declaring 1000 bytes per entry: parser before after .doc +559 MB resident +0 MB, rejected in 2 ms .docx +538 MB resident +0 MB, rejected in 1 ms .xlsx / .pptx +11 / +4 MB (container rejected early) +0 MB Every entry is now inflated during verification under a maxOutputLength bound equal to the size it declared. Node's zlib aborts the moment output would exceed that bound, so a lying entry costs only its declared size and the bytes are discarded immediately. Stored entries are checked against their own compressed size; unsupported compression methods fail closed. Verification walks the contiguous run of central-directory records rather than the EOCD's declared count, since that run is what a decompression library actually allocates per entry — a lied-down count must not hide an entry from verification. No limits changed: this reuses the existing DEFAULT_OOXML_SIZE_LIMITS all four parsers already ship against. Type of Change Bug fix (security — resource exhaustion / DoS) Testing Both bomb variants (honest and under-declared) are now rejected at +0 MB across .doc, .docx, .xlsx, .pptx, and .txt. Verified the new tests go red when the verification pass is disabled (4 fail) and when the .doc guard call is removed (3 fail). No false positives, checked against real files rather than only synthetic ones: 17/17 real Word-produced .docx fixtures from mammoth's test data still accepted txt / md / json / yaml / csv / html, valid OOXML as .docx/.doc/.pptx, and legacy OLE .doc all parse unchanged 0/2000 random buffers rejected; PDF, OLE, and BOM-text magic all pass maxOutputLength boundary confirmed to accept output equal to the cap, so honest archives are never rejected Cost: ~0.45 ms per MB of uncompressed content (1.4 ms @ 1 MB, 5.3 ms @ 10 MB, 22 ms @ 50 MB), against parse times an order of magnitude larger. The declared-size check still runs first, so a straightforward bomb is rejected at zero cost. Gates: tsc clean, check:api-validation passed, biome clean, 61 file-parser tests plus 1495 tests across uploads / knowledge / files API / copilot. (8 lib/copilot/** test files fail to collect on a PostCSS/Tailwind config error — confirmed identical with this branch's changes fully reverted, so pre-existing and unrelated.) 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 Closes a zip-bomb memory-exhaustion path on document upload, in two parts. 1. .doc skipped the guard entirely. DocParser handed the raw upload straight to officeparser and then mammoth, wit...
X Description: Summary Closes a zip-bomb memory-exhaustion path on document upload, in two parts. 1. .doc skipped the guard entirely. DocParser handed the raw upload straight to officeparser and then mammoth, wit...
Opengraph URL: https://github.com/simstudioai/sim/pull/6166
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:e04b0697-1942-0215-1a9b-fef7cbecb8a5 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B6C6:1EE905:506367:7264CF:6AFB405C |
| html-safe-nonce | 1b69c08329a7070f9a9f77cd12032f2bf30cec68a99c47f851e0115e628a83d5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkM2OjFFRTkwNTo1MDYzNjc6NzI2NENGOjZBRkI0MDVDIiwidmlzaXRvcl9pZCI6IjQwMDU2NTExMTk1NTA5NzE5OTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e0080ee58b2439bc9a3c13a88a89cfe6c82a6cb9eba514fc7954d1a215224bad |
| hovercard-subject-tag | pull_request:4185063307 |
| 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/6166/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 Closes a zip-bomb memory-exhaustion path on document upload, in two parts. 1. .doc skipped the guard entirely. DocParser handed the raw upload straight to officeparser and then mammoth, wit... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | d849b928f455c800985398e7f1b659425adb312a5fa14fba5d9a14e62e9fe5dd |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a6c2f87cbcb6414452377b4967858ed6a66f1109 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width