Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow all out-of-bounds symlinks in manifest repositories #9738

Closed
crenshaw-dev opened this issue Jun 21, 2022 · 2 comments · Fixed by #9843
Closed

Disallow all out-of-bounds symlinks in manifest repositories #9738

crenshaw-dev opened this issue Jun 21, 2022 · 2 comments · Fixed by #9843
Labels
enhancement New feature or request security Security related

Comments

@crenshaw-dev
Copy link
Member

crenshaw-dev commented Jun 21, 2022

Summary

Manifest generation (and other repo-server actions like getting app details) should fail if any symlink in the repo points out of bounds (regardless of whether the symlink resolves).

Motivation

We've had some issues with symlink following in the repo server:

It's likely that we've missed things. It's also possible that the patches aren't quite secure enough, because they are designed to prevent reading the contents of the destination, but not necessarily to prevent inferring things about the destination (like presence/absence and file type). That information can be sensitive since we're relying on randomized paths for traversal mitigation.

Finally, our code is not the only code involved. Since we call external binaries to operate on the repository contents, attackers may find ways to take advantage of behavior (buggy or otherwise) in those tools to traverse out of the repo.

Proposal

After each fetch, we should walk the entire repo contents and evaluate each symlink. If the symlink resolves to a location outside the repo root (regardless of whether there's anything at that location), we should fail the fetch operation so that the dependent operation fails. We should consider caching the success/failure to speed up future fetches of the same revision. We should also log a warning to help detect malicious symlinks.

We should identify every repo-related operation which does not perform a fetch before using the repo contents. Those operations should check the success/failure cache and then perform the symlink walk if the result isn't cached. The operation should fail and log a warning.

These checks should be disable-able by config. The config should be documented with a clear warning that disabling the check increases the risk of directory traversal attacks and should especially be avoided for Argo CD instances with multiple tenants.

This change should be made on a minor release (e.g. 2.5.0) and upgrade notes should clearly warn about the change.

@crenshaw-dev crenshaw-dev added enhancement New feature or request security Security related labels Jun 21, 2022
@notfromstatefarm
Copy link
Contributor

oh man, my force pushes really spammed the heck out of this issue. sorry!

@crenshaw-dev
Copy link
Member Author

Haha no worries, GitHub real estate is cheap. :-)

notfromstatefarm added a commit to notfromstatefarm/argo-cd that referenced this issue Jul 5, 2022
Signed-off-by: notfromstatefarm <86763948+notfromstatefarm@users.noreply.github.com>
crenshaw-dev pushed a commit that referenced this issue Jul 11, 2022
Signed-off-by: notfromstatefarm <86763948+notfromstatefarm@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request security Security related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants