On this page
Self-hosted CI runners often build images with Docker. PMG checks the packages that a job step installs. On runners where Docker runs inside the runner container, the installs inside a Docker build skip that check by default. A malicious package then installs, and the build passes. SafeDep reproduced this on a lab runner. With the PMG container trust switch on, the same build failed at the malicious package.
This post covers runners where the Docker daemon runs inside the runner container, such as summerwind Actions Runner Controller (ARC). The same gap applies to containers that a job starts with Docker and to job containers.
TL;DR
- Without the switch, PMG blocked the malicious test packages (
safedep-test-pkgfor npm and pip) only in the job step. The image build,docker runwith npm and pip, and the job container installed them, and their steps passed. - With
PMG_CONTAINER_TRUST=1, every place got a 403 for the malicious package, and the normal packages installed. - If the containers use a forward proxy in the runner container, PMG intercepts their installs, but the containers do not trust the PMG certificate authority (CA). With the switch off, the npm installs in the lab failed on the certificate. With the switch on, they gave the same results as without a proxy.
- The switch puts
pmg-runc, a wrapper for runc, between the Docker daemon and runc. It gives each container the PMG CA before the container starts.
Why container installs skip the check
On a runner, PMG runs as a persistent proxy daemon. It attaches eBPF programs to the cgroup of the runner container. The kernel then sends each registry connection of a job step to PMG (how it works(opens in new tab)). The Docker daemon starts each container in another cgroup and another network namespace, so container traffic does not pass through PMG.
With no forward proxy, a container install goes straight to the registry, and PMG does not check it.
Through a forward proxy in the runner container, such as Squid, the install fails. PMG enforces the cgroup of the
runner container, so it intercepts the connections from the proxy to the registry. It answers with a certificate from
the PMG CA, and the container does not trust that CA. In a lab run with Squid at http://172.17.0.1:3128, npm retried
for about 70 seconds, then failed:
#6 [3/3] RUN npm install --no-audit --no-fund safedep-test-pkg@0.1.3
#6 70.34 npm error code UNABLE_TO_VERIFY_LEAF_SIGNATURE
#6 70.34 npm error errno UNABLE_TO_VERIFY_LEAF_SIGNATURE
#6 70.34 npm error request to https://registry.npmjs.org/safedep-test-pkg failed, reason: unable to verify the first certificate
#6 70.34 npm error A complete log of this run can be found in: /root/.npm/_logs/2026-11-24T19_12_28_131Z-debug-0.log
ERROR: failed to solve: process "/bin/sh -c npm install --no-audit --no-fund ${PKG}" did not complete successfully: exit code: 1is-number@7.0.0 failed in the same way, so the build breaks for normal packages too.
A wrapper around the Docker CLI can add a volume and a variable to docker run and pass the CA in. A RUN step of a
Docker build has no such options. Only a Dockerfile change, such as a secret mount, or the container runtime can reach
it (trust inside a container(opens in new tab)).
PMG has a container redirect, the --enforce-namespaces redirect flag, that sends container traffic to PMG. Alone, it
does not make the container trust the PMG CA, so the TLS handshake still fails
(trust inside a container(opens in new tab)).
The switch turns on the redirect and gives each container the CA through pmg-runc.
How pmg-runc works
The Docker daemon and the BuildKit inside it start every container with the first runc on PATH. When the switch is
on, the runner entrypoint links /usr/local/sbin/runc to pmg-runc, so the daemon finds the wrapper first
(pmg-entrypoint.sh L210-224(opens in new tab)).
This is the Open Container Initiative (OCI) runtime wrapper pattern that the
NVIDIA Container Toolkit(opens in new tab)
uses for GPUs.
For each container that runc creates, pmg-runc edits the OCI config.json of the container
(main.go L211-293(opens in new tab)).
Then it runs the real runc with the same arguments. The edit does these things:
- It mounts the PMG CA and a CA bundle read-only in
/dev/pmg-ca. That directory is on the tmpfs of the container, so an image build does not keep the files in a layer. - It sets
NODE_EXTRA_CA_CERTS,SSL_CERT_FILE,REQUESTS_CA_BUNDLE,PIP_CERTandUV_NATIVE_TLS(main.goL389-413(opens in new tab)). If the image sets a CA variable, such asSSL_CERT_FILE, to its own CA file, the container gets a copy of it. The copy has the PMG CA added (main.goL360-387(opens in new tab)). Any other variable that the container sets keeps its value. - When buildx runs BuildKit in its own container (the
docker-containerdriver),pmg-runcmounts itself in front of the runc of that BuildKit. The build steps then get the same edit. - For a process that
runc execstarts, it adds the same variables.
pmg-runc refuses any file that holds a private key
(main.go L295-316(opens in new tab))
and opens image files with openat2 and RESOLVE_IN_ROOT
(main.go L466-492(opens in new tab)).
If it cannot change a container, it starts the container unchanged, and an install there fails on the certificate.
In the lab runner with the switch on, a shell in the runner container started a node:22-slim container (ID
28d8cc35a8f2, PID 3802). It then showed the variables and read-only mounts of that container, the wrapper log and the runc link:
$ sudo cat /proc/3802/environ | tr '\0' '\n'
UV_NATIVE_TLS=1
NODE_EXTRA_CA_CERTS=/dev/pmg-ca/ca.pem
NODE_VERSION=22.23.5
HOSTNAME=28d8cc35a8f2
YARN_VERSION=1.22.22
HOME=/root
SSL_CERT_FILE=/dev/pmg-ca/ca-bundle.pem
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
REQUESTS_CA_BUNDLE=/dev/pmg-ca/ca-bundle.pem
PWD=/
PIP_CERT=/dev/pmg-ca/ca-bundle.pem
$ sudo grep pmg-ca /proc/3802/mountinfo | cut -d' ' -f4,5,6
/etc/pmg-runc/ca.pem /dev/pmg-ca/ca.pem ro,relatime
/etc/pmg-runc/ca-bundle.pem /dev/pmg-ca/ca-bundle.pem ro,relatime
$ sudo grep 28d8cc35a8f2 /var/log/pmg-runc.log
2026-11-24T18:35:11Z pmg-runc: ca added to 28d8cc35a8f260573509acefd088d925b90b3a7184f92f025bc752749e20ebe5
$ ls -l /usr/local/sbin/runc
lrwxrwxrwx 1 root root 29 Nov 24 18:32 /usr/local/sbin/runc -> /opt/safedep/pmg/bin/pmg-runcSet it up
You need PMG v0.37.0 or later, and a runner image that starts with the PMG runner entrypoint. The ARC runners guide(opens in new tab) shows how to build it. The nodes need Linux 5.15 or later, kernel BTF and cgroup v2. The image is three lines on top of the summerwind dind image:
FROM summerwind/actions-runner-dind:ubuntu-22.04
COPY --from=ghcr.io/safedep/pmg:v0.37.0 /opt/safedep/pmg /opt/safedep/pmg
ENTRYPOINT ["/opt/safedep/pmg/bin/pmg-entrypoint.sh"]
CMD ["entrypoint-dind.sh"]Then set PMG_CONTAINER_TRUST=1 on the runner container:
apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
name: pmg-pilot
spec:
template:
spec:
organization: <your-org>
labels: [pmg-pilot]
image: <your-registry>/actions-runner-dind-pmg:<tag>
dockerdWithinRunnerContainer: true
env:
- name: PMG_CONTAINER_TRUST
value: '1'When the switch is on, the entrypoint does three things before the runner starts:
- It starts PMG with the container redirect.
- It copies the PMG CA certificate and the CA bundle to
/etc/pmg-runc. - It links
/usr/local/sbin/runctopmg-runc.
The Docker daemon must run in the runner container. If DOCKER_HOST is set, as with a Docker-in-Docker (dind)
sidecar, the entrypoint stops with an error
(pmg-entrypoint.sh L191-194(opens in new tab)).
To turn the switch off, remove the variable and start the Pod again.
Check it on your runner
Build an image that installs the test package safedep-test-pkg. The package is benign, and SafeDep flags it as
malicious, so anyone can test a block. The lab used this Dockerfile:
FROM node:22-slim
ARG PKG
WORKDIR /app
RUN npm install --no-audit --no-fund ${PKG}This step from the full lab workflow, in the Results section, builds it:
- name: docker build safedep-test-pkg
if: always()
run: docker build --no-cache --progress plain --build-arg PKG=safedep-test-pkg@0.1.3 dockerThe excerpts below come from the GitHub Actions job logs. They drop the timestamps, the step header and the build steps before the RUN step. The switch-on build also drops the BuildKit repeat of the npm error.
Without the switch, the build installed the malicious package and the step passed:
#6 [3/3] RUN npm install --no-audit --no-fund safedep-test-pkg@0.1.3
#6 0.442
#6 0.442 added 1 package in 260ms
#6 DONE 0.5s
#7 exporting to image
#7 exporting layers 0.0s done
#7 writing image sha256:ec0144d529753fdc36680b5f21ab5097aaa47b5b16a7187a88ec82e94542354f done
#7 DONE 0.1sIn the switch-on build, npm got a 403 from PMG, and the step failed:
#6 [3/3] RUN npm install --no-audit --no-fund safedep-test-pkg@0.1.3
#6 0.326 npm error code E403
#6 0.326 npm error 403 403 Forbidden - GET https://registry.npmjs.org/safedep-test-pkg/-/safedep-test-pkg-0.1.3.tgz
#6 0.326 npm error 403 In most cases, you or one of your dependencies are requesting
#6 0.326 npm error 403 a package version that is forbidden by your security policy, or
#6 0.326 npm error 403 on a server you do not have access to.
#6 0.326 npm error A complete log of this run can be found in: /root/.npm/_logs/2026-11-24T18_34_13_995Z-debug-0.log
#6 ERROR: process "/bin/sh -c npm install --no-audit --no-fund ${PKG}" did not complete successfully: exit code: 1
ERROR: failed to solve: process "/bin/sh -c npm install --no-audit --no-fund ${PKG}" did not complete successfully: exit code: 1
##[error]Process completed with exit code 1.On your runner, expect the 403 from PMG and a failed step. If the step passes, the containers on that runner get no PMG check.
Results
The lab used this setup:
- Cluster: a local Kubernetes cluster, with one runner Pod for each phase, first with the switch off and then on.
- Image:
summerwind/actions-runner-dind:ubuntu-22.04with PMG and buildx v0.24.0 added. - Versions: Docker 28.0.4, runner 2.338.2, Node.js v22.23.5 and npm 10.9.9.
- PMG: commit 472e1f9(opens in new tab) from pull request #638(opens in new tab), before any release.
- Label: the lab used a test label. To run the workflow on your own pool, change only the
pmg-pilotlabel.
The malicious packages were safedep-test-pkg@0.1.3 for npm and safedep-test-pkg==0.0.4 for pip.
| Where the install runs | Switch off | Switch on |
|---|---|---|
| Job step | Blocked403 | Blocked403 |
Image build (docker build) | Installedstep passed | Blocked403 |
Container, npm (docker run) | Installedstep passed | Blocked403 |
Container, pip (docker run) | Installedstep passed | Blocked403 |
Job container (container:) | Installedstep passed | Blocked403 |
The normal packages, is-number@7.0.0 and six==1.16.0, installed in every place, with the switch off and on.
The job container showed the same change as the image build:
added 1 package in 203msnpm error code E403
npm error 403 403 Forbidden - GET https://registry.npmjs.org/safedep-test-pkg/-/safedep-test-pkg-0.1.3.tgz
npm error 403 In most cases, you or one of your dependencies are requesting
npm error 403 a package version that is forbidden by your security policy, or
npm error 403 on a server you do not have access to.
npm error A complete log of this run can be found in: /github/home/.npm/_logs/2026-11-24T18_33_35_774Z-debug-0.log
##[error]Process completed with exit code 1.A second lab run gave the containers Squid, in the runner container, as their proxy at http://172.17.0.1:3128. It
tested the image build, docker run and the job container, with npm only:
| Where the install runs | Switch off | Switch on |
|---|---|---|
Image build (docker build) | Failedcertificate error, no check | Blocked403 |
Container, npm (docker run) | Failedcertificate error, no check | Blocked403 |
Job container (container:) | Failedcertificate error, no check | Blocked403 |
The normal package is-number@7.0.0 failed with the same certificate error when the switch was off, and it installed
when the switch was on.
Limits
- Host network containers get no check. A malicious package installs in a
--network hostcontainer. - Some containers get no CA, so their installs fail. This covers containers started with
-v /dev:/devand the containers that adocker:dindcontainer starts. For a-v /dev:/devcontainer,/var/log/pmg-runc.lognames the cause. - Some clients ignore the CA variables and fail. Java, wget built with GnuTLS, Bun 1.2 and code that sets its own CA file fail on the certificate.
- A proxy on the Docker bridge sees runner traffic from
169.254.200.1. With the switch on, PMG adds this address in the runner container, and runner traffic to that proxy comes from it. Add the address to the proxy access list. - A Docker daemon in a sidecar is not supported. With the switch on, the entrypoint stops with an error when
DOCKER_HOSTis set.
The
pmg-runc docs(opens in new tab)
give the details.
Get started
Build the runner image from the ARC runners guide above and set PMG_CONTAINER_TRUST=1 on one pilot pool. Then run the check above on that pool, and read
kernel enforcement(opens in new tab) for the kernel side of the setup.
Related reading
- pmg
- docker
- ci-cd
- self-hosted-runners
- github-actions
- kubernetes
- supply-chain
- malicious-package