Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-1.26] Properly validate cache IDs and sources #5794

Merged

Conversation

dashea
Copy link

@dashea dashea commented Oct 21, 2024

Backport the changes from #5778 to release-1.26

The --mount type=cache argument to the RUN instruction in Dockerfiles was using filepath.Join on user input, allowing crafted paths to be used to gain access to paths on the host, when the command should normally be limited only to Buildah;s own cache and context directories. Switch to filepath.SecureJoin to resolve the issue.

Fixes CVE-2024-9675

What type of PR is this?

/kind bug

What this PR does / why we need it:

How to verify it

Includes the new test from the original change, build-check-cve-2024-9675

Which issue(s) this PR fixes:

https://issues.redhat.com/browse/RHEL-62366
https://issues.redhat.com/browse/RHEL-62371

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Fixed CVE-2024-9675 which allowed arbitrary paths from the host to be mounted into a build container using the `--mount type=cache` argument to the `RUN` instruction in Dockerfiles.

@dashea dashea force-pushed the 1.26-cve-2024-9675 branch from c932ac4 to c682674 Compare October 21, 2024 18:28
@TomSweeneyRedHat
Copy link
Member

Changes LGTM.

The older variants of Buildah version themselves slightly differently. I'm not sure what's out of whack on this one, I'd try running ./tests/version.bats from the command line to see if that detects anything.

@dashea dashea force-pushed the 1.26-cve-2024-9675 branch from c682674 to 03681c1 Compare October 21, 2024 22:05
@dashea
Copy link
Author

dashea commented Oct 21, 2024

Forgot to add a new changelog entry to the spec file. Updated.

@cevich cevich force-pushed the 1.26-cve-2024-9675 branch from 03681c1 to b0eb0de Compare October 23, 2024 14:40
The `--mount type=cache` argument to the `RUN` instruction in
Dockerfiles was using `filepath.Join` on user input, allowing
crafted paths to be used to gain access to paths on the host,
when the command should normally be limited only to Buildah;s own
cache and context directories. Switch to `filepath.SecureJoin` to
resolve the issue.

Fixes CVE-2024-9675

N/B: The system test was slightly modified from the original
fix done by Matt.  The older CI environments used by this
release successfully block the escape with SELinux.

Signed-off-by: Matt Heon <[email protected]>
Signed-off-by: David Shea <[email protected]>
Signed-off-by: Chris Evich <[email protected]>
@cevich cevich force-pushed the 1.26-cve-2024-9675 branch from b0eb0de to 5fc4804 Compare October 23, 2024 14:41
@dashea dashea force-pushed the 1.26-cve-2024-9675 branch from 5fc4804 to 60b40b9 Compare October 23, 2024 16:48
@cevich
Copy link
Member

cevich commented Oct 23, 2024

@dashea I re-ran two tests that had flakes - "quay: 503 gateway timeout". Quay is notoriously flaky on these older branches. In podman CI too.

@dashea
Copy link
Author

dashea commented Oct 24, 2024

Just to summarize the changes since Tom's approval: @cevich disabled selinux on the new test since selinux was preventing access to /var/tmp with or without the code change, and I added a pre-fetch on busybox in run check --from with arg due to a failure in that test to find the image.

@nalind
Copy link
Member

nalind commented Oct 24, 2024

/approve
/lgtm

Copy link
Contributor

openshift-ci bot commented Oct 24, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dashea, nalind

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit e2feca7 into containers:release-1.26 Oct 24, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants