Compare commits

...

2 Commits

Author SHA1 Message Date
Teknium
477f31eaf9 fix(security): extend /proc read block to auxv and pagemap
Follow-up to the cherry-pick of @AhmetArif0's #32238. auxv is the
glaring miss alongside maps/smaps — it exposes AT_RANDOM (stack canary)
and AT_BASE/AT_PHDR (program/interpreter load addresses), which is a
direct ASLR oracle on par with /proc/*/maps.

pagemap exposes virtual→physical address translations on systems that
expose it to userspace (depends on CAP_SYS_ADMIN / kernel config) — same
address-leak class.

Adds both to the same endswith tuple and to the existing parametrized
test, keeping the fragile-suffix pattern consistent with the rest of the
guard. A regex/set refactor across all /proc leak vectors (pagemap,
syscall, stack, wchan, kallsyms) is worth a follow-up but out of scope
for closing this immediate gap.
2026-05-28 23:45:00 -07:00
AhmetArif0
da4a74e636 fix(security): extend /proc read block to smaps, smaps_rollup, numa_maps, mem
PR #4609 blocked /proc/*/maps to prevent ASLR layout leakage, but the
endswith("/maps") check does not match /proc/*/smaps or
/proc/*/smaps_rollup — both expose the same virtual-address layout and
bypass the guard.  /proc/*/numa_maps carries the same data with NUMA
annotations and is equally bypassed.  /proc/*/mem (raw process memory)
is added as defence-in-depth; it requires address knowledge to exploit
but is blocked for consistency.

Extends the endswith tuple in _is_blocked_device_path() to cover all
four variants and adds regression assertions for all new paths to
test_proc_sensitive_pseudo_files_blocked.

Partially addresses #4427.
2026-05-28 23:43:47 -07:00
2 changed files with 23 additions and 4 deletions

View File

@@ -93,7 +93,7 @@ class TestDevicePathBlocking(unittest.TestCase):
self.assertFalse(_is_blocked_device_path("/proc/self/fd/3"))
def test_proc_sensitive_pseudo_files_blocked(self):
"""environ/cmdline/maps under /proc/<pid> must be blocked (issue #4427)."""
"""environ/cmdline/maps (and maps variants) under /proc/<pid> must be blocked (issue #4427)."""
for path in (
"/proc/self/environ",
"/proc/12345/environ",
@@ -101,6 +101,18 @@ class TestDevicePathBlocking(unittest.TestCase):
"/proc/99/cmdline",
"/proc/self/maps",
"/proc/1/maps",
"/proc/self/smaps",
"/proc/12345/smaps",
"/proc/self/smaps_rollup",
"/proc/99/smaps_rollup",
"/proc/self/numa_maps",
"/proc/1/numa_maps",
"/proc/self/auxv",
"/proc/12345/auxv",
"/proc/self/pagemap",
"/proc/99/pagemap",
"/proc/self/mem",
"/proc/12345/mem",
):
self.assertTrue(_is_blocked_device(path), f"{path} should be blocked")

View File

@@ -137,10 +137,17 @@ def _is_blocked_device_path(path: str) -> bool:
("/fd/0", "/fd/1", "/fd/2")
):
return True
# /proc/*/environ, /proc/*/cmdline, /proc/*/maps can leak secrets,
# command-line args, and memory layout from the host process (issue #4427)
# /proc/*/environ, /proc/*/cmdline, /proc/*/maps (and the maps variants
# smaps, smaps_rollup, numa_maps) can leak secrets, command-line args, and
# memory layout (ASLR bypass) from the host process (issue #4427).
# /proc/*/auxv contains AT_RANDOM (stack canary) and AT_BASE/AT_PHDR
# (interpreter/program load addresses) — direct ASLR oracle.
# /proc/*/pagemap exposes virtual→physical translations — address leak.
# /proc/*/mem exposes raw process memory; block it as defense-in-depth even
# though it requires address knowledge to exploit usefully.
if normalized.startswith("/proc/") and normalized.endswith(
("/environ", "/cmdline", "/maps")
("/environ", "/cmdline", "/maps", "/smaps", "/smaps_rollup",
"/numa_maps", "/auxv", "/pagemap", "/mem")
):
return True
return False