Skip to main content
Be Bitwise

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.

text
-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:

text
CAP_NET_BIND_SERVICE - Bind to ports below 1024
CAP_NET_RAW - Use raw sockets
CAP_SYS_PTRACE - Trace any process (strace, gdb)
CAP_SYS_ADMIN - Broad admin operations
CAP_DAC_OVERRIDE - Override file DAC permissions
CAP_NET_ADMIN - Network configuration
CAP_SYS_MODULE - Load kernel modules
CAP_SYS_RAWIO - Direct I/O access
bash
# Run a web server that can bind to port 80 without running as root
setcap cap_net_bind_service=+ep /usr/bin/myserver

seccomp: Syscall Filtering

seccomp (secure computing) clamps down on which syscalls a process is even allowed to attempt:

c
#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, exit
struct 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 filter
prctl(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:

bash
Process: system_u:system_r:httpd_t:s0
File: 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 it

AppArmor ditches the labelling and goes path-based — much friendlier to write, less rigorous in theory:

bash
# /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,
}
MAC vs DAC

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:

text
PID Namespace: Process sees its own PID tree (PID 1 inside container)
Network NS: Own network stack, interfaces, routing
Mount NS: Own filesystem mount tree
User NS: Own UID/GID mapping
UTS NS: Own hostname
IPC NS: Own IPC objects
Cgroup NS: Own cgroup view

Containers — 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):

text
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:

text
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 switch

Integrity levels add a second gate on top of the DACL check:

text
Process (Medium) → Write to → Object (High) → DENIED
Process (High) → Write to → Object (Medium) → ALLOWED
Process (Low) → Write to → Object (Medium) → DENIED

Put 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

Lx

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.

Linux
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 anyway
Subject identityfsuid, fsgid, supplementary groups, capability sets
Object protection9 mode bits (+ optional POSIX ACL), SELinux label
Rule order matters?Only one class is consulted; no fall-through
Explicit denyNot in mode bits; MAC policy denies
Mandatory layerSELinux/AppArmor, after DAC passes

AppContainer: Application Sandboxing

AppContainer arrived in Windows 8 for UWP, and a handful of Win32 apps now opt in too:

text
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)
Key Concept
Windows Defender Features

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 SurfaceLinuxWindows
Syscall interface~450 syscalls~450-500 Nt* calls in ntoskrnl, plus 1,000+ NtUser*/NtGdi* calls into win32k
Driver attack surfaceAll in kernel spaceMostly kernel, some UMDF
GUI attack surfaceX11/Wayland (user space)win32k.sys (kernel space!)
IPC attack surfaceD-Bus, sockets, pipesALPC, named pipes, COM, RPC
Privilege escalationSUID binaries, capabilitiesService accounts, UAC bypasses
Persistencecron, systemd, init scriptsServices, 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.