Title: [Sec]: Disable auto-loading custom matplotlibrc files · Issue #31346 · matplotlib/matplotlib · GitHub
Open Graph Title: [Sec]: Disable auto-loading custom matplotlibrc files · Issue #31346 · matplotlib/matplotlib
X Title: [Sec]: Disable auto-loading custom matplotlibrc files · Issue #31346 · matplotlib/matplotlib
Description: Issue Description: matplotlibrc files are autoloaded on import matplotlib. When matplotlib_fname searches for this file, the first candidate it yields is the bare filename 'matplotlibrc' in the current working directory. If an attacker c...
Open Graph Description: Issue Description: matplotlibrc files are autoloaded on import matplotlib. When matplotlib_fname searches for this file, the first candidate it yields is the bare filename 'matplotlibrc' in the cur...
X Description: Issue Description: matplotlibrc files are autoloaded on import matplotlib. When matplotlib_fname searches for this file, the first candidate it yields is the bare filename 'matplotlibrc' in...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/31346
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Sec]: Disable auto-loading custom matplotlibrc files","articleBody":"**Issue Description:**\n\n`matplotlibrc` files are autoloaded on `import matplotlib`. When `matplotlib_fname` searches for this file, the first candidate it yields is the bare filename `'matplotlibrc'` in the current working directory. If an attacker can place a `matplotlibrc` file in a directory where a user runs Python (e.g., a cloned git repository, a shared project directory, a downloads folder), all rcParams in that file are applied automatically when `import matplotlib` or `import matplotlib.pyplot` executes.\n\nSeveral of the rcparams can set up common calls such as figure creation (https://github.com/matplotlib/matplotlib/pull/31293) or latex text rendering (https://github.com/matplotlib/matplotlib/pull/31249) such that they can execute arbitrary code from the `matplotlibrc` file as a side-effect. This presents a potential security risk.\n\nThe two linked threads above talk a bit about how an attacker which can place a file on the PATH, could alternatively just place an executable which wraps some module and silently imports with arbitrary import-time side effects, and so this is a security boundary that matplotlib should not try to include. My take is that this sort of script would appear as code and be likely flagged in a manual or automatic security audit, whereas a `matplotlibrc` file is not directly executable and appears as data. Someone who assumes the common principle of separating data and code would not think that this file might be risky.\n\nThis is not a critical vulnerability, but represents an opportunity for security hardening.\n\n**How to Solve:**\nStop auto-loading custom `matplotlibrc` files. Allow the user to opt-in to this via a function or setting the MATPLOTLIBRC environment variable.\n\nNote that this may require some discussion to figure out the best solution, and I do not recommend this as a first-time contributor issue.","author":{"url":"https://github.com/scottshambaugh","@type":"Person","name":"scottshambaugh"},"datePublished":"2026-03-21T17:26:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":14},"url":"https://github.com/31346/matplotlib/issues/31346"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0d40a777-eb7b-65af-98fe-56d9099f5831 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E49A:16A191:12E8FEB:19B93F7:6A521BE7 |
| html-safe-nonce | bfe6cd3e4c3383ce3f570259e3fe359b6eb208c9278c82e29a18a27491009c9f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDlBOjE2QTE5MToxMkU4RkVCOjE5QjkzRjc6NkE1MjFCRTciLCJ2aXNpdG9yX2lkIjoiODkxMzkwOTE4NjcxNjM3NjAzOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 471782a731a88019baef045aa3767e4379f2314ad5cd8faa9854d2a77bf207cb |
| hovercard-subject-tag | issue:4113114421 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/matplotlib/matplotlib/31346/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5dcc82a3107196912afbe781f44073f5fac6858f299381561553491145e95ff4/matplotlib/matplotlib/issues/31346 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5dcc82a3107196912afbe781f44073f5fac6858f299381561553491145e95ff4/matplotlib/matplotlib/issues/31346 |
| og:image:alt | Issue Description: matplotlibrc files are autoloaded on import matplotlib. When matplotlib_fname searches for this file, the first candidate it yields is the bare filename 'matplotlibrc' in the cur... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | scottshambaugh |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width