Safeguard
Developer Tools•

Which devcontainer.json settings should a code reviewer flag?

Privileged mode, added capabilities, unconfined seccomp, extra mounts, run arguments and host side commands widen a dev container. Review these settings.

Safeguard Security Team
4 min read

Flag any devcontainer.json entry that widens what the container can do: privileged, capAdd, securityOpt, mounts, runArgs, initializeCommand, and Features that add the same. Each is a legitimate setting with a clear purpose, and each deserves a written reason in the pull request.

Why dev container files need review

A devcontainer.json file lives in the repository and tells tooling how to build and run your development environment. A change to it can change the privileges of every developer who opens the project. Yet many teams review application code closely and wave through a few lines of container settings.

The review table

SettingWhat the reference saysWhy to flag it
privilegedRuns the container in privileged mode, required for things like Docker in Docker, with security implications particularly when running directly on LinuxBroad access to the host
capAddAdds capabilities typically disabled, often SYS_PTRACE for debuggersEach capability widens what a process can do
securityOptSets security options, with seccomp unconfined as the exampleCan turn off syscall filtering
mountsAdds mounts using the same values as the Docker mount flagCan expose host folders
runArgsPasses arbitrary Docker command line argumentsCan carry any of the above
initializeCommandRuns on the host machineExecutes outside the container
featuresAdds Feature installs to the containerFeature metadata can add privileges and run install scripts as root
containerUser and remoteUserDefault is often rootEverything runs with root powers inside the container

All descriptions come from the containers.dev reference. The "why to flag" column is this post's guidance.

The classic debugger request

The reference itself shows a common case: to let ptrace based debuggers for C++, Go and Rust work, add the SYS_PTRACE capability. It also gives an example of unconfined seccomp for the same purpose. These are reasonable asks for a native debugging project and unnecessary for a web front end. A reviewer can ask a simple question: does this project debug native code in the container? If not, remove the lines.

What a good pull request note looks like

For each flagged setting, ask the author to state:

  1. What breaks without it.
  2. Whether a narrower option exists, such as one capability instead of privileged.
  3. Who owns the exception and when it will be revisited.

Automating part of the check

Search every devcontainer.json for the names in the table in CI, and fail the build when a new hit has no linked reason. A short allowlist file with an owner and a date per exception keeps the list honest. See the lifecycle commands guide for the host side command and how Features change container settings for the install side.

What review cannot catch

A clean file does not make the image safe. Base images and tools added during setup bring their own packages and vulnerabilities. A container is also not described by the specification as a boundary against hostile code, so open unfamiliar repositories with the caution described in the extension trust post.

Safeguard's dependency and image scanning covers what the dev container installs, with a free scan at gold.safeguard.sh/scan.

Quick check

Is privileged mode ever justified in a dev container?

The reference says it is required for things like Docker in Docker. If the project needs that, record why and prefer a rootless alternative where it works.

Who should approve changes to this file?

Someone responsible for developer environment security, in addition to the code owner, since the file changes privileges for everyone who opens the project.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.