<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/github-actions-leaking-secrets-when-miri-output-is-cached-wtfuxayyu" -->

---
title: GitHub Actions leaking secrets when Miri output is cached
description: Miri, Rust's undefined-behavior checker, stores all environment variables inside the target/ directory during builds. When that directory is cached in GitHub...
canonical: https://daily.dev/posts/github-actions-leaking-secrets-when-miri-output-is-cached-wtfuxayyu
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: GitHub Actions leaking secrets when Miri output is cached | daily.dev
og:description: Miri, Rust's undefined-behavior checker, stores all environment variables inside the target/ directory during builds. When that directory is cached in GitHub...
og:url: https://daily.dev/posts/github-actions-leaking-secrets-when-miri-output-is-cached-wtfuxayyu
og:image: https://api.daily.dev/og/posts/wtFUxAYyU.png
og:image:alt: GitHub Actions leaking secrets when Miri output is cached
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub Actions leaking secrets when Miri output is cached

**[Rust](https://daily.dev/sources/rust)** · 4 min read · 1 upvotes · 0 comments

## Summary

Miri, Rust's undefined-behavior checker, stores all environment variables inside the target/ directory during builds. When that directory is cached in GitHub Actions and the cache is readable by pull requests, secrets exposed as environment variables to the job can leak to any PR, including ones from contributors who already had a PR merged. The Rust Security Response Team shipped a short-term fix restricting Miri to preserve only CARGO_* variables (excluding CARGO_*_TOKEN) and OUT_DIR, landing in the nightly dated 2026-09-22. An ecosystem scan found one confirmed vulnerable repository and seven at-risk ones. Maintainers are advised to check whether their CI runs cargo miri with secret-bearing environment variables and a PR-readable target/ cache, and if so to disable caching, scope secrets away from the Miri job, rotate leaked secrets, and clear the cache.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.rust-lang.org/2026/09/21/github-actions-leaking-secrets-when-miri-output-is-cached>

## Questions this post answers

### Why does caching the target/ directory in GitHub Actions leak secrets when using cargo miri?

Miri stores all environment variables into the target/ directory during builds so it can retain build-relevant variables between runs. If that job's environment contains secrets and the target/ directory gets cached, and the cache is readable by pull requests, those secrets become accessible to any PR that can trigger a cache read, including PRs from previously-approved contributors who push a second commit to hide the extraction.

_Teams tracking CI security fixes like this one can follow Rust ecosystem advisories on daily.dev._

### How was the Miri environment variable leak in GitHub Actions caches fixed?

The short-term fix restricts Miri to only preserve CARGO_* environment variables, excluding any CARGO_*_TOKEN variables, plus OUT_DIR, instead of copying the entire environment into target/. This landed in the nightly build dated 2026-09-22. A longer-term fix may involve Miri and cargo agreeing on a better way to communicate which environment variables Miri actually needs.

_Developers patching CI secret leaks can track Rust tooling security fixes like this on daily.dev._

### How do I know if my GitHub Actions CI setup is vulnerable to the Miri target cache secret leak?

A setup is vulnerable if it runs cargo miri in CI, the step running it has secrets available as an environment variable (directly, via workflow env, or inherited from a prior step), the workflow caches the target directory (commonly via actions/cache or swatinem/rust-cache), and that cache is readable by pull requests. Quick mitigations include disabling the cache, scoping secrets away from Miri steps, disabling Miri temporarily, clearing the cache, and rotating any leaked secrets.

_Engineers auditing CI caching for secret exposure can find similar Rust security advisories on daily.dev._

## Similar posts on daily.dev

- [The vulnerabilities nobody sees in your repository, and how to catch them before they merge](https://daily.dev/posts/the-vulnerabilities-nobody-sees-in-your-repository-and-how-to-catch-them-before-they-merge-qmufkovsn) · Medium · 1 upvotes · 0 comments
- [GitHub Actions Cache Poisoning is eating open source](https://daily.dev/posts/github-actions-cache-poisoning-is-eating-open-source-dyhf0mvj0) · Neciu Dan · 0 upvotes · 0 comments
- [GitHub Actions is the weakest link](https://daily.dev/posts/github-actions-is-the-weakest-link-kx8cbboab) · Andrew Nesbitt · 1 upvotes · 0 comments

---

Tags: [#devsecops](https://daily.dev/tags/devsecops), [#github-actions](https://daily.dev/tags/github-actions), [#rust](https://daily.dev/tags/rust), [#secrets-management](https://daily.dev/tags/secrets-management)

[View this post on daily.dev](https://daily.dev/posts/github-actions-leaking-secrets-when-miri-output-is-cached-wtfuxayyu)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"GitHub Actions leaking secrets when Miri output is cached","url":"https://daily.dev/posts/github-actions-leaking-secrets-when-miri-output-is-cached-wtfuxayyu","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/github-actions-leaking-secrets-when-miri-output-is-cached-wtfuxayyu"},"datePublished":"2026-09-21T17:46:16.766Z","dateModified":"2026-10-29T02:14:10.661Z","description":"Miri, Rust's undefined-behavior checker, stores all environment variables inside the target/ directory during builds. When that directory is cached in GitHub...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/10c030b2429f801a5aed8756bdece9d2?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/10c030b2429f801a5aed8756bdece9d2?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Rust","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Rust","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/8fb725c4025846578f65c8eada2fc5b8","url":"https://daily.dev/sources/rust"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/github-actions-leaking-secrets-when-miri-output-is-cached-wtfuxayyu","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"devsecops,github-actions,rust,secrets-management","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Rust","item":"https://daily.dev/sources/rust"},{"@type":"ListItem","position":3,"name":"GitHub Actions leaking secrets when Miri output is cached"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/github-actions-leaking-secrets-when-miri-output-is-cached-wtfuxayyu#faq","mainEntity":[{"@type":"Question","name":"Why does caching the target/ directory in GitHub Actions leak secrets when using cargo miri?","acceptedAnswer":{"@type":"Answer","text":"Miri stores all environment variables into the target/ directory during builds so it can retain build-relevant variables between runs. If that job's environment contains secrets and the target/ directory gets cached, and the cache is readable by pull requests, those secrets become accessible to any PR that can trigger a cache read, including PRs from previously-approved contributors who push a second commit to hide the extraction. Teams tracking CI security fixes like this one can follow Rust ecosystem advisories on daily.dev."}},{"@type":"Question","name":"How was the Miri environment variable leak in GitHub Actions caches fixed?","acceptedAnswer":{"@type":"Answer","text":"The short-term fix restricts Miri to only preserve CARGO_* environment variables, excluding any CARGO_*_TOKEN variables, plus OUT_DIR, instead of copying the entire environment into target/. This landed in the nightly build dated 2026-09-22. A longer-term fix may involve Miri and cargo agreeing on a better way to communicate which environment variables Miri actually needs. Developers patching CI secret leaks can track Rust tooling security fixes like this on daily.dev."}},{"@type":"Question","name":"How do I know if my GitHub Actions CI setup is vulnerable to the Miri target cache secret leak?","acceptedAnswer":{"@type":"Answer","text":"A setup is vulnerable if it runs cargo miri in CI, the step running it has secrets available as an environment variable (directly, via workflow env, or inherited from a prior step), the workflow caches the target directory (commonly via actions/cache or swatinem/rust-cache), and that cache is readable by pull requests. Quick mitigations include disabling the cache, scoping secrets away from Miri steps, disabling Miri temporarily, clearing the cache, and rotating any leaked secrets. Engineers auditing CI caching for secret exposure can find similar Rust security advisories on daily.dev."}}]}
```

