Skip to content

Run CoreDNS as the image's non-root user by default - #277

Merged
hagaibarel merged 1 commit into
coredns:masterfrom
martin-mat:restricted-pss-defaults
Sep 29, 2026
Merged

hagaibarel merged 1 commit into
coredns:masterfrom
martin-mat:restricted-pss-defaults

Conversation

@martin-mat

Copy link
Copy Markdown

Why is this pull request needed and what does it do?

The chart's defaults do not satisfy the restricted Pod Security Standard, so helm install into a namespace enforcing it is rejected at admission: the container declares neither runAsNonRoot nor a seccomp profile. Everything else the profile asks for is already there.

violates PodSecurity "restricted:latest": runAsNonRoot != true (pod or container "coredns" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "coredns" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")

The CoreDNS image has run as the distroless nonroot user (uid and gid 65532) since 1.11.0, with cap_net_bind_service on the binary so it binds port 53. This change declares that user on the container (runAsNonRoot, runAsUser and runAsGroup 65532) and sets seccompProfile.type: RuntimeDefault. The ids are numeric on purpose: images before 1.14.7 declare the user by name, which the kubelet cannot verify when runAsNonRoot is set (coredns/coredns#7542, fixed in the image by coredns/coredns#8316 and released in 1.14.7). With the numeric ids the defaults work on every image since 1.11.0.

Verified on kind 1.32 in a namespace enforcing restricted: the previous defaults are rejected with the message above; with this change the Deployment rolls out, the container runs as uid 65532 and answers DNS on port 53 through the Service.

A unit test asserts the rendered defaults. Minor version bump, since a user who overrides the image with one running as a different user now has to set runAsUser to match.

Which issues (if any) are related?

#39 proposed runAsNonRoot in 2021, when the image still ran as root; this picks that up now that the image supports it. coredns/coredns#7542 and coredns/coredns#8316 for the image side.

Checklist:

  • I have bumped the chart version according to versioning.
  • I have updated the chart changelog with all the changes that come with this pull request according to changelog.
  • Any new values are backwards compatible and/or have sensible default.
  • I have signed off all my commits as required by DCO.

🤖 Generated with Claude Code

The chart's defaults did not satisfy the restricted Pod Security
Standard: the container declared no runAsNonRoot and no seccomp
profile, so `helm install` into a namespace that enforces the profile
was rejected at admission:

  violates PodSecurity "restricted:latest": runAsNonRoot != true
  (pod or container "coredns" must set securityContext.runAsNonRoot=true),
  seccompProfile (pod or container "coredns" must set
  securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")

The CoreDNS image has run as the distroless nonroot user, uid and gid
65532, since 1.11.0, with cap_net_bind_service on the binary so it
binds port 53. The container securityContext now declares that user
(runAsNonRoot, runAsUser and runAsGroup 65532) and the RuntimeDefault
seccomp profile. The ids are numeric on purpose: images before 1.14.7
declare the user by name, which the kubelet cannot verify when
runAsNonRoot is set (coredns/coredns#7542; the image pins the numeric
ids since coredns/coredns#8316, released in 1.14.7).

Verified on kind 1.32 in a namespace enforcing restricted: the previous
defaults are rejected with the message above; with this change the
Deployment rolls out, the container runs as uid 65532 and answers DNS
on port 53 through the Service.

Minor chart version bump: a user who overrides the image with one that
runs as a different user now has to set runAsUser accordingly.

Signed-off-by: Martin Matyas <martin.matyas@tieto.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@martin-mat martin-mat mentioned this pull request Sep 26, 2026
@hagaibarel
hagaibarel merged commit bc6c42f into coredns:master Sep 29, 2026
2 checks passed
@hagaibarel

Copy link
Copy Markdown
Collaborator

Thanks for the PR!

@artizirk artizirk mentioned this pull request Sep 29, 2026
4 tasks done
hagaibarel pushed a commit that referenced this pull request Sep 29, 2026
CoreDNS 1.14.7 is built with Go 1.26.6 (fixes CVE-2026-56865,
CVE-2026-56864, CVE-2026-33818) and patches CVE-2026-86003 and
CVE-2026-82399. It also pins a numeric uid/gid for the image's nonroot
user (coredns/coredns#8316), which the chart's new runAsNonRoot defaults
from #277 reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Arti Zirk <arti.zirk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants