Skip to content

fix(security): prevent environment injection - #25

Draft
bateau84 wants to merge 17 commits into
mainfrom
security/sweep-2026-11
Draft

bateau84 wants to merge 17 commits into
mainfrom
security/sweep-2026-11

Conversation

@bateau84

Copy link
Copy Markdown
Contributor

Why

Environment values from secret stores must not become executable shell code or inject runner commands. This change writes runner environment files directly and rejects dangerous variable names rather than evaluating untrusted values.

What changed

  • Removes shell evaluation, protects multiline values and masks secrets, and rejects reserved or dangerous environment keys.
  • Builds the action image from the action's Dockerfile at its ref, using a digest-pinned base, rather than publishing a separate image.
  • Locks the npm toolchain, restricts workflow permissions, tracks action references, and skips write-capable autodoc for draft PRs.

Review notes

  • Review the deny list, shell-output compatibility, and Azure and Vault handling.
  • Step actions use version tags tracked by actions.lock; reusable workflows use commit pins. The semantic-release reusable workflow remains pinned to v5.1.5 until a hardened version is released.

Verification

  • python3 -I -m unittest discover -s tests -v — 20 tests passed locally.
  • Hosted PR checks and real hosted action and release verification are required before ready/release. No live Vault test has been performed here.

… eval'd shell

Secret values were printed into shell code that entrypoint.sh eval'd, so
$(...), backticks, quotes and newlines in a Vault value ran commands or
injected variables such as BASH_ENV into later steps.

Python now appends NAME<<random-delimiter heredocs to the runner files,
masks every line of each value, validates variable names and refuses
reserved ones (BASH_*, LD_*, NODE_OPTIONS, PATH, GITHUB_*, ...). The
entrypoint no longer evals anything. Shell output outside GitHub Actions
is quoted with shlex. Also validate the --myip-url response as an IP,
write the cache with O_NOFOLLOW/0600, and stop the vault_secret '*'
branch from falling through.
…tic-release

Use npm ci --ignore-scripts with a committed lockfile. The image job holds
packages: write but runs no npm code; the release job holds no package
permissions. Update checkout, setup-node and docker actions to current
SHA-pinned releases and stop persisting checkout credentials.
Pin github-workflow-semantic-release to v5.1.5 (6a8585e) and autodoc to
v1.1.4, use ubuntu-24.04, fix the autodoc runs-on JSON value and run the
injection tests on pull requests.
…re and logging

Names now follow the runner's rules (non-empty, no '=', CR, LF, NUL or
'<<'); hyphens, dots and lowercase names work again. The deny list is
case-sensitive and now covers GIT_*, JAVA_*, PERL/RUBY/PYTHON, LESSOPEN,
GCONV_PATH, proxies (any case), TLS bundles, TF_CLI_*, KUBECONFIG, pip
index and NPM_CONFIG_*. It is not an allow-list.

Also: fail when the Azure resource group is never found instead of
continuing unvalidated, search all storage accounts, require the three
Azure inputs up front, stop logging HTTP error bodies, and write the
kubeconfig with mode 0600.
action.yaml pointed at the published v3.2.1 image, which still held the
old eval code, so the fix would not have reached consumers. Use
image: Dockerfile so the code that runs always matches the pinned ref.
Remove the image publishing job (nothing else consumes the GHCR image),
keep credentials in the release job because semantic-release-tags runs a
plain git push, and update the README.
…le outside shell output

The entrypoint only exec'd python, so run setenv.py directly and remove
the unpinned apk step: the build now fetches only the digest-pinned base.
Apply the shell-identifier rule only when shell code is printed outside
GitHub Actions, so names like my-key work in GitHub Actions with eval
false.
Add the missing # v5.1.5 comment so the full-SHA pin stays readable.
Document the lockfile upkeep, including restoring the full-SHA pins that gh actions-lock rewrites to tags.
Action bumps change what consumers execute, so Renovate now titles them fix(deps): and they release a patch.
Run gh actions-lock --verify-local (extension pinned to v0.4.1, contents: read) on PRs touching .github/workflows/, and lock the new workflow. The checkout in the new workflow is pinned to a full commit SHA.
gh actions-lock rewrote step-level uses: to full version tags. actions.lock records and enforces the resolved commit SHAs, which GitHub treats as equivalent to hash pinning. Reusable workflow calls (jobs.<id>.uses) are not covered by the lockfile and stay pinned to a full commit SHA with a vX.Y.Z comment.
Remove the restore-the-SHA-pins steps. Explain that step actions keep version tags that the lockfile enforces, and that reusable workflow calls stay SHA-pinned.
Disable digest pinning for step-level actions so Renovate bumps full semver tags and regenerates actions.lock. Keep digest pinning for reusable workflow calls (depType workflow). Action bumps stay fix(deps).
…DATA_DIR and VAULT_ADDR

Keeps the deny list identical to github-workflow-plattform-terraform.
Callers whose Vault secrets export these keys now fail with
'Refusing to export variable with reserved name'.
Run autodoc when a draft becomes ready for review while retaining normal PR and manual triggers.
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.

1 participant