index container security
When /proc/PID/root Still Leads to the Wrong File
A pinned Syft release that inventories the host while labelling the SBOM as a container and exiting 0, and an absolute symlink that makes a collector approve the wrong file. A reproducible Linux lab with recorded evidence and a scoped-lookup reference implementation.

/proc/PID/root looks like a doorway into another process's filesystem. Prefix
a path with it and you read the container's file. This post shows two ways that
assumption fails while every command still succeeds.
Case one: an SBOM of the host, labelled as the container. Run on a Linux host
against a Debian container, syft scan dir:/proc/PID/root (Syft 1.56.0) exited 0
and kept /proc/PID/root as its source label. Its dpkg inventory matched
a direct scan of the host:
| Scan | Distro reported | Package names | Lab-only yara package |
|---|---|---|---|
Host Syft, dir:/proc/PID/root |
Ubuntu 24.04 (the host) | 1,296 | absent |
| Same scan inside the container | Debian 12.15 | 110 | present |
1,205 of the 1,296 reported package names were absent from the container's dpkg inventory. No attacker and no planted symlink are involved.
Case two: a collector approves the wrong file. The collector opened
/proc/1/root/app/payment.py and reported the approved hash. Inside the workload,
/app/payment.py loaded different bytes. The difference was one absolute symlink:
/app/payment.py -> /app/real.py
A plain open() followed that link back into the collector's own root. It read
its reference copy of real.py, while the workload read the altered copy.
In the restricted-writer experiment, the writer ran as UID 10001 with zero effective Linux capabilities. It changed files in an existing shared application volume. The workload kept the same PID, root identity, and mount namespace. Nobody reconfigured the deployment between the before and after observations.
| Observation | SHA-256 prefix |
|---|---|
Naive collector using /proc/1/root/... |
b6eded2c883e060c… |
| Workload's newly loaded fixture | a450d3b3d0f76a09… |
Collector using scoped openat2 lookup |
a450d3b3d0f76a09… |
The two cases have different causes, and the source code explains each one below.
Get Wrong Root Lab on GitHub, or download the tested lab snapshot and recorded evidence. The Python fixtures print JSON messages and use a harmless YARA marker.
Reproduce the result
Clone the lab and run it:
git clone https://github.com/nadimjsaliby/wrong-root-lab.git
cd wrong-root-lab
python3 run_lab.py
python3 demo.py
The published results use lab revision 4247ff6.
The downloadable snapshot includes the recorded evidence; extract it and run the
same Python commands inside filesystem-view-lab.
The runner builds the image, tests 19 scenarios, saves JSON evidence, and cleans
up its containers and named volume. The demo prints a summary of the saved
observations. For the restricted-writer result, inspect
evidence/latest/unprivileged-volume-writer.json.
Both of these environments passed the complete suite:
| Environment | Architecture | Docker | Compose | YARA |
|---|---|---|---|---|
| Linux, kernel 6.8.0-110-generic | x86_64 | 29.2.1 | 5.0.2 | 4.2.3 |
| macOS client with OrbStack, Linux VM kernel 7.0.14-orbstack-00380-ga7e0a2dc9535 | arm64 | 29.4.0 | 5.1.2 | 4.2.3 |
Requirements are Python 3.9+ on the client and a Linux Docker engine with kernel
5.6+ and Compose. The initial build downloads packages. Lab containers have no
network, published ports, Docker socket, or host PID namespace. The collector
uses CAP_SYS_PTRACE within the workload's PID namespace.
The Syft cases have their own scripts. python3 test_syft.py runs the
container-to-container comparison anywhere the core lab runs.
python3 test_syft_host.py runs the host-level scan and needs a Linux Docker
host with a local Docker daemon, passwordless sudo, and the image built by
test_syft.py. It records only a redacted summary by default,
because a full SBOM of your host is an inventory of that machine.
Tested with OrbStack; Docker Desktop is untested. A remote Linux Docker host is another option if your local engine cannot provide the required process-inspection access.
Case one: Syft inventories the host and labels it as the container
Syft is a widely used SBOM generator. A node-level agent that wants an inventory of a running container can point it at that container's process root. With pinned v1.56.0, run as root on the Ubuntu 24.04 lab host against a Debian 12 container:
sudo syft scan dir:/proc/PID/root \
--override-default-catalogers dpkg-db-cataloger -o syft-json
The runner applies the same cataloger and exclusion settings to three scans:
the requested process root, the host's own dir:/, and dir:/ inside the
container. It compares package type, name, and version, plus distro identity.
The table counts distinct package names. Full arguments are in the evidence;
the runner excludes virtual filesystems, container storage, and private trees.
| Scan | Exit | SBOM source label | Distro | Package names | yara |
|---|---|---|---|---|---|
Host, dir:/proc/PID/root |
0 | /proc/PID/root |
Ubuntu 24.04 | 1,296 | absent |
Host control, dir:/ |
0 | / |
Ubuntu 24.04 | 1,296 | absent |
Inside the container, dir:/ |
0 | / |
Debian 12.15 | 110 | present |
The lab image installs yara; this host does not. The process-root scan matched
the direct host control's package identities and distro, while 1,205 package
names were absent from the container control. Those names include the host's
kernel image and SSH server. The source label still names the container's
process root and the exit code is zero, but the inventory describes the host
filesystem. This comparison covers dpkg packages, not every software component.
The cause was already reported
Ariel Miculas found the mechanism first. In
issue #3396, opened in October 2024,
they traced it to Syft's directory resolver calling filepath.EvalSymlinks on the
requested path. /proc/PID/root is a kernel magic link, and reading its link text
returns /, which Syft then resolves in its own mount namespace. They also opened
PR #3423 to add mount-namespace support.
The pinned v1.56.0 source still has that path. The directory resolver builds a
normalized root context,
and NormalizeRootDirectory calls filepath.EvalSymlinks
on the requested root. Path evaluation rewrites /proc/PID/root to the
host's own / before indexing starts. The namespace transition is lost as
pathname text, so any path below it is resolved on the host.
The issue documents the case that fails. Scanning a path that exists only in the
target exits with an error, and this lab reproduces it: asking for
dir:/proc/PID/root/catalog, a directory that exists only in the container,
exits 1 and names the mechanism:
could not evaluate root="/proc/PID/root/catalog" symlinks: lstat /catalog: no such file or directory
This post adds the case that succeeds. A path that also exists on the host, such
as / in the main result, exits 0 with the host's contents under the container's
label. A second experiment shows the same rewrite between two containers: a
collector container scanning dir:/proc/1/root/catalog reported its own synthetic
package version (1.0.0) rather than the workload's (9.9.9), on both Linux x86_64
and OrbStack arm64.
Unsupported input that exits 0
This is not a Syft vulnerability. Scanning another mount namespace is not a supported feature; upstream tracks it as an enhancement request, and nothing here crosses a privilege boundary. The scan runs as root and reads files root can already read.
The problem is how the unsupported input behaves. It does not refuse. Depending on
which paths happen to exist on the host, it either fails with a confusing lstat
error or succeeds with the wrong filesystem, a zero exit code, and a source label
that names the container. A pipeline that trusts exit codes and labels records the
host inventory as the container's SBOM.
As checked on November 3, 2026, the issue and the PR remain open. The measured
result applies to v1.56.0 and these arguments; retest the actual release used in
your pipeline rather than relying on issue status alone. For this version, avoid
cross-namespace /proc/PID/root inputs to the directory source. Scan in the
target's context, as the control does. Image scanning answers a different
question: it does not inventory files added or replaced through runtime volumes.
Check a known difference between host and target, such as distro identity or a
target-only package, alongside the scan's cataloger selection and errors.
Case two: who controls what?
Consider an application that loads scripts or plugins from a shared volume. A publishing worker has write access to that storage. The application mounts it read-only, and a separate collector checks the application's files against a trusted digest policy.
If the publishing worker is compromised, it can modify the shared files without controlling Docker or the collector. The collector is supposed to notice those changes. A read-only mount in the application does not stop a different writer from changing the underlying volume.
The attacker wants the collector to report approved bytes after the workload starts loading changed bytes.
False approval requires the collector to already have approved bytes at the
absolute symlink destination, /app/real.py. The lab supplies them by building
the collector and workload from the same image. This condition can also hold for
a sidecar built from the application image, or a collector shipping a reference
tree at those paths. A host agent or DaemonSet with no file at that destination
would get a missing-file error instead. The attacker cannot create or modify
the collector's copy.
The lab makes that boundary explicit:
| Component | Authority |
|---|---|
| Writer | UID 10001; write access to /shared; no capabilities, network, Docker socket, or target PID namespace. |
| Workload | Reads the same volume at /app; reloads a changed fixture; no capabilities. |
| Collector | Reads the workload's process view; owns its separate reference files and trusted hash policy. |
The writer replaces a file with a symlink and changes the linked fixture. These are ordinary filesystem operations within its existing permissions. The lab's trusted initialization step creates and assigns that volume before the test.
This is a detector-integrity experiment: the attacker already has application content-write access. The failed boundary is the collector's interpretation of that content, not a new way to obtain host privileges.
Why the absolute symlink changes the answer
Linux mount namespaces give processes different filesystem hierarchies.
/proc/PID/root lets an authorized observer begin a lookup in another process's
root and mount view. That entry point does not automatically confine all later
symlink resolution. Linux process-root documentation
In the symlink fixture, the path walk starts in the workload:
/proc/1/root/app/payment.py
|
+--> /app/real.py (absolute symlink)
With plain open(), the absolute target is resolved from the calling collector's
root. Because of the precondition above, the collector gets its own approved
/app/real.py rather than a missing-file error.
The corrected lookup opens the target root as a directory descriptor, then uses that descriptor as the root for the entire resolution:
root_fd = open("/proc/PID/root", O_PATH | O_DIRECTORY)
file_fd = openat2(root_fd, "/app/payment.py",
resolve=RESOLVE_IN_ROOT | RESOLVE_NO_MAGICLINKS)
RESOLVE_IN_ROOT keeps ordinary absolute symlink resolution within the supplied
root. RESOLVE_NO_MAGICLINKS rejects magic-link traversal during that scoped
walk. The initial trusted /proc/PID/root handle is obtained separately.
Linux openat2 documentation
The checker fails explicitly if this operation is unavailable or denied.
This problem has a history
Container-relative symlink handling predates this lab. In the 2019 disclosure
of CVE-2018-15664, Aleksa Sarai described a docker cp time-of-check/time-of-use
race involving scoped symlink resolution and later filesystem operations.
The disclosure also references earlier Docker copy-related work.
Original disclosure
That race and this deterministic wrong-root lookup are different failure modes
within the same broader problem: a privileged observer must preserve the
intended filesystem boundary while resolving untrusted paths. openat2 provides
kernel-enforced resolution controls; established projects such as
filepath-securejoin also address
safe rooted lookup. The contribution here is a small executable regression lab
and measured collector behavior.
Check the target without mirroring its filesystem
The reference implementation checks one target file against reviewed digests. It does not require a matching file in the collector:
sudo python3 src/viewcheck.py \
--pid TARGET_PID \
--path /app/payment.py \
--policy /path/to/trusted-policy.json
The comparison mode used in the visual demonstrations is an optional
--compare-observer flag. A regression case hides the collector's /app
entirely and confirms that target-only checking still detects the difference.
The implementation supports regular files up to 8 MiB, emits structured JSON, and has three exit statuses:
| Exit | Meaning |
|---|---|
| 0 | The target's sampled bytes match the reference or an explicitly approved override. |
| 1 | A digest-policy mismatch. |
| 2 | The check is incomplete: access denied, missing file, invalid policy, scanner failure, or observed instability. |
YARA is optional. When enabled, it opens /proc/self/fd/N using an inherited
descriptor for the already-selected object. Hashing and scanning refer to that
same file object without repeating the untrusted pathname lookup.
A legitimate override passes only when its exact digest appears in the policy. Different inodes containing identical bytes are accepted. Different mount namespaces alone do not trigger an incident.
The limit that matters: current bytes versus executed bytes
One scenario loads the reference fixture, records its exact byte-buffer hash, and executes it. The runner then replaces the file with the altered fixture.
Loaded at startup: b6eded2c883e060c…
Current target file: a450d3b3d0f76a09…
The corrected checker reports the changed current file. It cannot conclude that the changed bytes already executed. The controlled launcher's receipt gives this experiment its ground truth; a production investigation needs independent execution evidence.
The samples are also point-in-time observations. File metadata, process start ticks, root identity, and namespace checks catch some concurrent changes, but there is no atomic snapshot of all filesystem and process state. The README records those implementation limits in detail.
Keep a regression case for every collector
For an SBOM pipeline, include a target-only package in the control and enable the cataloger that can discover it. A missing marker is a reason to investigate: exclusions or cataloger failures can also explain it. In this experiment, the matching host inventory and differing target control establish the wrong view.
For a file collector, the most useful artifact is the symlink fixture: put different marker bytes at the same absolute target in the collector and workload, then assert which bytes your collector obtains. A missing file often exposes a bad lookup. A plausible reference file can conceal it.
The lab's suite covers that fixture and more: approved and unapproved overrides, identical bytes in different objects, missing processes, denied access, scanner errors, a file replaced after load, a missing target, and a FIFO that must not block the collector. It also verifies the restricted writer and target-only mode.
Both cases end the same way: the command returned data, the exit code was 0, and the label named the right process. The missing fact was whose filesystem had actually been inspected.