Skip to content

bugfix: cache-poisoning: fix false positive for docker/setup-buildx-action - #644

Merged
woodruffw merged 5 commits into
mainfrom
ww/complex-controls
Apr 5, 2025
Merged

woodruffw merged 5 commits into
mainfrom
ww/complex-controls

Conversation

@woodruffw

Copy link
Copy Markdown
Member

This is an initial stab at exposing greater generality when evaluating whether a set of controls are "satisfied" for the purpose of considering an action enabled.

Doing this while also preserving the concept of "default enablement" results in some very wonky 4-valued logic, since there are 4 different states a control can evaluate to:

  1. Satisfied by default
  2. Satisfied through evaluation
  3. Not satisfied through evaluation
  4. "Conditional," i.e. we don't know because it's driven by an expression or similar

This is a little hard to follow, so I need to think about this more before actually merging it. However, the tests do pass and I've also added a successful test for the original bug case that spurred this.

Fixes #642.

@woodruffw woodruffw added enhancement New feature or request bugfix Fixes a known bug labels Apr 3, 2025
@woodruffw woodruffw self-assigned this Apr 3, 2025

@crazy-max crazy-max left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice work thanks!

Left a comment about runtime artifacts

Comment on lines +6 to +17
error[cache-poisoning]: runtime artifacts potentially vulnerable to a cache poisoning attack
--> @@INPUT@@:20:9
|
15 | / with:
16 | | cache-binary: true
17 | | version: latest
| |_________________________^ opt-in for caching here
18 |
19 | - name: Build docker
20 | uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ runtime artifacts usually published here
|

@crazy-max crazy-max Apr 3, 2025 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Indeed we are publishing the build record as GitHub artifact in post step of the build-push-action: https://github.com/docker/build-push-action/blob/84ad562665bb303b549fec655d1b64f9945f3f91/src/main.ts#L208-L214

But there could be false positives. If env vars DOCKER_BUILD_SUMMARY=false or DOCKER_BUILD_RECORD_UPLOAD=false are set, then no artifact is uploaded: https://github.com/docker/build-push-action/tree/master?tab=readme-ov-file#environment-variables

There are also other tricky cases where build summary would be disabled and therefore no artifact will be uploaded: https://github.com/docker/build-push-action/blob/84ad562665bb303b549fec655d1b64f9945f3f91/src/main.ts#L170-L180 but I think these are edge cases.

Env var could also be tricky to detect in some cases like internal script using core.exportVariable or append to GITHUB_ENV.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for calling this out! Yeah, I don't have a fantastic way to model implicit controls like environment variables quite yet -- it should be doable in the same basic way, but I need to think more through the complexity implications 🙂

In the mean time, this is one of the reasons this finding is marked as "low confidence" -- we only issue high-confidence cache poisoning findings when the workflow trigger itself is unambiguously a publish trigger, i.e. tag or release.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In the mean time, this is one of the reasons this finding is marked as "low confidence"

Ah ok got it, didn't know that

@woodruffw
woodruffw merged commit 059e718 into main Apr 5, 2025
@woodruffw
woodruffw deleted the ww/complex-controls branch April 5, 2025 00:57
aldur pushed a commit to aldur/zizmor that referenced this pull request May 5, 2025
…ction (zizmorcore#644)

* bugfix: cache-poisoning: fix false positive for docker/setup-buildx-action

Fixes zizmorcore#642.

* cleanup

* update jdx/mise-action coordinate

* release-notes: record changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a known bug enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: setup-buildx-action false positive for cache poisoning audit

2 participants