mirror of
https://github.com/flatpak/flatpak.git
synced 2026-10-28 10:29:42 -04:00
Use glnx_chaseat to ensure that all the attacker-controlled paths end up inside the basefd directory, and then AT_SYMLINK_NOFOLLOW to make sure that the last path component won't escape from the basefd. On kernels >= 6.6 we can now use fchmodat() with AT_SYMLINK_NOFOLLOW, but on older kernels that didn't work, so if necessary fall back to opening the file with O_NOFOLLOW and then calling fchmod() on it. Because this is the last syscall that used the previous (flawed) validation mechanism, we can now remove the validation helpers and be sure that everything is using the glnx-chaseat()-based replacements. [smcv: Separated from a larger commit for better reviewability] Co-authored-by: Simon McVittie <smcv@collabora.com> Resolves: https://github.com/flatpak/flatpak/security/advisories/GHSA-qrwq-7qwx-q9rp