Interview Prep/GitHub Actions/Security Hardening & Supply Chain

A workflow writes untrusted data to `$GITHUB_ENV`. Why is that dangerous and how do you fix it?

AdvancedScenarioSecurity Hardening & Supply Chain
Answer

Situation read → Newlines in the data let an attacker define arbitrary env vars for later steps, such as NODE_OPTIONS=--require /tmp/x.js or LD_PRELOAD.

What I'd do →

  1. Avoid writing untrusted values to $GITHUB_ENV; pass them as step outputs and map into env: of the consuming step.
  2. If unavoidable, use a random heredoc delimiter and validate content (reject newlines).

Why → GITHUB_ENV affects every later step including third-party actions.

Interview tip → Mention NODE_OPTIONS as the concrete exploitation path.

All GitHub Actions questions Roadmap: GitHub Actions

More on Security Hardening & Supply Chain