Commit cad232f
authored
Prevent cache poisoning vuln in GitHub Actions sample workflows (#1935)
The PR #1917 bumped the
`actions/setup-node` action from v4 to v6. This made the publishing
GitHub Actions sample workflows potentially vulnerable to cache
poisoning, because v5 and later enable caching by default (see
https://github.com/actions/setup-node/blob/53b83947a5a98c8d113130e565377fae1a50d02f/README.md#breaking-changes-in-v5).
v6 only enables automatic caching if the `packageManager` field in
package.json is set to `npm`.
Consuming GitHub Actions cache in publishing workflows is discouraged,
because the cache may be poisoned by compromising any low-privileged
workflow in the same repository. Normally, a code injection
vulnerability in a low-privileged workflow (for example `permissions:
{contents: read}` and no secrets) is not a big deal, because the
attacker cannot do much more than poison the repository cache (which
requires no permissions). If caching is only used in other
low-privileged workflows, the impact is limited. However, if a
high-privileged workflow like the release build consumes the cache, then
it becomes a real problem.
As @AdnaneKhan concludes in his blog posts about GitHub Actions cache
poisoning, such as
https://adnanthekhan.com/2024/05/06/the-monsters-in-your-build-cache-github-actions-cache-poisoning/#dont-use-actions-caching-in-release-builds:
"the best way to protect the integrity of releases is to avoid using
GitHub Actions caching entirely for release workflows."
The README of `actions/setup-node` also recommends
`package-manager-cache: false` for privileged workflows (see
https://github.com/actions/setup-node/blob/53b83947a5a98c8d113130e565377fae1a50d02f/README.md#breaking-changes-in-v5):
> For workflows with elevated privileges or access to sensitive
information, we recommend disabling automatic caching by setting
`package-manager-cache: false` when caching is not needed for secure
operation.
## References
Related to #19171 parent e93dc35 commit cad232f
2 files changed
Lines changed: 7 additions & 4 deletions
File tree
- content/packages-and-modules/securing-your-code
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
| 94 | + | |
| 95 | + | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
298 | 299 | | |
299 | 300 | | |
300 | 301 | | |
301 | | - | |
| 302 | + | |
302 | 303 | | |
303 | 304 | | |
304 | 305 | | |
| 306 | + | |
305 | 307 | | |
306 | 308 | | |
307 | 309 | | |
| |||
0 commit comments