Skip to content

Race condition in sys_open with O_CREAT allowing for privilege escalation #312

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

Open
disconnect3d opened this issue Jan 9, 2025 · 1 comment

Comments

@disconnect3d
Copy link

disconnect3d commented Jan 9, 2025

Hi,

There is a race condition in the sys_open syscall with the O_CREAT flag which allows for privilege escalation.

int result = create_file_fs((char *)file, mode);
if (!result) {
node = kopen((char *)file, flags);

The tl;dr is that since there is no locking here, an unprivileged process can create two threads. One will do a call to create a file, and another will remove the file immediately after it is created by the create_file_fs call, then symlink it to another file - owned by root - and then the kopen will just happily open the symlink. At this point, the unprivileged process can open any file owned by root.

I can share a proof of concept of exploiting that vulnerability if you want.

This bug was found during HXP 38C3 CTF competition (which contained a challenge with TaoruOS).

@klange
Copy link
Owner

klange commented Jan 10, 2025

This one's probably more straightforward to fix than a lot of the other subtle TOCTOUs; might be a good candidate for someone to pick up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants