Skip to content

fix(registry): redact the upload Location in rejection errors - #24094

Merged
stonezdj merged 1 commit into
goharbor:release-2.15.0from
bupd:backport/redact-upload-location-215
Nov 9, 2026
Merged

stonezdj merged 1 commit into
goharbor:release-2.15.0from
bupd:backport/redact-upload-location-215

Conversation

@bupd

@bupd bupd commented Oct 8, 2026

Copy link
Copy Markdown
Member

A rejected chunked-upload Location was quoted verbatim in the error, which replication logs. This renders it without userinfo, query and fragment, so credentials or signed upload tokens do not reach the job log. Follow-up to GHSA-wjpm-hv5w-gxr6.

Backport of #24068 to release-2.15.0. The commit cherry-picked cleanly with no changes.

Tests: go test of the touched packages (from src/).

Please indicate you've done the following:

  • Well Written Title and Summary of the PR
  • Label the PR as needed. "release-note/ignore-for-release, release-note/new-feature, release-note/update, release-note/enhancement, release-note/community, release-note/breaking-change, release-note/docs, release-note/infra, release-note/deprecation"
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

@bupd
bupd requested a review from a team as a code owner October 8, 2026 01:38
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (release-2.15.0@2bed165). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                @@
##             release-2.15.0   #24094   +/-   ##
=================================================
  Coverage                  ?   66.54%           
=================================================
  Files                     ?     1076           
  Lines                     ?   117383           
  Branches                  ?     2962           
=================================================
  Hits                      ?    78116           
  Misses                    ?    34957           
  Partials                  ?     4310           
Flag Coverage Ξ”
unittests 66.54% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Ξ”
src/pkg/registry/client.go 55.73% <100.00%> (ΓΈ)
πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟑 Changes recommended

Malformed Locations can still leak their full signed URL through url.Parse errors.

1 open finding
What changed in this PR

Redacts secrets from rejected registry upload Locations before errors reach replication logs.

Changes:

  • Adds URL redaction for userinfo, query, and fragment.
  • Adds regression tests for rejected Locations.
File Description
src/​pkg/​registry/​client.go Redacts rejected upload URLs in errors.
src/​pkg/​registry/​client_chunk_location_test.go Tests secret redaction.

🧠 Review effort: Balanced


πŸ’‘ Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +823 to +825
// redactUploadLocation renders a Location for error messages without userinfo, query or fragment,
// since registries may put credentials or signed upload tokens there and callers log these errors.
func redactUploadLocation(u *url.URL) string {

@wy65701436 wy65701436 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@wy65701436

Copy link
Copy Markdown
Contributor

@bupd can you help to fix the CI failures?

A rejected chunked-upload Location was quoted verbatim in the error,
which replication logs. Registries can carry credentials or signed
upload tokens in its userinfo or query, so render it without userinfo,
query and fragment.

Follow-up to GHSA-wjpm-hv5w-gxr6.

Signed-off-by: Prasanth Baskar <prasanth@8gears.com>
(cherry picked from commit 0c14c60)
Signed-off-by: stonezdj <stonezdj@gmail.com>
@stonezdj
stonezdj force-pushed the backport/redact-upload-location-215 branch from f9a5d0a to c88c746 Compare November 9, 2026 02:24
@stonezdj
stonezdj merged commit 45c878f into goharbor:release-2.15.0 Nov 9, 2026
12 checks passed
@Vad1mo Vad1mo added this to Harbor Nov 20, 2026
@github-project-automation github-project-automation Bot moved this to Done in Harbor Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants