fix(hub): restrict tkn hub install resources fetching - #3240
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
🟡 Changes recommended
HTTPS-to-loopback redirects can downgrade Hub fetches; redirect validation must require HTTPS unconditionally.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Hardens tkn hub install by restricting Hub URLs and installable resource kinds.
Changes:
- Requires HTTPS, with loopback-only HTTP exceptions and fetch timeouts.
- Allows only Tekton
Task,Pipeline, andStepActionresources. - Updates tests and test Hub configuration.
- Critical issue: redirects can still downgrade HTTPS to loopback HTTP; redirects must require HTTPS unconditionally.
File summaries
| File | Reviewed changes |
|---|---|
pkg/cmd/hub/test/config.go |
Uses an HTTPS test Hub URL. |
pkg/cmd/hub/installer/action.go |
Validates installable resource kinds and groups. |
pkg/cmd/hub/installer/action_test.go |
Tests allowed and rejected resource kinds. |
pkg/cmd/hub/hub/hub.go |
Adds URL validation, redirect handling, and timeouts. |
pkg/cmd/hub/hub/hub_test.go |
Tests Hub URL validation behavior. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
tkn hub install applied Hub YAML with the user's kube credentials after fetching it over an unrestricted HTTP client. --api-server and httpGet only used url.ParseRequestURI, so remote HTTP, file://, and arbitrary schemes were accepted. The installer also did not check GVK, so a compromised Hub response could apply a TaskRun or PipelineRun and run immediately. Require HTTPS for Hub URLs (HTTP only to loopback for a local Hub), reject non-https redirects, and time out fetches. Before apply, allow only tekton.dev Task, Pipeline, and StepAction and runnable kinds stay rejected. All the above cases are handled. TLS pinning is not required: default Hub URLs are already HTTPS and Go verifies public CA certificates. Cosign/sigstore and SHA digest checks are not required as they need Hub-published signatures or hashes, and a digest from the same Hub API is the same trust root as the YAML. A malicious Task from a trusted catalog is still a catalog-trust issue, not a CLI URL bug. Signed-off-by: pratap0007 <shverma@redhat.com> Assisted-by: Cursor Grok 4.6 (via Cursor) Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
🟡 Changes recommended
Moderate findings remain around HTTP-client coverage, hostless URL validation, and update-path resource rejection tests.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
pkg/cmd/hub/hub/hub.go:232
- The HTTPS branch accepts URLs without a host.
url.ParseRequestURIpermits opaque/hostless forms such ashttps:foo, soSetURLsucceeds but the first request fails later withhttp: no Host in request URLinstead of rejecting the invalid--api-servervalue at validation time.
switch strings.ToLower(u.Scheme) {
case "https":
return nil
- Files reviewed: 5/5 changed files
- Comments generated: 2
- Review effort level: Lite
| var hubHTTPClient = &http.Client{ | ||
| Timeout: httpClientTimeout, | ||
| CheckRedirect: func(req *http.Request, via []*http.Request) error { | ||
| if len(via) >= maxRedirects { | ||
| return fmt.Errorf("stopped after %d redirects", maxRedirects) | ||
| } | ||
| if !strings.EqualFold(req.URL.Scheme, "https") { | ||
| return fmt.Errorf("refusing non-HTTPS redirect to %q", req.URL.Redacted()) | ||
| } | ||
| return validateHubURL(req.URL) | ||
| }, |
| if err := validateInstallableResource(newRes); err != nil { | ||
| errors = append(errors, err) | ||
| return nil, errors | ||
| } |
tkn hub install applied Hub YAML with the user's kube credentials after fetching it over an unrestricted HTTP client. --api-server and httpGet only used url.ParseRequestURI, so remote HTTP, file://, and arbitrary schemes were accepted. The installer also did not check GVK, so a compromised Hub response could apply a TaskRun or PipelineRun and run immediately.
Require HTTPS for Hub URLs (HTTP only to loopback for a local Hub), reject non-https redirects, and time out fetches. Before apply, allow only tekton.dev Task, Pipeline, and StepAction and runnable kinds stay rejected.
All the above cases are handled.
TLS pinning is not required: default Hub URLs are already HTTPS and Go verifies public CA certificates.
Cosign/sigstore and SHA digest checks are not required as they need Hub-published signatures or hashes, and a digest from the same Hub API is the same trust root as the YAML. A malicious Task from a trusted catalog is
still a catalog-trust issue, not a CLI URL bug.
Assisted-by: Cursor Grok 4.6 (via Cursor)
Changes
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
make checkmake generatedSee the contribution guide
for more details.
Release Notes