Skip to main content

Module process_hardening

Module process_hardening 

Source
Expand description

Keeping other processes of the same user out of srv’s and the host’s memory.

The host’s IPC token and the launcher’s secrets live in these processes’ memory. An ordinary process of the same user could otherwise read them with ptrace, process_vm_readv or /proc/<pid>/mem (Linux), or by attaching a debugger (macOS). deny_memory_access turns that off for the calling process: on Linux the process is marked not dumpable (/proc/<pid>/mem, environ, maps, fd/ and ptrace need CAP_SYS_PTRACE from then on; the flag resets by itself in anything the process execs, so the agents srv starts are unaffected); on macOS PT_DENY_ATTACH refuses debugger attach; on Windows the process’s access-control list stops other processes of the user reading or changing its memory (see [win]).

The host calls it once CEF is initialized, not at startup: Chromium’s user-namespace sandbox launches the zygotes from the browser process during CefInitialize, and a non-dumpable browser process cannot (No usable sandbox!). Every helper is started from those zygotes or by exec, so none of them inherits the flag.

On Windows the launcher calls it too, at startup: it holds the handles it started srv and the host with.

Left alone, on purpose: a headless srv (it runs without a launcher, and the launcher’s check for an orphaned one reads its environment), a dev build (people attach debuggers to those), and any process started with AGENTMUX_ALLOW_PTRACE=1.

A process that holds SeDebugPrivilege enabled (an elevated admin token) ignores the access-control list on Windows, so it can still read a hardened process; this is by design and the tests that look for a refusal skip on such a runner (debug_privilege).

Enums§

Skipped
Why deny_memory_access left the process as it was, if it did.

Constants§

ALLOW_PTRACE_ENV
Set to anything non-empty to leave a process attachable (a debugger, perf).

Functions§

apply
Applies the control, whatever the policy says (deny_memory_access decides first).
decide
What to do for a process, from the facts about it. Pure, so the policy is tested.
deny_memory_access
Denies other processes of this user access to this process’s memory, unless the process is a dev build, headless, or started with ALLOW_PTRACE_ENV. Never fails the caller: a platform without the control, or a refusal, leaves the process as it was. Returns whether the control was applied.
relax
restore