Skip to content

fix: detect ubuntu-slim runners early and bail out - #657

Merged
varunsh-coder merged 3 commits into
step-security:mainfrom
devantler:fix/ubuntu-slim-user-env
May 2, 2026
Merged

varunsh-coder merged 3 commits into
step-security:mainfrom
devantler:fix/ubuntu-slim-user-env

Conversation

@devantler

@devantler devantler commented Apr 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Detect ubuntu-slim runners (Hosted Compute Agent Docker containers) early and bail out with an informative message, instead of crashing with chown: invalid user: 'undefined'.

Problem

ubuntu-slim runners are GitHub-hosted Linux containers that lack the standard USER environment variable (runner). When harden-runner runs on these runners, chownForFolder(process.env.USER, ...) executes sudo chown -R undefined /home/agent, which crashes the step.

The existing isDocker() check does not catch ubuntu-slim because the is-docker npm package looks for /.dockerenv, which Hosted Compute Agent containers do not have.

Fix

Add an early bail-out check in both setup.ts and cleanup.ts:

  console.log(common.UBUNTU_SLIM_MESSAGE);
  return;
}

This follows the existing patterns for isDocker(), isARCRunner(), and other unsupported runner type detection.

Detection rationale

  • Standard GitHub-hosted Ubuntu VMs always set USER=runner
  • ubuntu-slim (Hosted Compute Agent Docker containers) do not set USER
  • Combined with isGithubHosted() and process.platform === "linux", this reliably identifies ubuntu-slim

Files changed

File Change
src/common.ts Add UBUNTU_SLIM_MESSAGE constant
src/setup.ts Add early bail-out after isDocker() check
src/cleanup.ts Add early bail-out after isDocker() check

Fixes #627

Loading
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.

Fix harden runner action on ubuntu-slim

2 participants