Skip to content

fix(hub): restrict tkn hub install resources fetching - #3240

Open
pratap0007 wants to merge 1 commit into
tektoncd:mainfrom
pratap0007:13837
Open

fix(hub): restrict tkn hub install resources fetching#3240
pratap0007 wants to merge 1 commit into
tektoncd:mainfrom
pratap0007:13837

Conversation

@pratap0007

Copy link
Copy Markdown
Contributor

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:

  • Includes tests (if functionality changed/added)
  • Run the code checkers with make check
  • Regenerate the manpages, docs and go formatting with make generated
  • Commit messages follow commit message best practices

See the contribution guide
for more details.

Release Notes

tkn hub install now requires HTTPS for Hub API URLs (HTTP is allowed only for a local Hub on loopback) and rejects other schemes such as file://.
Install applies only tekton.dev Task, Pipeline, and StepAction resources; TaskRun, PipelineRun, ClusterTask, and non-Tekton kinds are refused.

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Sep 11, 2026
@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from pratap0007 after the PR has been reviewed.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 11, 2026
@pratap0007
pratap0007 requested a lite review from Copilot September 11, 2026 09:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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, and StepAction resources.
  • 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.

Comment thread pkg/cmd/hub/hub/hub.go
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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.ParseRequestURI permits opaque/hostless forms such as https:foo, so SetURL succeeds but the first request fails later with http: no Host in request URL instead of rejecting the invalid --api-server value 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

Comment thread pkg/cmd/hub/hub/hub.go
Comment on lines +204 to +214
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)
},
Comment on lines +205 to +208
if err := validateInstallableResource(newRes); err != nil {
errors = append(errors, err)
return nil, errors
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants