Skip to content

Fix harden runner action on ubuntu-slim #627

Closed

Description

@varunsh-coder

Activity

  1. jacobwoffenden commented on Jan 29, 2026

    @jacobwoffenden

    Tagging along on to this to add

    sudo chown -R /home/agent chown: invalid user: ‘undefined’
    

    Source

  2. added a commit that references this issue on Mar 31, 2026
  3. devantler commented on Apr 11, 2026

    @devantler
    Contributor

    Analysis: Why harden-runner crashes on ubuntu-slim and potential paths forward

    Root cause

    ubuntu-slim runners are GitHub Hosted Compute Agent Docker containers (base image ubuntu:24.04). The isDocker() check in setup.ts does not detect them because the is-docker package checks for /.dockerenv (absent) and Docker cgroup entries (absent in Hosted Compute Agent containers).

    When isDocker() returns false, harden-runner proceeds to install the Linux agent, which crashes at:

    chownForFolder(process.env.USER, "/home/agent")
     sudo chown -R undefined /home/agent
     chown: invalid user: 'undefined'
    

    process.env.USER is undefined because bare ubuntu:24.04 containers do not set the USER environment variable.

    Environment comparison

    Property ubuntu-latest ubuntu-slim
    VM Image Full runner image (ubuntu-24.04, 60+ GB) Docker ubuntu:24.04
    RUNNER_ENVIRONMENT github-hosted github-hosted
    process.env.USER runner undefined
    /.dockerenv absent absent
    systemd
    isDocker() false false

    Immediate fix (PR #657)

    PR #657 adds early bail-out detection:

    if (isGithubHosted() && process.platform === "linux" && !process.env.USER) {
      console.log(common.UBUNTU_SLIM_MESSAGE);
      return;
    }

    This follows the existing pattern for isDocker(), isARCRunner(), and other unsupported runner checks. Added to both setup.ts and cleanup.ts.

    Could full ubuntu-slim support be implemented?

    Fixable (proper solutions, not workarounds):

    Blocker Fix Notes
    process.env.USER undefined os.userInfo().username Node.js ` independent of env vars
    No systemd cp.spawn() detached process Pattern already exists in installWindowsAgent
    No journalctl Read from /home/agent/agent.log Cleanup already reads this file

    Likely blocked (container runtime limitations):

    Blocker Issue
    eBPF agent (TLS variant) Requires CAP_BPF / CAP_SYS_ not available in Docker without --privileged`
    Non-TLS agent monitoring Requires `CAP_NET_ uncertain if available
    Network namespace Docker containers have isolated networking that may interfere with monitoring

    The existing CONTAINER_MESSAGE ("...can be monitored by installing Harden Runner in a custom VM image...") suggests containers are intentionally unsupported. Full support would require verifying agent monitoring works inside containers and adding a non-systemd process management path for Linux.

    References

  4. JakobJingleheimer commented on Apr 25, 2026

    @JakobJingleheimer

    @varunsh-coder gentle nudge. ubuntu-slim speeds up our CI rather significantly.

  5. varunsh-coder commented on May 2, 2026

    @varunsh-coder
    MemberAuthor

    Thanks @devantler for the analysis and PR #657.

    The PR has been merged and we will be releasing a new version shortly. To set expectations on what it does and doesn't do:

    What the fix changes

    • Harden-Runner will detect ubuntu-slim runners and exit cleanly with an informational log message, instead of crashing on
      chown: invalid user: 'undefined'.

    What the fix does not do

    • Jobs running on ubuntu-slim will not be monitored by Harden-Runner. The agent relies on kernel-level features (that require elevated capabilities).
    • Per GitHub's docs on single-CPU runners: "The container for ubuntu-slim runners runs in unprivileged mode. This means that some operations requiring elevated privileges such as mounting file systems, using Docker-in-Docker, or accessing low-level kernel features are not supported." Those low-level kernel features are what the agent needs, so monitoring inside the unprivileged container is not feasible today.

    For StepSecurity enterprise customers
    If your security posture requires that workflows are always monitored, you can block the use of ubuntu-slim via workflow run policies see the Runner Label Policy docs. This lets you enforce that jobs only run on monitored runner types.

  6. JakobJingleheimer commented on May 2, 2026

    @JakobJingleheimer

    Thanks @varunsh-coder. Unfortunate that it's fundamentally impossible. Is there perchance a subset that would be sufficient if added to ubuntu-slim?

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