Skip to content

fix: validate Location host before blob upload to prevent credential leak#1192

Closed
TerryHowe wants to merge 1 commit into
oras-project:mainfrom
TerryHowe:fix/ghsa-jxpm-75mh-9fp7-main
Closed

fix: validate Location host before blob upload to prevent credential leak#1192
TerryHowe wants to merge 1 commit into
oras-project:mainfrom
TerryHowe:fix/ghsa-jxpm-75mh-9fp7-main

Conversation

@TerryHowe

Copy link
Copy Markdown
Member

Summary

Backports the GHSA-jxpm-75mh-9fp7 fix from the v2 line (originally #1152) to main.

Validates 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 otherwise return a cross-host Location, causing oras-go to send the caller's credentials to an attacker-controlled endpoint. Scheme downgrades (https → http) on the Location URL are also rejected.

A new sameUploadHost() helper normalizes 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

Cherry-picked from commit b4437a6.

Test plan

  • go build ./registry/remote/...
  • go test ./registry/remote/ passes

…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>
@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.03%. Comparing base (9fc3dfb) to head (851ca99).

Files with missing lines Patch % Lines
registry/remote/repository.go 71.42% 2 Missing and 2 partials ⚠️

❌ 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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TerryHowe

Copy link
Copy Markdown
Member Author

nvm

@TerryHowe TerryHowe closed this May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant