SEC: Block shell escapes in latex and ps commands by scottshambaugh · Pull Request #31282 · matplotlib/matplotlib · GitHub
Skip to content

SEC: Block shell escapes in latex and ps commands#31282

Merged
WeatherGod merged 1 commit into
matplotlib:mainfrom
scottshambaugh:tex_no_shell
Mar 13, 2026
Merged

SEC: Block shell escapes in latex and ps commands#31282
WeatherGod merged 1 commit into
matplotlib:mainfrom
scottshambaugh:tex_no_shell

Conversation

@scottshambaugh

@scottshambaugh scottshambaugh commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

PR summary

See the discussion in #31249

This blocks our LaTeX and ps commands from arbitrary code execution in the shell:

AI Disclosure

Claude used for the audit (found a few more spots to hit!), code manually reviewed

PR checklist

@scottshambaugh scottshambaugh added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Mar 11, 2026
Comment thread lib/matplotlib/backends/backend_ps.py
Comment thread lib/matplotlib/texmanager.py Outdated
@tacaswell

Copy link
Copy Markdown
Member

@tacaswell tacaswell added this to the v3.11.0 milestone Mar 11, 2026
@scottshambaugh

Copy link
Copy Markdown
Contributor Author

It's possible switching away from -R0 breaks something, but we should fix it some other way should that be the case.

@tacaswell tacaswell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am indifferent to settling on one or two - on latex cli args or leaving as-is.

@scottshambaugh scottshambaugh added the Security Hardening Proactive security hardening. Existing vulnerabilities should be reported per our security policy label Mar 12, 2026
@WeatherGod

Copy link
Copy Markdown
Member

In principle, I approve these changes, but I don't know if the test failure is one of the spurious failures or actually related to these changes.

@tacaswell

Copy link
Copy Markdown
Member

Someone must have re-run them, I'm only seeing a codecov failures but it is short an upload so I am not worried.

@WeatherGod WeatherGod merged commit 8ff895d into matplotlib:main Mar 13, 2026
63 of 67 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
@ksunden

ksunden commented Apr 17, 2026

Copy link
Copy Markdown
Member

@meeseeksdev please backport to v3.10.x

@lumberbot-app

lumberbot-app Bot commented Apr 17, 2026

Copy link
Copy Markdown

timhoffm pushed a commit that referenced this pull request Apr 22, 2026
SEC: Block shell escapes in latex and ps commands
(cherry picked from commit 8ff895d)

The test that was edited had significant updates on main, so the old
test was kept on backport and no similar call exists in the old test.
timhoffm added a commit that referenced this pull request Apr 22, 2026
Backport PR #31282 on branch v3.10.x (SEC: Block shell escapes in latex and ps commands)
@ksunden ksunden mentioned this pull request Apr 24, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend: pgf backend: ps Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. Security Hardening Proactive security hardening. Existing vulnerabilities should be reported per our security policy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants