TExcelTAD

Privilege Boundaries

Every finding in a test has an answer to the question "as whom?". An injection runs as the web service's user; a stolen session acts as that customer; a misconfigured share is readable by "all domain users". A privilege boundary is a line the operating system or the application enforces between identities with different rights. Most serious attack paths are a series of boundary crossings: from the Internet to a service account, from the service account to root, from one host's administrator to the domain. A tester's impact assessment is precise only if it names which boundaries were crossed, which held, and why. This lesson maps the boundaries on Linux, Windows and in between, and examines the boundaries around your own sandbox.

The boundaries

Boundary Enforced by Crossing it legitimately Crossing it illegitimately is called
unauthenticated to authenticated the application, the identity provider logging in authentication bypass, credential theft
user to user (same level) access checks in the application or the file system sharing, delegation horizontal escalation, IDOR
service account to root / SYSTEM the kernel (UIDs, tokens) sudo, services designed to start as root and drop privileges vertical privilege escalation
process to kernel the CPU's privilege rings, the system-call interface system calls kernel exploit
container to host namespaces, cgroups, capabilities, seccomp, the container runtime none (by design) container escape
VM to hypervisor the hypervisor none VM escape
host administrator to domain Active Directory permissions, Kerberos, credential storage delegated administration lateral movement, domain escalation (next lessons)
standard user to administrator on Windows (same account) UAC, integrity levels (medium vs high) consent prompt, elevation UAC bypass (not a security boundary by Microsoft's own definition)

Two details matter in reports. On Linux, root's power is split into capabilities (CAP_NET_RAW, CAP_SYS_ADMIN, CAP_DAC_OVERRIDE…), so "root in a container" with few capabilities is far less than root on the host. On Windows, a process's rights come from its access token (user, groups, privileges such as SeImpersonatePrivilege or SeDebugPrivilege, integrity level), so "local administrator" in a medium-integrity process is not yet full control until it elevates.

Your sandbox as a set of boundaries

Every bash session in this track runs inside a container designed around these boundaries: an unprivileged user, no capabilities, a system-call filter, no network. Here is the sandbox checking them, which is also exactly what a tester does first after gaining command execution, to state precisely what was obtained:

bash · try it yourself
echo "== identity"
id
echo "== capabilities (hex masks) and filters"
grep -E '^(CapEff|CapBnd|NoNewPrivs|Seccomp):' /proc/self/status
python3 - <<'PY'
NAMES = ["CHOWN", "DAC_OVERRIDE", "DAC_READ_SEARCH", "FOWNER", "FSETID", "KILL", "SETGID", "SETUID",
         "SETPCAP", "LINUX_IMMUTABLE", "NET_BIND_SERVICE", "NET_BROADCAST", "NET_ADMIN", "NET_RAW",
         "IPC_LOCK", "IPC_OWNER", "SYS_MODULE", "SYS_RAWIO", "SYS_CHROOT", "SYS_PTRACE", "SYS_PACCT",
         "SYS_ADMIN", "SYS_BOOT", "SYS_NICE", "SYS_RESOURCE", "SYS_TIME", "SYS_TTY_CONFIG", "MKNOD",
         "LEASE", "AUDIT_WRITE", "AUDIT_CONTROL", "SETFCAP"]
status = dict(l.split(":\t") for l in open("/proc/self/status") if l.startswith("Cap"))
for field in ["CapEff", "CapBnd"]:
    mask = int(status[field], 16)
    caps = [n for i, n in enumerate(NAMES) if mask >> i & 1]
    print(f"{field}: {len(caps)} capabilities {', '.join(caps) or '(none)'}")
PY
echo "== the file-system boundary"
stat -c '%A %U:%G %n' /etc/passwd /etc/shadow
cat /etc/shadow 2>&1 | head -1
touch /etc/marker 2>&1
== identity
uid=1000(learner) gid=1000(learner) groups=1000(learner)
== capabilities (hex masks) and filters
CapEff:	0000000000000000
CapBnd:	00000000a80425fb
NoNewPrivs:	0
Seccomp:	2
CapEff: 0 capabilities (none)
CapBnd: 14 capabilities CHOWN, DAC_OVERRIDE, FOWNER, FSETID, KILL, SETGID, SETUID, SETPCAP, NET_BIND_SERVICE, NET_RAW, SYS_CHROOT, MKNOD, AUDIT_WRITE, SETFCAP
== the file-system boundary
-rw-r--r-- root:root /etc/passwd
-rw-r----- root:shadow /etc/shadow
cat: /etc/shadow: Permission denied
touch: cannot touch '/etc/marker': Permission denied

Reading the result as a tester would write it in a finding: the process runs as learner (uid 1000), with no effective capabilities; the bounding set (the most any process in this container could ever gain) is Docker's default list, which still contains SETUID and NET_RAW, but the effective set is empty, so the user has none of them. /etc/shadow is readable only by root and the shadow group, and the file system refuses writes to /etc. A command-execution finding in a service like this one would be reported as "code execution as an unprivileged user without capabilities, inside a container", which is much less than "root on the server", and the report should say so.

How boundary crossings are detected

  • Identity changes: Linux sudo and su log to the auth log or journal; auditd can record every setuid/execve where the effective UID becomes 0. Windows logs special-privilege logons (4672), explicit-credential logons (4648) and process creation with the token's elevation type (4688).
  • Capability and namespace changes: container runtime and EDR events for processes gaining capabilities, mounting file systems, or accessing the host's /proc and devices.
  • Access to protected files: auditd watches on /etc/shadow, /etc/sudoers; Windows SACLs on sensitive keys and the SAM.

How boundaries are kept strong

  • Run every service as its own unprivileged user; drop capabilities (CapabilityBoundingSet= in systemd units, --cap-drop=ALL for containers), set NoNewPrivileges, and enable seccomp profiles.
  • Don't run containers privileged, don't mount the Docker socket into them, and don't share the host's PID or network namespaces.
  • On Windows, use virtual service accounts or gMSAs rather than LocalSystem, remove unneeded privileges such as SeImpersonatePrivilege from service accounts where the application allows it, and treat UAC as a convenience, not a security boundary.
  • Separate administration: different accounts for user work and for administration, and different administrators for workstations, servers and the domain (tiering, in the AD course).

Pitfalls

  • Overstating impact. "Full compromise" from a shell as www-data in a container is wrong; state the identity, capabilities and what was actually reachable.
  • Understating it. A low-privileged account that can read a file with database credentials has crossed a boundary through data, not through the kernel. Count credential access as a crossing.
  • Treating UAC as a boundary. Bypassing it gives an administrator what they already had; it is a hardening issue, not a privilege escalation in the report's sense.

Practice

  1. The bounding set contains NET_RAW. Why can't the sandbox user still send raw packets?
  2. A tester gains code execution in an application container that has CAP_SYS_ADMIN and the host's /var/run/docker.sock mounted. Which boundary is at risk, and what should the finding recommend?
Answers
  1. The bounding set only limits what could be gained (through set-user-ID or file-capability programs). The effective set is empty, so the process can't use it now; it could gain it only through a set-user-ID-root or file-capability program in the image (a tester lists them with find / -perm -4000 and getcap -r /), and the network namespace has only loopback anyway.
  2. Container to host: access to the Docker socket is equivalent to root on the host (it can start a privileged container that mounts the host file system), and CAP_SYS_ADMIN weakens isolation further. Recommend removing the socket mount, dropping all capabilities not needed, running as a non-root user and using a read-only root file system. The proof is the presence of the socket and the capability, not their use.

Test yourself

What does the sandbox's empty CapEff mean?

  1. The process is root
  2. The process has no effective capabilities, whatever the bounding set allows
  3. Capabilities are unsupported
  4. Seccomp is off

A web flaw gives code execution as www-data. What should the finding claim?

  1. Root on the server
  2. Code execution as the unprivileged service user www-data, with what that user can reach
  3. Domain admin
  4. Nothing until root is obtained

Why is a mounted Docker socket in a container a critical finding?

  1. It is slow
  2. Control of the Docker daemon is equivalent to root on the host
  3. It leaks the container name
  4. It disables logging

Which Windows event records that special privileges were assigned to a new logon?

  1. 4624
  2. 4672
  3. 4688
  4. 7045