Title: fix(charts): confine untrusted chart options to canvas render paths by icecrasher321 · Pull Request #6998 · simstudioai/sim · GitHub
Open Graph Title: fix(charts): confine untrusted chart options to canvas render paths by icecrasher321 · Pull Request #6998 · simstudioai/sim
X Title: fix(charts): confine untrusted chart options to canvas render paths by icecrasher321 · Pull Request #6998 · simstudioai/sim
Description: Summary
parseChartSpec forwarded a .chart document's option to setOption unchanged. A .chart file is untrusted input — any workspace member authors one, and a public share link renders it to anonymous visitors on the app origin — so a string tooltip.formatter reached ECharts' innerHTML sink as stored XSS.
ECharts draws through canvas with two exceptions: a tooltip left in its default renderMode: 'html' assigns its content to innerHTML, and a string formatter is that content's template verbatim (only substituted values are escaped); toolbox assigns dataView.lang to innerHTML and fills a saveAsImage popup with document.write. Both are now closed at the parse boundary, so the document has no DOM sink at all — rather than filtering the values that flow through one.
The walk is deep because a top-level fix is provably incomplete: baseOption, media[].option and timeline options[] each carry their own tooltip, a tooltip declared only under media still instantiates the component in HTML mode, and a media entry can override a top-level renderMode.
Escaped the series name in the pptx chart renderer's bubble tooltip — same sink, different door. It comes from the uploaded document and is interpolated into a hand-built innerHTML string; every other tooltip there leaves the markup to ECharts, which escapes it. Used encodeHTML rather than the render mode because Sim owns that formatter and only the values are untrusted.
Deliberately did not restrict contentType on file creation: resolvePreviewType falls back to the .chart extension, so it closes nothing and would reject legitimate types.
renderMode: 'richText' is ECharts' own documented injection-safe mode. One behavior note: HTML inside an author's formatter string (
, ) now renders as literal text. Templates ({b}: {c}), default tooltips and markers are unaffected — ECharts builds those per-mode.
Side effect: a document nested deeply enough to exhaust the stack already crashed the render (structuredClone in buildChartRenderOption throws on it). It's now rejected at parse, so it shows the document's error card instead of failing inside the render.
Type of Change
Bug fix
Testing
20 new tests in lib/charts/spec.test.ts, including two that render through real ECharts in SSR mode and assert the resolved model — a version bump that breaks the renderMode assumption fails loudly instead of silently reopening the hole
bun run test lib/charts lib/pptx-renderer app/workspace/[workspaceId]/files — 801 passing
type-check, lint, check:block-registry and check:audits (33 audits, incl. check:api-validation:strict) all clean
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 parseChartSpec forwarded a .chart document's option to setOption unchanged. A .chart file is untrusted input — any workspace member authors one, and a public share link renders it to a...
X Description: Summary parseChartSpec forwarded a .chart document's option to setOption unchanged. A .chart file is untrusted input — any workspace member authors one, and a public share link renders it ...
Opengraph URL: https://github.com/simstudioai/sim/pull/6998
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:4856979c-6aea-791f-6aa0-1b29e683e738 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C2CA:2F2AB3:D20CEC:120FF1B:6AFB59C4 |
| html-safe-nonce | f088e077daec1b3fd471f44aefac9a6804fdf0326824b832b25951f79f76cba5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMkNBOjJGMkFCMzpEMjBDRUM6MTIwRkYxQjo2QUZCNTlDNCIsInZpc2l0b3JfaWQiOiIyNzI3NTUxODQ4MjA5NDA2NDA0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7f3656f185300b55926610558021f6ccfed4089b2891963c910c5252f2e2d615 |
| hovercard-subject-tag | pull_request:4340226423 |
| 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/6998/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 parseChartSpec forwarded a .chart document's option to setOption unchanged. A .chart file is untrusted input — any workspace member authors one, and a public share link renders it to a... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ea33d13c96d0ff66bd8fa906b193d2213536b78cb06b0c50a4632c58b1418f94 |
| 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 | 59ef97164c52cf59bd10558ddec9c4f482763988 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width