Get highlights of our research into the security of GitHub Actions, and our advice on mitigating the risk.
We recently published a report, called The State of GitHub Actions Security, which analyzes the security posture of GitHub Actions workflows and custom GitHub Actions. This report is based on an analysis of 2,500,000 GitHub Actions workflow files belonging to 553,000 organizations and personal users.
We found some troubling security issues in GitHub Actions, including lack of dependency pinning or limits on token permissions.
In this blog post, we share highlights of our findings, plus our recommendations on mitigating the risks of GitHub Actions use.
The Legit research team found a significant number of the following vulnerabilities in GitHub Actions workflows:
Avoid these vulnerabilities by:
Our research found the GitHub Actions marketplace security posture especially concerning. Most of the Actions there are not verified, maintained by one developer, and have low security scores based on OpenSSF Scorecard.
Custom Actions, although useful, pose a significant risk for workflow authors. To limit the risk, adhere to strict standards when using them. Make sure that you import Actions from verified owners, and those that are active, maintained, and have high security scores.
Some triggers inherently present more risk than others, for instance, pull_request_target and workflow_run. We found thousands of occurrences of both these triggers.
When possible, avoid using dangerous triggers, such as workflow_run and pull_request_target. If you can’t avoid them, use the following mitigation strategies:
Our research found that 98.4% of the references used by jobs and steps are not following the best practice of dependency pinning, which specifies which package or library an Action can rely on.
Dependency pinning in GitHub Actions (and in general) is crucial for ensuring workflows are stable and reproduceable. By pinning dependencies, you specify the exact versions
of the external packages or libraries your Actions rely on. This practice guards against unexpected changes or updates that could potentially introduce breaking changes, compatibility issues, or security vulnerabilities.
There are two ways to use runners:
Self-hosted runners pose significant security risks (see blog on self-hosted runner security), especially if untrusted workflows run on them.
We recommend only using self-hosted runners with private repositories. Forks of your public repository could potentially run dangerous code on your self-hosted runner machine by creating a pull request that executes the code in a workflow.
GitHub-hosted runners, on the other hand, are clean, isolated virtual machines that are destroyed at the end of the job execution and do not pose the same risks.
Each workflow run is assigned a GitHub personal access token scoped to the current repository that enables it to communicate with a GitHub API. By default, this token is highly privileged.
Our research reveals that only 14% of workflows limit token permissions.
Without these limits, the token could be used to perform malicious actions or take over the repository.
Therefore, it is important that workflow authors use the “permission” key to specify the scope their workflow requires.
The risk companies face from insecure GitHub Actions use is significant. GitHub Actions provide the key to a company’s most critical infrastructure. They are connected both to an organization’s source code and to their deployment environment, meaning that once exploited by attackers, the organization is completely in the attacker’s hands.
Organizations should prioritize educating their development and operations teams about the security risks associated with GitHub Actions.
This education includes:
• The proper handling of secrets
• The risks of code injection
• The best practices for using third-party Actions
Training sessions should cover the identification and remediation of common vulnerabilities, with a strong emphasis on security-first coding practices and the regular auditing of workflows to detect any unauthorized changes. Moreover, continuous education programs should be implemented to keep all team members updated on the latest security threats and mitigation techniques.
Implementing organization-wide best practice configuration enforcement is crucial for maintaining the security of GitHub Actions workflows. Organizations should use GitHub’s built-in features for controlling GitHub Actions behavior to enforce best practices and organization policies.
These policies include:
Organizations should leverage security tools that integrate seamlessly with GitHub to provide continuous scanning for GitHub Actions vulnerabilities, misconfigurations, vulnerable dependencies, secrets detection, and more.
Configure these tools to automatically scan the code for each code or configuration change, ensuring immediate feedback on potential security issues.
Get our full research, analysis, and recommendations on GitHub Actions security in the State of GitHub Actions Security report.
*** This is a Security Bloggers Network syndicated blog from Legit Security Blog authored by Noam Dotan. Read the original post at: https://www.legitsecurity.com/blog/how-to-mitigate-the-risk-of-github-actions