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

utils.RecursiveChown: Fix for Privilege Escalation due to following symlinks #33244

Merged
merged 2 commits into from Oct 10, 2023

Conversation

jentfoo
Copy link
Contributor

@jentfoo jentfoo commented Oct 10, 2023

Prior to this change a user could exploit Teleports privileged access to `chown` arbitrary files on the system.

This is due to the directory being changed first, allowing a small time window where a user can remove or rename the still `root` owned files with a symlink.  The added tests help show this issue in a more controlled way.

A switch to `os.Lchown` avoids the risk in following symlinks to files.  In addition, in order to remove the risk for hardlinks (notably on OSX with reduced hardlink protections), as well as risks with directory symlinks, the folder structure is inspected before any `chown` operation.  And then the files are updated before their parent directories.
None of these cases should expect a symlink that would need to be followed.
@jentfoo jentfoo added this pull request to the merge queue Oct 10, 2023
Merged via the queue into master with commit ff2f727 Oct 10, 2023
28 checks passed
@jentfoo jentfoo deleted the jent/recursiveChownFix branch October 10, 2023 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audit-log Issues related to Teleports Audit Log size/md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants