You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CI Secret Exposure via Misuse of `pull_request_target` in GitHub Actions Workflows
Low
iluwatar
published
GHSA-85mx-2hxh-5r8pMay 31, 2026
Package
No package listed
Affected versions
2d39fe7ed8acfb683890644355ab5156c9b37354
Patched versions
None
Description
Summary
The GitHub Actions workflow maven-pr-builder.yml in this repository uses the pull_request_target event while checking out and executing untrusted code from forked pull requests. This workflow runs with the security context of the base repository, including:
SONAR_TOKEN
By crafting a malicious pull request, an attacker can exfiltrate the SONAR_TOKEN.
Details
1. Insecure use of pull_request_target
In multiple workflows:
on:
pull_request_target:
pull_request_target runs in the context of the target repository, which means that the GITHUB_TOKEN is available.
This event is only safe if you do not run untrusted code from the PR. Here, the workflows do exactly that.
2. Checkout of attacker-controlled code
Every vulnerable workflow checks out the PR head commit:
An attacker can exfiltrate the SONAR_TOKEN. Usually, SONAR_TOKEN is a user token, so the attacker could:
Get access to private repositories, if they can be accessed via the SonarCloud.
Change the SonarCloud project settings, e.g. the project name, description, etc.
Submit fake/poisoned analyses for the project (e.g., upload crafted metrics/issues), which can mislead PR decoration / quality gate status and spam analysis history.
An attacker can use the token to run massive scans on unrelated code, consuming the organization's license quota and potentially blocking legitimate CI/CD pipelines.
Luckily, the GITHUB_TOKEN has only read permissions because of the permissions field.
Recommended Remediation
1. Stop using pull_request_target for untrusted code
For workflows that build, test, lint, or run code from PRs, switch:
on:
pull_request_target:
to:
on:
pull_request:
This ensures the workflow runs in the fork’s security context (no base repo secrets).
2. If retention of pull_request_target is necessary, secrets & checkout is required
Ensure it never checks out or executes untrusted PR code.
Use a safe-to-test label workflow, such as: verify-safe-to-test-label GitHub Action.
This ensures untrusted code is not executed with secrets.
The product imports, requires, or includes executable functionality (such as a library) from a source that is outside of the intended control sphere.
Learn more on MITRE.
Summary
The GitHub Actions workflow
maven-pr-builder.ymlin this repository uses thepull_request_targetevent while checking out and executing untrusted code from forked pull requests. This workflow runs with the security context of the base repository, including:SONAR_TOKENBy crafting a malicious pull request, an attacker can exfiltrate the
SONAR_TOKEN.Details
1. Insecure use of
pull_request_targetIn multiple workflows:
pull_request_targetruns in the context of the target repository, which means that theGITHUB_TOKENis available.This event is only safe if you do not run untrusted code from the PR. Here, the workflows do exactly that.
2. Checkout of attacker-controlled code
Every vulnerable workflow checks out the PR head commit:
3. Workflow executes untrusted code
The maven-pr-builder.yml workflow executes untrusted code:
An attacker can inject a malicious code by changing the
mvnwfile.See https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
PoC
mvnwfile with the following code:java-design-patterns.mp4
Impact
An attacker can exfiltrate the
SONAR_TOKEN. Usually,SONAR_TOKENis a user token, so the attacker could:Luckily, the
GITHUB_TOKENhas only read permissions because of thepermissionsfield.Recommended Remediation
1. Stop using
pull_request_targetfor untrusted codeFor workflows that build, test, lint, or run code from PRs, switch:
to:
This ensures the workflow runs in the fork’s security context (no base repo secrets).
2. If retention of
pull_request_targetis necessary, secrets & checkout is requiredEnsure it never checks out or executes untrusted PR code.
Use a safe-to-test label workflow, such as: verify-safe-to-test-label GitHub Action.
This ensures untrusted code is not executed with secrets.