Description
The Yama security module adds the kernel.yama.ptrace_scope sysctl, which restricts the
ptrace system call used by debuggers to inspect and modify other processes:
0: a process can trace any process with the same user ID.1: a process can only trace its own descendants, unless the target allows it explicitly.2: only processes with theCAP_SYS_PTRACEcapability can useptrace.3: nobody can useptrace, and the value cannot be changed until the next reboot.
Ubuntu ships 1 in /etc/sysctl.d/10-ptrace.conf (/usr/lib/sysctl.d/55-ptrace.conf on 26.04):
the check passes on core profiles, and hardened profiles raise it to 2.
Rationale
With 0 (the kernel default), malware running as a user can attach to the user's SSH agent, password
manager or browser and read keys and session tokens from their memory. Limiting ptrace to
descendants keeps normal debugging (gdb ./program, strace command) working while blocking
attachment to unrelated running processes.
Impact
With 1, attaching a debugger to an already running process (gdb -p, strace -p) needs
root or CAP_SYS_PTRACE. With 2, every use of ptrace needs privileges, which breaks
debugging by regular users. 3 cannot be undone without a reboot.
Setting
| Location | sysctl `kernel.yama.ptrace_scope`, persisted in `/etc/sysctl.d/` |
| Default | 1 |
| Recommended | At least {{ ptrace_scope }} |
Parameters
| Parameter | Core | Server | Server hardened | Desktop | Desktop hardened | Bounds |
|---|---|---|---|---|---|---|
ptrace_scopeinteger. Minimum value of kernel.yama.ptrace_scope. | 1 | 1 | 2 | 1 | 2 | 1 to 3 |
The value used is your override (tailoring file), else the profile's, else the one of the profile it extends, else the default. Bounds limit what an override may set.
Audit
Run sysctl kernel.yama.ptrace_scope. The value must be at least {{ ptrace_scope }}.
Then check that no sysctl configuration file sets a lower value.
Automated: every check must pass. Scanners report each check by its id.
running
Running value of kernel.yama.ptrace_scope.
key: kernel.yama.ptrace_scope
operator: '>='
value: '{{ ptrace_scope }}'
Remediation
Create /etc/sysctl.d/60-cirsec.conf containing kernel.yama.ptrace_scope = {{ ptrace_scope }},
remove any other assignment of this key, then run sysctl --system.
| Restart | none |
| Disruption | low |
Rollback
Remove the line from /etc/sysctl.d/60-cirsec.conf and run sysctl -w kernel.yama.ptrace_scope=1.
A value of 3 can only be lowered by rebooting after removing the line.
set
Generated from check running: the engine writes the fix for every output, it sets the expected value and the check runs again after.
Each release turns these fixes into remediate.sh and an Ansible role per profile: dry run by default, a fix runs only when its check fails.
References
- Ubuntu Security documentation - Kernel protections Canonical, vendor-doc, accessed 2026-10-19
- Linux kernel documentation - Yama The Linux Kernel Organization, vendor-doc, accessed 2026-10-19
- ANSSI-BP-028 v2.0 - Recommandations de configuration d'un système GNU/Linux (R11) ANSSI, guide, accessed 2026-10-19
Mappings
| Framework | ID | Relation | Note |
|---|---|---|---|
| ANSSI-BP-028 - Recommandations de configuration d'un système GNU/Linux2.0 | R11 | equivalent | Both require a value of at least 1. |
| NIST SP 800-53 Rev. 55.1.1 | SC-39 | related |
How this control relates to the other framework's: equivalent, stricter, looser, partial or related.
Threats mitigated
| Taxonomy | ID |
|---|---|
| MITRE ATT&CK | T1055.008 |
| MITRE ATT&CK | T1003 |
People and lifecycle
| Authors |
|
| Verified | 2026-10-19 by Sn0wAlice on 20.04, Proxmox VM, Ubuntu 20.04 cloud image, kernel 5.4.0-216-generic, BIOS boot. Core passes on a fresh install (1); server-hardened fails, generated fix sets 2; kept after reboot; fix idempotent. |
| Verified | 2026-10-19 by Sn0wAlice on 22.04, Proxmox VM, Ubuntu 22.04 cloud image, kernel 5.15.0-198-generic, BIOS boot. Core passes on a fresh install (1); server-hardened fails, generated fix sets 2; kept after reboot; fix idempotent. |
| Verified | 2026-10-19 by Sn0wAlice on 24.04, Proxmox VM, Ubuntu 24.04 cloud image, kernel 6.8.0-147-generic, BIOS boot. Core passes on a fresh install (1); server-hardened fails, generated fix sets 2; kept after reboot; fix idempotent. |
| Verified | 2026-10-19 by Sn0wAlice on 26.04, Proxmox VM, Ubuntu 26.04 cloud image, kernel 7.0.0-38-generic, BIOS boot. Core passes on a fresh install (1); server-hardened fails, generated fix sets 2; kept after reboot; fix idempotent. |
| Introduced in | v0.1.0 |
| Created, updated | 2026-10-19, 2026-10-19 |
| Translations | fr |