Registry Mirror
Skip to content

Conversation

@divyani-22

Copy link
Copy Markdown
Contributor

Description

In pkg/functions/repositories.go, Add, Rename, and Remove previously passed repository names directly to filepath.Join(r.path, ...) and performed filesystem mutations (repo.Write, os.Rename, os.RemoveAll) without validating against path traversal, path separators, or reserved names:

  1. Remove(".") or Remove("..") / Remove("../outside") resolved outside or at the root of r.path and passed that path directly to os.RemoveAll, risking deletion of all installed repositories or parent configuration directories.
  2. Rename allowed from or to to escape r.path via ../ or path separators.
  3. Add wrote directly to filepath.Join(r.path, repo.Name). Because NewRepository allows a remote repository's manifest.yaml name: field to set repo.Name, an untrusted repository declaring name: ../evil could write outside the configured repositories root.

This complements #4193 (which hardened MCP positional argument handling for repository_* tools) by securing the core Repositories API itself.

Changes

  • pkg/functions/repositories.go:
    • Added validateRepositoryName and resolveRepositoryPath to reject empty/whitespace names, reserved "default", ".", "..", path separators (/ and \), volume prefixes, and any resolved target escaping r.path.
    • Enforced validation in Add (both on explicit name before cloning and on resolved repo.Name before writing to disk), Rename (on both from and to), and Remove (before os.RemoveAll).
  • pkg/functions/repositories_test.go:
    • Added TestRepositories_PathTraversalRejected testing traversal/separator/reserved inputs across Add, Rename, and Remove.
    • Added TestRepositories_AddManifestTraversalRejected verifying that an untrusted manifest.yaml name: cannot write outside the repositories root.

Testing

  • TestRepositories_PathTraversalRejected in pkg/functions/repositories_test.go
  • TestRepositories_AddManifestTraversalRejected in pkg/functions/repositories_test.go

Copilot AI balanced review requested due to automatic review settings December 1, 2026 03:15
@knative-prow

knative-prow Bot commented Dec 1, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: divyani-22
Once this PR has been reviewed and has the lgtm label, please assign jrangelramos for approval. For more information see the Code Review Process.

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

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@knative-prow knative-prow Bot added the size/L 🤖 PR changes 100-499 lines, ignoring generated files. label Dec 1, 2026
@knative-prow

knative-prow Bot commented Dec 1, 2026

Copy link
Copy Markdown

Hi @divyani-22. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow knative-prow Bot added the needs-ok-to-test 🤖 Needs an org member to approve testing label Dec 1, 2026
…and remove

Signed-off-by: Divyani <divyanipapalkar22@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test 🤖 Needs an org member to approve testing size/L 🤖 PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants