-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Live filesystem modified by tests (security) #11808
Comments
Is there some way to prioritize this? We have a test that can make |
A few more obscure ways this can go wrong:
|
I agree these tests are dangerous. I haven't dug into it deep enough to understand how to replace them with safe alternatives. Do you have suggestions? |
I can't think of a way to make it completely safe in a portable way. Ideally we'd like to mess with a file that we create ourselves, but we'll own any file we create, and non-root users can't We could try to check a long list of conditions in which the user might actually be able to A potential consolation prize would be to run the test only on CI, and only as root. If you create a new file and run |
I agree these tests on the root filesystem are not great. Also, what does that actually test anyway, checking if chmod works is already done in other tests... We just want to test the error path which can also be reached by trying to chmod a non-existent file. And yeah, |
There's a test that tries to make /etc world-writable, and asserts that it fails. Although this test is guarded by a root user check, there are situations where you don't need to be root to be able to do this. This may thus have unwanted effects on your live filesystem. The simple solution is to remove that part of the test. It doesn't really add value anyway: we're trying to test the chmod error path, but that exact same error path can be reached with any failure condition that the kernel gives. For example, trying to chmod a non-existent file will trigger the same code path. While at it, also prefix the test path for the non-existent file such that we don't accidentally modify the filesystem.
* PHP-8.2: Fix GH-11808: Live filesystem modified by tests (security)
* PHP-8.3: Fix GH-11808: Live filesystem modified by tests (security)
Description
I don't remember where I reported this, but I haven't heard anything about it since November of 2022, so here it is again: https://bugs.gentoo.org/839894
Several filesystem tests check for root privileges with,
and proceed to modify the live filesystem if the user is not root. Those modifications are expected to fail. For example,
This test tries to make
/etc/passwd
world-writable, but it will be skipped if you are uid 0. Well, not only uid 0 can modify/etc/passwd
. if there's anadmins
group, for example, its members may have uid 1000+ and still be able to add new users by modifying/etc/passwd
. The user reporting the Gentoo bug is also able to write those files, and is not root (for some other reason). In cases like those, this test creates a security issue: the test will be run because the user is not root, and/etc/passwd
will be made world-writable; afterwards, anyone can edit it.There are two problems here:
PHP Version
git HEAD
Operating System
No response
The text was updated successfully, but these errors were encountered: