Skip to content

Commit 6e429f7

Browse files
committed
feat: detect vulnerable GitHub Actions
Signed-off-by: behnazh-w <[email protected]>
1 parent f335ec0 commit 6e429f7

25 files changed

+1721
-113
lines changed

docs/source/glossary.rst

+5
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@ Glossary
2323

2424
* Witness is a tool that wraps a build command and records various types of information in a provenance document in the ``in-toto`` format as the build execution happens.
2525
* URL: https://github.com/in-toto/witness
26+
27+
PURL
28+
29+
* Package URL identifier
30+
* URL: https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst

docs/source/index.rst

+7-14
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ Current checks in Macaron
4646
The table below shows the current set of actionable checks derived from
4747
the requirements that are currently supported by Macaron.
4848

49-
.. list-table:: Mapping SLSA requirements to Macaron checks
49+
.. list-table:: Macaron checks descriptions
5050
:widths: 20 40 40
5151
:header-rows: 1
5252

5353
* - Check ID
54-
- SLSA requirement
54+
- Summary
5555
- Concrete check
5656
* - ``mcn_build_tool_1``
5757
- **Build tool exists** - The source code repository includes configurations for a supported build tool used to produce the software component.
@@ -95,19 +95,12 @@ the requirements that are currently supported by Macaron.
9595
* - ``mcn_scm_authenticity_check_1``
9696
- **Source repo authenticity** - Check whether the claims of a source code repository made by a package can be corroborated.
9797
- If the source code repository contains conflicting evidence regarding its claim of the source code repository, this check will fail. If no source code repository or corroborating evidence is found, or if the build system is unsupported, the check will return ``UNKNOWN`` as the result. This check currently supports only Maven artifacts.
98-
99-
****************************************************************************************
100-
Macaron checks that report integrity issues but do not map to SLSA requirements directly
101-
****************************************************************************************
102-
103-
.. list-table::
104-
:widths: 20 40
105-
:header-rows: 1
106-
107-
* - Check ID
108-
- Description
10998
* - ``mcn_detect_malicious_metadata_1``
110-
- This check performs analysis on PyPI package metadata to detect malicious behavior. It also reports known malware from other ecosystems, but the analysis is currently limited to PyPI packages.
99+
- **Malicious code detection** - Check whether the source code or package metadata has indicators of compromise.
100+
- This check performs analysis on PyPI package metadata to detect malicious behavior. It also reports known malware from other ecosystems.
101+
* - ``mcn_githubactions_vulnerabilities_1``
102+
- **Detect vulnerable GitHub Actions** - Check whether the GitHub Actions called from the corresponding repo have known vulnerabilities.
103+
- This check identifies third-party GitHub Actions used in a repository and reports any known vulnerabilities associated with the used versions.
111104

112105
----------------------
113106
How does Macaron work?

docs/source/pages/cli_usage/command_analyze.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. Copyright (c) 2023 - 2023, Oracle and/or its affiliates. All rights reserved.
1+
.. Copyright (c) 2023 - 2025, Oracle and/or its affiliates. All rights reserved.
22
.. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33
44
.. _analyze-command-cli:

docs/source/pages/developers_guide/apidoc/macaron.slsa_analyzer.package_registry.rst

+14-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ macaron.slsa\_analyzer.package\_registry package
33

44
.. automodule:: macaron.slsa_analyzer.package_registry
55
:members:
6-
:undoc-members:
76
:show-inheritance:
7+
:undoc-members:
88

99
Submodules
1010
----------
@@ -14,45 +14,53 @@ macaron.slsa\_analyzer.package\_registry.deps\_dev module
1414

1515
.. automodule:: macaron.slsa_analyzer.package_registry.deps_dev
1616
:members:
17-
:undoc-members:
1817
:show-inheritance:
18+
:undoc-members:
1919

2020
macaron.slsa\_analyzer.package\_registry.jfrog\_maven\_registry module
2121
----------------------------------------------------------------------
2222

2323
.. automodule:: macaron.slsa_analyzer.package_registry.jfrog_maven_registry
2424
:members:
25-
:undoc-members:
2625
:show-inheritance:
26+
:undoc-members:
2727

2828
macaron.slsa\_analyzer.package\_registry.maven\_central\_registry module
2929
------------------------------------------------------------------------
3030

3131
.. automodule:: macaron.slsa_analyzer.package_registry.maven_central_registry
3232
:members:
33-
:undoc-members:
3433
:show-inheritance:
34+
:undoc-members:
3535

3636
macaron.slsa\_analyzer.package\_registry.npm\_registry module
3737
-------------------------------------------------------------
3838

3939
.. automodule:: macaron.slsa_analyzer.package_registry.npm_registry
4040
:members:
41+
:show-inheritance:
4142
:undoc-members:
43+
44+
macaron.slsa\_analyzer.package\_registry.osv\_dev module
45+
--------------------------------------------------------
46+
47+
.. automodule:: macaron.slsa_analyzer.package_registry.osv_dev
48+
:members:
4249
:show-inheritance:
50+
:undoc-members:
4351

4452
macaron.slsa\_analyzer.package\_registry.package\_registry module
4553
-----------------------------------------------------------------
4654

4755
.. automodule:: macaron.slsa_analyzer.package_registry.package_registry
4856
:members:
49-
:undoc-members:
5057
:show-inheritance:
58+
:undoc-members:
5159

5260
macaron.slsa\_analyzer.package\_registry.pypi\_registry module
5361
--------------------------------------------------------------
5462

5563
.. automodule:: macaron.slsa_analyzer.package_registry.pypi_registry
5664
:members:
57-
:undoc-members:
5865
:show-inheritance:
66+
:undoc-members:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
.. Copyright (c) 2025 - 2025, Oracle and/or its affiliates. All rights reserved.
2+
.. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
3+
4+
.. _detect-vuln-gh-actions:
5+
6+
=======================================
7+
How to detect vulnerable GitHub Actions
8+
=======================================
9+
10+
This tutorial explains how to use a check in Macaron that detects vulnerable third-party GitHub Actions. This check is important for preventing security issues in your CI/CD pipeline, especially in light of recent incidents, such as vulnerabilities discovered in popular GitHub Actions like `tj-actions/changed-files <https://www.cve.org/CVERecord?id=CVE-2025-30066>`_, and `reviewdog/action-setup <https://www.cve.org/CVERecord?id=CVE-2025-30154>`_.
11+
12+
We will guide you on how to enable and use this check to enhance the security of your development pipeline.
13+
14+
For more information on other features of Macaron, please refer to the :ref:`Documentation here <index>`.
15+
16+
.. contents:: :local:
17+
18+
------------
19+
Introduction
20+
------------
21+
22+
In March 2025, CISA (Cybersecurity and Infrastructure Security Agency) issued an `alert <https://www.cisa.gov/news-events/alerts/2025/03/18/supply-chain-compromise-third-party-github-action-cve-2025-30066>`_ about a critical supply chain attack affecting third-party GitHub Actions. The incidents, identified as `CVE-2025-30066 <https://www.cve.org/CVERecord?id=CVE-2025-30066>`_ and `CVE-2025-30154 <https://www.cve.org/CVERecord?id=CVE-2025-30154>`_, targeted the widely used GitHub Actions ``tj-actions/changed-files`` and ``reviewdog/action-setup``, respectively. These actions were compromised, allowing attackers to manipulate CI/CD pipelines and potentially inject malicious code into repositories.
23+
24+
Macaron now includes a check for detecting vulnerable third-party GitHub Actions that are used in repositories, preventing the potential misuse of these actions.
25+
26+
-------------------------------------------
27+
The Check: Detect Vulnerable GitHub Actions
28+
-------------------------------------------
29+
30+
Macaron's check, ``mcn_githubactions_vulnerabilities_1`` identifies third-party GitHub Actions and reports any known vulnerabilities associated with the versions used in your repository.
31+
32+
33+
**Key Features of this Check:**
34+
35+
- **Vulnerability Detection**: It scans the repository’s workflow files and checks for any known vulnerabilities in the GitHub Actions used.
36+
- **Version Checks**: It verifies the versions of the GitHub Actions being used, comparing them against a list of known vulnerabilities.
37+
- **Security Prevention**: Helps prevent security breaches by ensuring that your workflows are free from compromised actions.
38+
- **Continuous Monitoring**: As GitHub Actions are updated, you can enforce a policy to continuously track and address emerging threats, ensuring that your security posture remains up-to-date.
39+
40+
-----------------------------------------------------------
41+
How to Use the GitHub Actions Vulnerability Detection Check
42+
-----------------------------------------------------------
43+
44+
******************************
45+
Installation and Prerequisites
46+
******************************
47+
48+
Skip this section if you already know how to install Macaron.
49+
50+
.. toggle::
51+
52+
Please follow the instructions :ref:`here <installation-guide>`. In summary, you need:
53+
54+
* Docker
55+
* the ``run_macaron.sh`` script to run the Macaron image.
56+
* sqlite3
57+
58+
.. note:: At the moment, Docker alternatives (e.g. podman) are not supported.
59+
60+
61+
You also need to provide Macaron with a GitHub token through the ``GITHUB_TOKEN`` environment variable.
62+
63+
To obtain a GitHub Token:
64+
65+
* Go to ``GitHub settings`` → ``Developer Settings`` (at the bottom of the left side pane) → ``Personal Access Tokens`` → ``Fine-grained personal access tokens`` → ``Generate new token``. Give your token a name and an expiry period.
66+
* Under ``"Repository access"``, choosing ``"Public Repositories (read-only)"`` should be good enough in most cases.
67+
68+
Now you should be good to run Macaron. For more details, see the documentation :ref:`here <prepare-github-token>`.
69+
70+
***************
71+
Running Macaron
72+
***************
73+
74+
To use the GitHub Actions Vulnerability Detection check in Macaron, you can either provide the repository URL or use the :term:`PURL` of the package. Macaron will automatically resolve the repository if you choose the PURL approach. For more details, refer to the :ref:`CLI options<analyze-command-cli>` of the ``analyze`` command.
75+
76+
+++++++++++++++++++++++++
77+
Using the Repository Path
78+
+++++++++++++++++++++++++
79+
80+
As an example, we will check if the https://github.com/apache/logging-log4j2 repository calls any vulnerable GitHub Actions. First, execute the ``analyze`` command as follows:
81+
82+
.. code-block:: shell
83+
84+
./run_macaron.sh analyze -rp https://github.com/apache/logging-log4j2
85+
86+
Next, ensure that the ``mcn_githubactions_vulnerabilities_1`` check passes for the repository. You can create a simple policy like the one below and store it in a file (e.g., ``check_github_actions_vuln.dl``):
87+
88+
.. code-block:: prolog
89+
90+
Policy("github_actions_vulns", component_id, "GitHub Actions Vulnerability Detection") :-
91+
check_passed(component_id, "mcn_githubactions_vulnerabilities_1").
92+
93+
apply_policy_to("github_actions_vulns", component_id) :-
94+
is_repo_url(component_id, "https://github.com/apache/logging-log4j2").
95+
96+
Run the ``verify-policy`` command to check if the ``mcn_githubactions_vulnerabilities_1`` check is successful.
97+
98+
.. code-block:: shell
99+
100+
./run_macaron.sh verify-policy --database ./output/macaron.db --file ./check_github_actions_vuln.dl
101+
102+
++++++++++++++
103+
Using the PURL
104+
++++++++++++++
105+
106+
Alternatively, run the ``analyze`` command with the PURL of a package:
107+
108+
.. code-block:: shell
109+
110+
./run_macaron.sh analyze -purl pkg:maven/org.apache.logging.log4j/[email protected]
111+
112+
Then, ensure that the ``mcn_githubactions_vulnerabilities_1`` check passes for the component. You can create a similar policy to the one shown earlier and store it in a file (e.g., ``check_github_actions_vuln.dl``):
113+
114+
.. code-block:: prolog
115+
116+
Policy("github_actions_vulns", component_id, "GitHub Actions Vulnerability Detection") :-
117+
check_passed(component_id, "mcn_githubactions_vulnerabilities_1").
118+
119+
apply_policy_to("github_actions_vulns", component_id) :-
120+
is_component(component_id, purl),
121+
match("pkg:maven/org.apache.logging.log4j/log4j-core@.*", purl).
122+
123+
Run the ``verify-policy`` command to verify that the check passes:
124+
125+
.. code-block:: shell
126+
127+
./run_macaron.sh verify-policy --database ./output/macaron.db --file ./check_github_actions_vuln.dl
128+
129+
******************
130+
Review the Results
131+
******************
132+
133+
Macaron stores the results in a local database and generates HTML and JSON reports. If the ``verify-policy`` step fails, you can retrieve detailed information about the vulnerable repositories from the database. For a quick overview, refer to the HTML report located in the ``output/reports`` directory, such as:
134+
135+
- ``output/reports/github_com/apache/logging-log4j2/logging-log4j2.html`` (for repository path analysis)
136+
- ``output/reports/maven/org_apache_logging_log4j/log4j-core/log4j-core.html`` (for PURL analysis)
137+
138+
For comprehensive results, query the local database with the following command:
139+
140+
.. code-block:: shell
141+
142+
sqlite3 -json output/macaron.db "SELECT * FROM github_actions_vulnerabilities_check;" | jq
143+
144+
.. code-block:: json
145+
146+
[
147+
{
148+
"id": 1,
149+
"vulnerability_urls": "[\"https://osv.dev/vulnerability/GHSA-mrrh-fwg8-r2c3\"]",
150+
"github_actions_id": "tj-actions/changed-files",
151+
"github_actions_version": "v41",
152+
"caller_workflow": "https://github.com/OWNER/REPO/blob/4d59c62f42b7f5c08e31f6eb401a4e35355fe077/.github/workflows/workflow.yml"
153+
}
154+
]
155+
156+
**Output Breakdown:**
157+
158+
- **id**: Unique identifier for this specific report in the database.
159+
- **vulnerability_urls**: List of URLs pointing to published vulnerability advisories for the identified GitHub Action.
160+
- **github_actions_id**: The identifier of the vulnerable GitHub Action, formatted as ``OWNER/REPO``.
161+
- **github_actions_version**: The version of the GitHub Action that contains the vulnerability.
162+
- **caller_workflow**: URL to the GitHub workflow file that is calling the affected action.
163+
164+
The output is machine-readable, making it suitable for further analysis, automation, or integration with other security tools.
165+
166+
.. note::
167+
168+
The ``OWNER`` and ``REPO`` in the ``caller_workflow`` field are anonymized to protect the privacy of the repository being analyzed.
169+
170+
**********
171+
Mitigation
172+
**********
173+
174+
To mitigate the vulnerability, review the advisory linked in the ``vulnerability_urls`` field and identify the patched version of the GitHub Action. Follow security best practices by pinning the vulnerable action to a fixed version, using the commit SHA for the patched version. This ensures that security updates are incorporated while maintaining the stability of your workflow.
175+
176+
For example, to pin the ``tj-actions/changed-files`` action to a specific version:
177+
178+
.. code-block:: yaml
179+
180+
uses: tj-actions/changed-files@823fcebdb31bb35fdf2229d9f769b400309430d0 # v46.0.3
181+
182+
Refer to GitHub's security hardening guide for more information on managing third-party actions securely: `GitHub Security <https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#using-third-party-actions>`_.
183+
184+
---------------------
185+
Why This is Important
186+
---------------------
187+
188+
In the aftermath of the supply chain compromise in March 2025, securing your CI/CD pipeline is more important than ever. GitHub Actions are widely used to automate development processes, but relying on third-party actions that could be compromised poses a significant risk.
189+
190+
By using the ``mcn_githubactions_vulnerabilities_1`` check in Macaron, you can proactively secure your repositories. It helps identify and mitigate risks early in the development process, ensuring that your workflows are running trusted and secure actions.
191+
192+
As third-party libraries and tools continue to grow in popularity, security risks from supply chain attacks will only increase. Regularly checking for vulnerabilities in the GitHub Actions used in your projects is an essential step toward maintaining a secure development environment.
193+
194+
----------
195+
Conclusion
196+
----------
197+
198+
In this tutorial, we've shown you how to use Macaron to detect vulnerable third-party GitHub Actions in your repository. By integrating this check into your pipeline, you can prevent security breaches caused by compromised or vulnerable actions. This is especially important following the recent `CVE-2025-30066 <https://www.cve.org/CVERecord?id=CVE-2025-30066>`_ report, which highlights the need for robust security measures in CI/CD pipelines.
199+
200+
Make sure to stay up to date with Macaron’s security checks to protect your project from emerging threats.
201+
202+
For more information about using Macaron and other checks, please refer to the full list of our checks: :ref:`here <index>`.

docs/source/pages/tutorials/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ For the full list of supported technologies, such as CI services, registries, an
1919

2020
commit_finder
2121
detect_malicious_package
22+
detect_vulnerable_github_actions
2223
npm_provenance
2324
detect_malicious_java_dep
2425
generate_verification_summary_attestation

src/macaron/config/defaults.ini

+6
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,12 @@ url_netloc = api.deps.dev
544544
url_scheme = https
545545
purl_endpoint = v3alpha/purl
546546

547+
[osv_dev]
548+
url_netloc = api.osv.dev
549+
url_scheme = https
550+
query_endpoint = v1/query
551+
querybatch_endpoint = v1/querybatch
552+
547553
# Configuration options for selecting the checks to run.
548554
# Both the exclude and include are defined as list of strings:
549555
# - The exclude list is used to specify the checks that will not run.

0 commit comments

Comments
 (0)