Suspicious GitHub Action pre/post hook
ID |
gca_suspicious_post_hook |
Severity |
high |
Resource |
Network |
Tags |
attack-T1195.001, attack-T1552, cwe-506, evader, exfiltration |
Description
This detector flags a GitHub Custom Action whose pre/post hook entry point both reaches the network and reads secrets, credentials, or CI tokens. That combination — not the mere presence of a hook — is the signal.
pre/post hooks run around the main action and, with post-if: always(), even when the job fails, which makes them an ideal place to smuggle exfiltration logic. Only JavaScript actions (runs.pre / runs.post) and Docker container actions (runs.pre-entrypoint / runs.post-entrypoint) have such hooks; composite actions do not and are not inspected.
Rationale
A malicious or compromised Action can read the workflow’s secrets (process.env.TOKEN, GITHUB_TOKEN, cloud credentials) and quietly ship them to an attacker-controlled endpoint from a hook that most reviewers never look at. Requiring *both a network egress (fetch/axios/http(s).request/curl/wget/nc) and a secret-shaped environment read keeps false positives low: benign cleanup or telemetry hooks typically do one but rarely both, and legitimately reading INPUT* alone is not enough to trip the rule.
The pre/post timing trick is exactly how several real GitHub Actions supply-chain compromises staged their theft of CI secrets.
Related Malware campaigns
-
tj-actions/changed-files(March 2025, CVE-2025-30066) — a widely-used Action was compromised and made to dump the runner’s memory/secrets into the build log, affecting tens of thousands of repositories. -
reviewdogactions (March 2025, CVE-2025-30154) — a linked compromise in the same wave, used to seed the tj-actions incident, exfiltrating credentials from CI. -
Broader pattern: attacker-controlled
pre/posthooks and mutated Action tags used to stealGITHUB_TOKEN, npm/PyPI publish tokens, and cloud OIDC credentials from CI pipelines.