X Tutup
Skip to content

MNT: Restrict webagg toolbar actions to valid actions#31294

Merged
QuLogic merged 3 commits intomatplotlib:mainfrom
scottshambaugh:webagg_cross_origin
Mar 13, 2026
Merged

MNT: Restrict webagg toolbar actions to valid actions#31294
QuLogic merged 3 commits intomatplotlib:mainfrom
scottshambaugh:webagg_cross_origin

Conversation

@scottshambaugh
Copy link
Copy Markdown
Contributor

@scottshambaugh scottshambaugh commented Mar 12, 2026

PR summary

The WebAgg backend starts a local Tornado web server with no origin checking on its WebSocket handler and an open getattr dispatch for toolbar actions. This means any webpage a user visits while WebAgg is running can silently connect to the server, receive figure image data, and invoke arbitrary zero-argument methods on the toolbar object.

The good news is that I believe this is sandboxed to the figure window & its methods, and does not allows for arbitrary code execution. So the blast radius is pretty limited. @tacaswell FYI

This adds origin checking to the websocket handler, to ensure all requests are coming from the webagg server hosting the figure. And it restricts the toolbar button dispatch to only allow acting on the actual toolbar buttons.

AI Disclosure

Claude authored, manually reviewed.

PR checklist

@scottshambaugh scottshambaugh added the Security Hardening Proactive security hardening. Existing vulnerabilities should be reported per our security policy label Mar 12, 2026
@scottshambaugh scottshambaugh force-pushed the webagg_cross_origin branch 3 times, most recently from ba73df8 to f1f0da8 Compare March 13, 2026 00:59
@tacaswell tacaswell added this to the v3.11.0 milestone Mar 13, 2026
@tacaswell
Copy link
Copy Markdown
Member

I'm 👍🏻 on the toolbar change, but confused by the CORS change as I think tornando defaults to locked down.

@scottshambaugh scottshambaugh removed the Security Hardening Proactive security hardening. Existing vulnerabilities should be reported per our security policy label Mar 13, 2026
@scottshambaugh scottshambaugh changed the title SEC: Prevent webagg cross-origin connections MNT: Restrict webagg toolbar actions to valid actions Mar 13, 2026
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
@QuLogic QuLogic merged commit 32805b1 into matplotlib:main Mar 13, 2026
37 of 40 checks passed
andreas16700 added a commit to andreas16700/matplotlib that referenced this pull request Mar 16, 2026
andreas16700 added a commit to andreas16700/matplotlib that referenced this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup