From 321c59fb0e6230096487afb5ac7d6db9b9ab8cea Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Fri, 1 Mar 2024 17:44:14 +0100 Subject: [PATCH 1/2] Fix GH-11808: Live filesystem modified by tests (security) 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. --- ext/standard/tests/file/006_error.phpt | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/ext/standard/tests/file/006_error.phpt b/ext/standard/tests/file/006_error.phpt index 98caa4d1e11e..26c977b9ea5c 100644 --- a/ext/standard/tests/file/006_error.phpt +++ b/ext/standard/tests/file/006_error.phpt @@ -11,20 +11,9 @@ require __DIR__ . '/../skipif_root.inc'; Date: Fri, 1 Mar 2024 18:07:21 +0100 Subject: [PATCH 2/2] Some more --- ext/standard/tests/file/chroot_001.phpt | 18 ++++++++++---- ext/standard/tests/file/mkdir-004.phpt | 32 +++++++++++-------------- ext/standard/tests/file/mkdir-005.phpt | 25 ------------------- ext/standard/tests/file/mkdir-006.phpt | 20 ---------------- 4 files changed, 27 insertions(+), 68 deletions(-) delete mode 100644 ext/standard/tests/file/mkdir-005.phpt delete mode 100644 ext/standard/tests/file/mkdir-006.phpt diff --git a/ext/standard/tests/file/chroot_001.phpt b/ext/standard/tests/file/chroot_001.phpt index a8bca2e04bde..79192e98fc9f 100644 --- a/ext/standard/tests/file/chroot_001.phpt +++ b/ext/standard/tests/file/chroot_001.phpt @@ -2,14 +2,22 @@ chroot() --SKIPIF-- --FILE-- +recursive mkdir() with unclean paths --FILE-- --EXPECT-- -bool(true) -bool(true) -bool(true) -Done +Ok. diff --git a/ext/standard/tests/file/mkdir-005.phpt b/ext/standard/tests/file/mkdir-005.phpt deleted file mode 100644 index 383f8b18e052..000000000000 --- a/ext/standard/tests/file/mkdir-005.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -recursive mkdir() tests ---SKIPIF-- - ---FILE-- - ---EXPECT-- -bool(true) -bool(true) -bool(true) -Done diff --git a/ext/standard/tests/file/mkdir-006.phpt b/ext/standard/tests/file/mkdir-006.phpt deleted file mode 100644 index 1974faa0b603..000000000000 --- a/ext/standard/tests/file/mkdir-006.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -recursive mkdir() with unclean paths ---FILE-- - ---EXPECT-- -Ok.