glsec

Rules / GL060

GL060 docker run mounting sensitive host paths

Severity: error for /, /etc, /root, /proc, /sys; warn for /var/run, /dev, /boot
OWASP: CICD-SEC-7 – Insecure System Configuration
CWE: CWE-552 – Files or Directories Accessible to External Parties

Risk

Mounting sensitive host filesystem paths into a container via docker run -v breaks container isolation. A compromised job or malicious dependency can read or write host files outside the container boundary.

Particularly dangerous source paths:

Trigger example

test:
  script:
    - docker run -v /:/host -it myimage chroot /host

Both -v and --volume are detected. The source side of the bind mount is what matters — -v /etc:/anything is flagged regardless of the destination inside the container. Subpaths count too (-v /root/.ssh:/keys).

Safe alternative

Mount only the specific project directory or a named Docker volume:

test:
  script:
    - docker run -v $CI_PROJECT_DIR:/app myimage ./test.sh

Notes

Documentation for glsec 1.23.0. Source of this page · Rule implementation