Skip to content

Chart default podSecurityContext (runAsUser: 1000) incompatible with image — container must start as root (uid 0) #1

Description

@red-avtovo

Summary

The chart's default podSecurityContext sets runAsUser: 1000 and runAsNonRoot: true, but the nousresearch/hermes-agent image is designed to start as root (uid 0) and drop privileges internally via s6-overlay.

Root Cause

The s6-overlay init system inside the image runs /etc/cont-init.d/01-hermes-setup and /etc/cont-init.d/02-reconcile-profiles as root, then drops to the hermes user (uid 10000 by default, remappable via HERMES_UID/HERMES_GID) using s6-setuidgid. This call internally invokes setgroups(), which requires the process to be running as root — it cannot be called from a non-root context even with CAP_SETGID/CAP_SETUID in the bounding set when allowPrivilegeEscalation: false is also set (which applies no_new_privs).

When the pod starts as uid 1000 (chart default), the following fatal errors occur:

s6-applyuidgid: fatal: unable to set supplementary group list: Operation not permitted
cont-init: info: /etc/cont-init.d/01-hermes-setup exited 111
s6-applyuidgid: fatal: unable to set supplementary group list: Operation not permitted
cont-init: info: /etc/cont-init.d/02-reconcile-profiles exited 111

And with readOnlyRootFilesystem: true (also a chart default), /run is immutable and owned by root, causing s6-overlay's preinit to fail before any init scripts even run:

/package/admin/s6-overlay/libexec/preinit: fatal: /run belongs to uid 0 instead of 1000, has insecure and/or unworkable permissions, and we're lacking the privileges to fix it.
s6-overlay-suexec: fatal: child failed with exit code 100

Fix Applied (workaround)

Override the security contexts in Helm values to allow root startup:

podSecurityContext:
  runAsUser: 0
  runAsNonRoot: false
securityContext:
  allowPrivilegeEscalation: true
  readOnlyRootFilesystem: false
  runAsNonRoot: false
  capabilities:
    drop: []
env:
  HERMES_UID: "1000"
  HERMES_GID: "1000"

HERMES_UID/HERMES_GID tell the image's stage2 hook to remap the hermes user to uid/gid 1000 before dropping privileges, which integrates cleanly with Kubernetes fsGroup on the persistent volume.

Suggestion

The chart's default podSecurityContext and securityContext should either:

  1. Default to runAsUser: 0 / runAsNonRoot: false to match the image's actual requirements, or
  2. Include documentation/warnings that the defaults are incompatible with the official image and must be overridden as shown above.

The HERMES_UID/HERMES_GID env vars are a clean mechanism — it may be worth exposing them as first-class chart values.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions