Original Post: Protect Your GitHub Actions with Semgrep
The article discusses concerns surrounding GitHub Actions (GHA) security. The major points are:
-
Security Risks: The author worries about potential code injection attacks and unauthorized access via GHA, particularly due to ambiguities in permissions and access controls.
-
Stolen Secrets: Compromised runners can steal secrets, which are available through environment variables, leading to unauthorized access like AWS credentials or Semgrep tokens.
-
Unwanted Modifications: Attackers with write permissions can inject malicious code or steal GitHub tokens, potentially modifying the repository or committing harmful changes.
-
Shell Injection: Inserting untrusted data directly into
run
scripts can lead to shell injection vulnerabilities. This can be mitigated by using environment variables for untrusted data. -
pull_request_target: While
pull_request_target
provides the target repository’s environment, using it to check out incoming code can lead to serious vulnerabilities if that code is run. This was demonstrated in the discussed vulnerabilities and is risky if improperly handled. -
ACTIONS_ALLOW_UNSECURE_COMMANDS: This environment variable re-enables deprecated, insecure commands and should be avoided. Use Environment Files instead.
-
Mitigations And Recommendations: Utilize Semgrep rules to scan for vulnerabilities, apply branch protections, audit third-party actions, and be cautious with handling any GitHub context data as untrusted input.
- Appendices: Detailed examples of payload exploitation and GitHub token permissions were provided, emphasizing the importance of understanding permissions and potential access.
The post stresses on vigilance and regular audits to fortify GHA security.
Go here to read the Original Post