Repository navigation
fix: prevent SSRF in google.List() pagination - #2332
Conversation
Add URL validation to getNextPageURL() to ensure pagination Link headers point to the same registry host. This prevents SSRF attacks where a malicious registry could include a Link header pointing to internal services like cloud metadata endpoints (169.254.169.254). The fix validates that: 1. The pagination URL scheme matches the registry scheme 2. The pagination URL host matches the registry host This is consistent with SSRF protections added in PRs #2292, #2293, #2295 for other code paths.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
The same SSRF vulnerability that affected google.List() also exists in remote.List() and remote.Catalog(). A malicious registry can return a Link header pointing to internal services. This commit adds SSRF protection to the remote package's pagination handling, using the same validation approach.
Update test calls to getNextPageURL in pkg/v1/remote/list_test.go to pass the required name.Repository argument, matching the new function signature that includes SSRF validation. Also update makeResp helper to include a Request with URL for proper ResolveReference behavior, and adjust test assertions accordingly.
| } | ||
| } | ||
|
|
||
| // "<>" resolves to current URL which is valid |
There was a problem hiding this comment.
Can you provide a link to the Docker spec as to why this is valid? I don't see this in the HTTP API V2 document.
There was a problem hiding this comment.
Hey, this is fixed. There's no spec basis for treating <> as valid pagination.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2332 +/- ##
=======================================
Coverage 57.03% 57.03%
=======================================
Files 166 166
Lines 11399 11442 +43
=======================================
+ Hits 6501 6526 +25
- Misses 4131 4140 +9
- Partials 767 776 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
crane 0.21.7 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## What's Changed * tarball: return error instead of panicking on missing rootfs.diff_ids by @iahsanGill in google/go-containerregistry#2304 * gcrane: honor --platform flag in copy by @iahsanGill in google/go-containerregistry#2307 * mutate: verify layer digests in Extract and Time by @momenashrafff in google/go-containerregistry#2303 * tarball: close layer readers during Write by @nandbhat in google/go-containerregistry#2308 * build(deps): bump the actions group across 1 directory with 2 updates by @dependabot[bot] in google/go-containerregistry#2311 * build(deps): bump github.com/docker/cli from 29.4.3+incompatible to 29.5.2+incompatible in the go-deps group across 1 directory by @dependabot[bot] in google/go-containerregistry#2312 * BUGFIX: Fail with error when read exceeds maximum by @inteon in google/go-containerregistry#2328 * build(deps): bump the actions group across 1 directory with 2 updates by @dependabot[bot] in google/go-containerregistry#2327 * fix(name): anchor loopback registry detection by @rohan-patnaik in google/go-containerregistry#2314 * Reject symlinks in OCI layout blobs by @mosskappa in google/go-containerregistry#2306 * fix(crane): avoid creating export tar on pull failure by @Haihan-Jiang in google/go-containerregistry#2318 * feat(kubernetes): allow ignoring pull secrets by @rohan-patnaik in google/go-containerregistry#2315 * fix(name): preserve localhost registry references by @rohan-patnaik in google/go-containerregistry#2316 * pkg/registry: export ErrNotFound by @malt3 in google/go-containerregistry#2176 * pkg/registry: export RedirectError by @malt3 in google/go-containerregistry#2177 * build(deps): bump the go-deps group across 1 directory with 2 updates by @dependabot[bot] in google/go-containerregistry#2343 * build(deps): bump the actions group across 1 directory with 2 updates by @dependabot[bot] in google/go-containerregistry#2344 * fix: prevent SSRF in google.List() pagination by @tufstraka in google/go-containerregistry#2332 * internal/gzip: fix goroutine leak in ReadCloserLevel by @amarkdotdev in google/go-containerregistry#2347 * fix(transport): apply refreshed bearer token after cross-host redirect by @64johnlee in google/go-containerregistry#2337 * build(deps): bump the go-deps group across 3 directories with 4 updates by @dependabot[bot] in google/go-containerregistry#2348 * fix(tarball): normalize paths when matching files by @bstoll in google/go-containerregistry#2334 * transport: do not re-attach bearer token after cross-host redirect by @evilgensec in google/go-containerregistry#2349 * Bump CI go version to 1.26.4 by @Subserial in google/go-containerregistry#2350 ## New Contributors * @momenashrafff made their first contribution in google/go-containerregistry#2303 * @nandbhat made their first contribution in google/go-containerregistry#2308 * @inteon made their first contribution in google/go-containerregistry#2328 * @rohan-patnaik made their first contribution in google/go-containerregistry#2314 * @mosskappa made their first contribution in google/go-containerregistry#2306 * @Haihan-Jiang made their first contribution in google/go-containerregistry#2318 * @tufstraka made their first contribution in google/go-containerregistry#2332 * @amarkdotdev made their first contribution in google/go-containerregistry#2347 * @64johnlee made their first contribution in google/go-containerregistry#2337 * @bstoll made their first contribution in google/go-containerregistry#2334 **Full Changelog**: https://github.com/google/go-containerregistry/compare/v0.21.6...v0.21.7</pre> <p>View the full release notes at <a href="https://github.com/google/go-containerregistry/releases/tag/v0.21.7">https://github.com/google/go-containerregistry/releases/tag/v0.21.7</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!11861
Prevents SSRF attacks via malicious pagination Link headers in registry responses.
When listing tags or repositories, the library follows
Linkheader URLs for pagination. A malicious registry can return a Link header pointing to internal services (e.g., cloud metadata at169.254.169.254), causing the client to make unintended requests.This PR validates pagination URLs before following them:
Fixes
google.List(),remote.List(), andremote.Catalog().