Title: fix(media): stop the ffmpeg output format from choosing its own path by icecrasher321 · Pull Request #7001 · simstudioai/sim · GitHub
Open Graph Title: fix(media): stop the ffmpeg output format from choosing its own path by icecrasher321 · Pull Request #7001 · simstudioai/sim
X Title: fix(media): stop the ffmpeg output format from choosing its own path by icecrasher321 · Pull Request #7001 · simstudioai/sim
Description: Summary convert and extract_audio built their output path as path.join(dir, `out.${format}`), and format arrives from the tool as an unconstrained {"type": "string"} — no pattern, no enum — which the handler passes through untouched. A traversal in that string relocates the file FFmpeg writes. Verified against a real FFmpeg binary rather than reasoned about: format = "../../../../../../../../tmp/ffx-escaped.mp4" path.join(dir, "out." + format) -> /tmp/ffx-escaped.mp4 result: 44,078-byte MP4 written outside the temp directory The temp directory is removed with fs.rm(dir, { recursive: true, force: true }) afterwards, which never sees that file — it was never inside the directory being removed. So the write also outlives the cleanup that is supposed to bound this tool's filesystem footprint. The bytes are a transcode of a caller-supplied input, so the attacker influences the content as well as the destination, bounded only by what the app process can write. Reaching it needs nothing but workspace write permission, the same gate as the rest of the tool. Fix Output extensions are letters and digits only, up to 12 characters. Because the pattern admits no . and no separator, out.${ext} is always a single path segment — containment follows from the validation itself rather than from a second check that could drift away from it. Every ordinary target still works: mp4, mp3, webm, m4a, flac, opus, gif, mkv, and MP4 still lowercases before validating. What is deliberately not changed trim and fade also build paths from an extension, but theirs comes from extFromMime, which returns mime.split('/')[1] — that can never contain a separator, so those paths are already contained. Routing them through this stricter pattern would wrongly reject legitimate values like x-msvideo that the fallback produces for an unrecognized MIME type. Provenance Found while tracing a report that targeted escapeDrawtext and addText. That vulnerability is already fixed — #6734 replaced the inline caption with textfile= plus expansion=none, and escapeDrawtext no longer exists — but the report's observation that the tool's string parameters are unconstrained still held for format, which is a path rather than a filtergraph. Verification Six traversal cases pinned by tests — parent-relative, deep-relative, embedded .., absolute, and an embedded NUL — each confirmed to fail against the unfixed source before the fix was applied. Full suite: 1,789 tests across lib/copilot and lib/media, plus tsc --noEmit, lint:check, and the api-validation / boundaries / client-boundary / utils gates. Follow-ups, not in scope A -protocol_whitelist on FFmpeg inputs would stop a crafted input container from referencing external resources. No injection vector remains through the tool's own parameters, so this is defence in depth rather than a fix, and it needs care not to break the concat demuxer. concat is separately broken for any clip without an audio stream: it synthesizes silence with -f lavfi, but lavfi is a libavdevice device and fluent-ffmpeg validates -f against ffmpeg -formats, which does not list devices. Reproduced standalone; fix verified; wants its own PR. 🤖 Generated with Claude Code
Open Graph Description: Summary convert and extract_audio built their output path as path.join(dir, `out.${format}`), and format arrives from the tool as an unconstrained {"type": "string"} — no patter...
X Description: Summary convert and extract_audio built their output path as path.join(dir, `out.${format}`), and format arrives from the tool as an unconstrained {"type": "string&qu...
Opengraph URL: https://github.com/simstudioai/sim/pull/7001
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:a30ddd91-b614-a4da-2c92-3f32bd2eeb33 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A28A:305156:1139D:187AE:6AFB47D4 |
| html-safe-nonce | 62da0f4813a0958f471dcfda3fe753bc69bcc2a1cacbd70a1f32e39e66327601 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjhBOjMwNTE1NjoxMTM5RDoxODdBRTo2QUZCNDdENCIsInZpc2l0b3JfaWQiOiI4NjE2MDU3MzQ1MDk4MzM2MjEyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | aa6ff8fba6f75101cca1c0c024c87b28c8fe6b3d8a24a456c2f874bd18c6cf0b |
| hovercard-subject-tag | pull_request:4340285720 |
| 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/7001/files |
| twitter:image | https://avatars.githubusercontent.com/u/17950982?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/17950982?s=400&v=4 |
| og:image:alt | Summary convert and extract_audio built their output path as path.join(dir, `out.${format}`), and format arrives from the tool as an unconstrained {"type": "string"} — no patter... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | acf7616d06cc051644705b379878c9bb13dc5e70ecf4ffd9b34140f8ac01d7e1 |
| 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 | 26504db649b58525278f77a52b80ba5f10d5f4de |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width