Closed bcoles closed 3 years ago
A simpler approach is to simply replace the /tmp/profiler_coredumps/
directory with a symlink. However, this does not allow control over the destination filename (the PID is still used).
This also freezes the system with no useful debug information presented in the console.
It seems that symlinks are followed, but coredumps will not be written to a location on a different partition.
If a coredump path is a symlink pointing to:
Symlinking to paths within /tmp/*
works :
The
/tmp/profiler_coredumps/
directory is used for storing coredumps created during process profiling withprofile
.Side note: While not directly relevant, it is worth mentioning that this directory does not exist at system startup, which allows anyone to first create the directory. This leads to a trivial denial of service by setting strict ownership and file permissions, preventing others from accessing profiler coredumps.
This screenshot isn't clear, but the user creating the directory is
nona
, notanon
. This preventsanon
from writing a core dump.If the directory does not exist, or has been removed, the next time a process is profiled the directory will be recreated with
777
permissions androot
ownership :https://github.com/SerenityOS/serenity/blob/d0a9954f0e8393c0eb68ca53bd246ed10d137361/Kernel/Syscalls/profiling.cpp#L49-L72
https://github.com/SerenityOS/serenity/blob/d0a9954f0e8393c0eb68ca53bd246ed10d137361/Kernel/Process.cpp#L600-L609
A combination of factors allow this functionality to be abused when a high privileged user profiles a process:
/tmp/profiler_coredumps/
directory is world writableIn theory, low-privileged users can spray symlinks for a range of PIDs (ie, 1-65535) into the
/tmp/profiler_coredumps/
directory. When a higher privileged user attempts to profile a process, the coredump will be written to the location pointed to by the symlink.At least, that was the plan. When I tried profiling by command or by process ID the system froze with no useful debug info printed to console.
The
/etc/win
file also wasn't created in the disk image:I'm not sure why the system freezes, but in theory this could be abused to write coredumps to any writable mounted filesystems
This issue is somewhat similar to #4435.