fix: validate Location host before blob upload to prevent credential leak#1192
Closed
TerryHowe wants to merge 1 commit into
Closed
fix: validate Location host before blob upload to prevent credential leak#1192TerryHowe wants to merge 1 commit into
TerryHowe wants to merge 1 commit into
Conversation
…leak Validate that the Location header returned by the registry POST response refers to the same host as the original request before issuing the PUT and forwarding the Authorization header. A malicious registry could return a cross-host Location, causing oras-go to send the caller's credentials to an attacker-controlled endpoint. Also reject scheme downgrades (https → http) on the Location URL. Adds sameUploadHost() to normalize implicit default ports (80/443) so that e.g. example.com and example.com:443 compare equal over HTTPS, preserving the existing port-443 workaround behaviour. Fixes: GHSA-jxpm-75mh-9fp7 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Terry Howe <terrylhowe@gmail.com> (cherry picked from commit b4437a6) Signed-off-by: Terry Howe <terrylhowe@gmail.com>
TerryHowe
requested review from
Wwwsylvia,
sabre1041 and
shizhMSFT
as code owners
May 28, 2026 12:53
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (71.42%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1192 +/- ##
==========================================
- Coverage 83.06% 83.03% -0.03%
==========================================
Files 81 81
Lines 5687 5701 +14
==========================================
+ Hits 4724 4734 +10
- Misses 595 597 +2
- Partials 368 370 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
Author
|
nvm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backports the GHSA-jxpm-75mh-9fp7 fix from the
v2line (originally #1152) tomain.Validates that the
Locationheader returned by the registry POST response refers to the same host as the original request before issuing the PUT and forwarding theAuthorizationheader. A malicious registry could otherwise return a cross-hostLocation, causing oras-go to send the caller's credentials to an attacker-controlled endpoint. Scheme downgrades (https → http) on theLocationURL are also rejected.A new
sameUploadHost()helper normalizes implicit default ports (80/443) so that e.g.example.comandexample.com:443compare equal over HTTPS, preserving the existing port-443 workaround behaviour.Fixes: GHSA-jxpm-75mh-9fp7
Cherry-picked from commit b4437a6.
Test plan
go build ./registry/remote/...go test ./registry/remote/passes