Security Models Compared
Linux vs Windows Internals Compared · Operating Systems track
8 min read
In this module
Defending the Operating System
Linux and Windows draw their security architectures very differently, even though they've drifted toward broadly the same goals: defence in depth, minimum necessary privilege, policy enforcement that doesn't ask the user's permission. If your job is to harden or break either platform, you'll meet both models sooner rather than later — and knowing where they diverge is what matters.
Linux Security: Layers of Defence
DAC: Traditional Unix Permissions
The bottom layer is Discretionary Access Control: that ancient owner-group-others trio that's been on Unix since the seventies.
-rwxr-xr-- 1 alice developers 8192 Jan 15 10:30 program │││ │││ │││ │││ │││ └── Others: read only │││ └└└──── Group (developers): read + execute └└└──────── Owner (alice): read + write + execute"Discretionary" because the file's owner gets to set the rules. Root short-circuits all of it.
Capabilities: Splitting Root Powers
Capabilities chop root's blanket power into bite-sized permissions you can hand out individually:
CAP_NET_BIND_SERVICE - Bind to ports below 1024CAP_NET_RAW - Use raw socketsCAP_SYS_PTRACE - Trace any process (strace, gdb)CAP_SYS_ADMIN - Broad admin operationsCAP_DAC_OVERRIDE - Override file DAC permissionsCAP_NET_ADMIN - Network configurationCAP_SYS_MODULE - Load kernel modulesCAP_SYS_RAWIO - Direct I/O access# Run a web server that can bind to port 80 without running as rootsetcap cap_net_bind_service=+ep /usr/bin/myserverseccomp: Syscall Filtering
seccomp (secure computing) clamps down on which syscalls a process is even allowed to attempt:
#include <linux/seccomp.h>#include <linux/filter.h>#include <linux/audit.h>#include <sys/prctl.h>#include <sys/syscall.h>#include <stddef.h>
// Simple seccomp-bpf filter: allow only read, write, exitstruct sock_filter filter[] = { // Syscall numbers differ per ABI, so check the architecture first BPF_STMT(BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, arch)), BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, AUDIT_ARCH_X86_64, 1, 0), BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS), BPF_STMT(BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, nr)), BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_read, 0, 1), BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_write, 0, 1), BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_exit_group, 0, 1), BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS), // Kill on any other syscall};
struct sock_fprog prog = { .len = sizeof(filter) / sizeof(filter[0]), .filter = filter,};
// An unprivileged process must promise never to gain privileges// (no setuid exec) before it may install a filterprctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog);A real filter would also handle the x32 ABI, which shares AUDIT_ARCH_X86_64 but sets bit 30 of the syscall number; libseccomp generates these checks for you.
Chrome, Firefox, Docker, and systemd all lean on seccomp to box processes in.
SELinux and AppArmor: Mandatory Access Control
SELinux slaps a security label on every process, file, and socket and runs the lot against a central policy:
Process: system_u:system_r:httpd_t:s0File: system_u:object_r:httpd_sys_content_t:s0
Policy rule:allow httpd_t httpd_sys_content_t : file { read open getattr };# httpd can ONLY read files labelled httpd_sys_content_t# Even if DAC permissions allow more, SELinux blocks itAppArmor ditches the labelling and goes path-based — much friendlier to write, less rigorous in theory:
# /etc/apparmor.d/usr.bin.firefox/usr/bin/firefox { /usr/lib/firefox/** mr, /tmp/** rw, /home/*/.mozilla/** rw, deny /etc/shadow r, deny /boot/** rwx, network tcp,}Discretionary Access Control (DAC) lets resource owners set permissions. Mandatory Access Control (MAC) enforces system-wide policies that even root cannot override (in enforcing mode). A process running as root under SELinux still cannot access files outside its security policy. This limits the damage from privilege escalation: even if an attacker gets root, MAC confines what root can do.
Linux Namespaces: Container Isolation
Namespaces hand each process a private view of various system resources:
PID Namespace: Process sees its own PID tree (PID 1 inside container)Network NS: Own network stack, interfaces, routingMount NS: Own filesystem mount treeUser NS: Own UID/GID mappingUTS NS: Own hostnameIPC NS: Own IPC objectsCgroup NS: Own cgroup viewContainers — Docker, Podman, the lot — are really just clever assemblies of namespaces, cgroups, seccomp filters, and capability drops glued together.
Windows Security: Token-Based Access Control
Access Tokens and ACLs
Windows security pivots on two structures: access tokens (who's running this code) and security descriptors (who's allowed to touch the resource):
Process Token:├── User SID: S-1-5-21-...-1001 (alice)├── Group SIDs: Administrators, Users, ...├── Privileges: SeDebugPrivilege, SeBackupPrivilege, ...├── Integrity Level: Medium└── Logon Session ID
Object Security Descriptor:├── Owner: S-1-5-21-...-1001├── DACL:│ ├── Allow Administrators: Full Control│ ├── Allow alice: Read, Write│ └── Deny Guest: All└── SACL: └── Audit Everyone: Write (failure)UAC and Integrity Levels
UAC hands every admin two tokens, not one:
Admin User Logon:├── Filtered Token (Medium Integrity)│ - Admin group SID present but disabled│ - Used by default for all processes│ - Cannot write to Program Files, HKLM, etc.└── Full Token (High Integrity) - Admin group SID enabled - Only used when elevation is approved - UAC consent dialogue triggers the switchIntegrity levels add a second gate on top of the DACL check:
Process (Medium) → Write to → Object (High) → DENIEDProcess (High) → Write to → Object (Medium) → ALLOWEDProcess (Low) → Write to → Object (Medium) → DENIEDPut the pieces together and you get each kernel's answer to one question: may this process open that file for writing? Flip between the tabs, then switch on side-by-side to see where the two algorithms part ways. The step order is simplified (Windows also has privilege checks such as SeBackupPrivilege, and owner-implied rights), but the shape is right.
Access check: open a file for writing
Linux: mode bits, then capabilities, then LSM
The kernel picks exactly one class of permission bits (owner, group or other) and checks only that class. Capabilities can override DAC, and an LSM such as SELinux gets the final say.
1. fsuid == file owner? use owner bits
else in file's group? use group bits
else use other bits
2. bit missing? CAP_DAC_OVERRIDE can still allow it
3. LSM hook (SELinux/AppArmor) may deny anywayAppContainer: Application Sandboxing
AppContainer arrived in Windows 8 for UWP, and a handful of Win32 apps now opt in too:
AppContainer properties:- Unique SID per application- No access to user's files by default- Must declare capabilities: - internetClient: outbound network - documentsLibrary: user's Documents folder - microphone: audio capture- Network loopback blocked by default- Cannot access named objects (pipes, shared memory)Modern Windows includes multiple defence layers: Windows Defender Antivirus (real-time scanning), Windows Defender Exploit Guard (ASLR, DEP, CFI enforcement), Credential Guard (isolated LSASS using virtualisation), App Control for Business, formerly WDAC and once branded Device Guard (code integrity policies), memory integrity/HVCI (kernel code integrity enforced by the hypervisor), and Windows Sandbox (disposable VM for running untrusted software). These features use hardware-based virtualisation (VBS - Virtualisation Based Security) to create security boundaries that even kernel-level malware cannot cross.
Attack Surface Comparison
| Attack Surface | Linux | Windows |
|---|---|---|
| Syscall interface | ~450 syscalls | ~450-500 Nt* calls in ntoskrnl, plus 1,000+ NtUser*/NtGdi* calls into win32k |
| Driver attack surface | All in kernel space | Mostly kernel, some UMDF |
| GUI attack surface | X11/Wayland (user space) | win32k.sys (kernel space!) |
| IPC attack surface | D-Bus, sockets, pipes | ALPC, named pipes, COM, RPC |
| Privilege escalation | SUID binaries, capabilities | Service accounts, UAC bypasses |
| Persistence | cron, systemd, init scripts | Services, registry Run keys, scheduled tasks |
One architectural decision dominates the security comparison. Windows runs its window manager (win32k.sys) inside the kernel for the speed wins, and that single choice plops a vast attack surface into ring 0. Linux keeps its display server (X11, Wayland) in user space, though the in-kernel DRM and GPU drivers it talks to are a large attack surface on both platforms.
Both have stacked up serious layered defences, and arguing which is "safer" in the abstract is a waste of breath. Real-world security comes down to configuration discipline, patch cadence, and whether anyone actually switched on the protections that ship turned off by default.