Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: divyani-22 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.
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.
|
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 Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
…and remove Signed-off-by: Divyani <divyanipapalkar22@gmail.com>
Description
In
pkg/functions/repositories.go,Add,Rename, andRemovepreviously passed repository names directly tofilepath.Join(r.path, ...)and performed filesystem mutations (repo.Write,os.Rename,os.RemoveAll) without validating against path traversal, path separators, or reserved names:Remove(".")orRemove("..")/Remove("../outside")resolved outside or at the root ofr.pathand passed that path directly toos.RemoveAll, risking deletion of all installed repositories or parent configuration directories.Renameallowedfromortoto escaper.pathvia../or path separators.Addwrote directly tofilepath.Join(r.path, repo.Name). BecauseNewRepositoryallows a remote repository'smanifest.yamlname:field to setrepo.Name, an untrusted repository declaringname: ../evilcould write outside the configured repositories root.This complements #4193 (which hardened MCP positional argument handling for
repository_*tools) by securing the coreRepositoriesAPI itself.Changes
pkg/functions/repositories.go:validateRepositoryNameandresolveRepositoryPathto reject empty/whitespace names, reserved"default",".","..", path separators (/and\), volume prefixes, and any resolved target escapingr.path.Add(both on explicitnamebefore cloning and on resolvedrepo.Namebefore writing to disk),Rename(on bothfromandto), andRemove(beforeos.RemoveAll).pkg/functions/repositories_test.go:TestRepositories_PathTraversalRejectedtesting traversal/separator/reserved inputs acrossAdd,Rename, andRemove.TestRepositories_AddManifestTraversalRejectedverifying that an untrustedmanifest.yamlname:cannot write outside the repositories root.Testing
TestRepositories_PathTraversalRejectedinpkg/functions/repositories_test.goTestRepositories_AddManifestTraversalRejectedinpkg/functions/repositories_test.go