-
Notifications
You must be signed in to change notification settings - Fork 613
[New Rule] GitHub Actions Workflow Injection Blocked #5433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
terrancedejesus
wants to merge
9
commits into
main
Choose a base branch
from
terrancedejesus/issue5431
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+131
−0
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
176b904
[New Rule] GitHub Actions Workflow Injection Blocked
terrancedejesus db23c2e
adjusts MITRE ATT&CK mappings
terrancedejesus 654a307
adjusting file name
terrancedejesus 27e583c
updating GitHub integration schema; fixed MITRE mappings
terrancedejesus abee608
revert manifests / schemas to main
terrancedejesus b7ceb96
added dynamic github fields to non-ecs file
terrancedejesus bf4ac73
Merge branch 'main' into terrancedejesus/issue5431
terrancedejesus 77917c7
Merge branch 'main' into terrancedejesus/issue5431
terrancedejesus c858499
Merge branch 'main' into terrancedejesus/issue5431
terrancedejesus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
rules/integrations/github/initial_access_github_actions_workflow_injection_blocked.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| [metadata] | ||
| creation_date = "2025/12/05" | ||
| integration = ["github"] | ||
| maturity = "production" | ||
| updated_date = "2025/12/05" | ||
|
|
||
| [rule] | ||
| author = ["Elastic"] | ||
| description = """ | ||
| Detects when a GitHub Actions workflow attempts to create or modify workflow files in a protected branch but is blocked | ||
| due to insufficient permissions. This behavior is indicative of a supply chain attack where a malicious package or | ||
| compromised CI/CD pipeline attempts to inject persistent backdoor workflows into a repository. The Shai Hulud 2.0 attack | ||
| demonstrated this technique by using npm preinstall hooks to push malicious workflow files that enable command injection | ||
| or secrets exfiltration. | ||
| """ | ||
| false_positives = [ | ||
| """ | ||
| Legitimate CI/CD automation that requires workflow file modifications may trigger this alert if not properly | ||
| configured with the necessary permissions. Review the workflow configuration and ensure the GITHUB_TOKEN or PAT has | ||
| the required 'workflows' permission if the modification is intentional. | ||
| """, | ||
| ] | ||
| from = "now-9m" | ||
| interval = "8m" | ||
| language = "esql" | ||
| license = "Elastic License v2" | ||
| name = "GitHub Actions Workflow Injection Blocked" | ||
| note = """## Triage and analysis | ||
|
|
||
| ### Investigating GitHub Actions Workflow Injection Blocked | ||
|
|
||
| This rule detects attempts to push workflow files to a GitHub repository from within a GitHub Actions workflow that are blocked by GitHub's security controls. This is a key indicator of supply chain attacks where malicious code attempts to establish persistence by injecting backdoor workflows. | ||
|
|
||
| ### Possible investigation steps | ||
|
|
||
| - Review the `github.repo` field to identify which repository was targeted. | ||
| - Examine the `github.actor` to determine if the action was triggered by a bot (`github-actions[bot]`) or a user account (PAT-based). | ||
| - Check recent workflow runs in the repository for suspicious activity, especially in jobs that run `npm install` or other package manager commands. | ||
| - Review the repository's dependencies for recently added or updated packages that may contain malicious preinstall/postinstall hooks. | ||
| - Examine the `github.reasons.message` field for details on which workflow file was being created or modified. | ||
| - Search for other repositories in the organization that may have the same malicious dependency. | ||
| - Review GitHub audit logs for successful workflow file modifications that may have occurred before protections were enabled. | ||
|
|
||
| ### False positive analysis | ||
|
|
||
| - Legitimate automation tools that manage workflow files may trigger this alert. Verify if the repository uses tools like Dependabot, Renovate, or custom automation that modifies workflows. | ||
| - CI/CD pipelines that intentionally update workflow files should use a PAT with the 'workflows' scope and be documented. | ||
|
|
||
| ### Response and remediation | ||
|
|
||
| - If this is a confirmed attack attempt, immediately audit all dependencies in the affected repository. | ||
| - Remove any suspicious packages and regenerate lock files. | ||
| - Rotate any secrets that may have been exposed during the CI run. | ||
| - Review and revoke any PATs that may have been compromised. | ||
| - Enable branch protection rules requiring pull request reviews for workflow file changes. | ||
| - Consider implementing CODEOWNERS for `.github/workflows/` directory. | ||
| - Search for indicators of compromise such as unexpected workflow files (e.g., `discussion_*.yaml`, `formatter_*.yml`). | ||
| """ | ||
| references = ["https://www.wiz.io/blog/shai-hulud-2-0-ongoing-supply-chain-attack"] | ||
| risk_score = 47 | ||
| rule_id = "e8b37f18-4804-4819-8602-4aba1169c9f4" | ||
| severity = "medium" | ||
| tags = [ | ||
| "Domain: Cloud", | ||
| "Use Case: Threat Detection", | ||
| "Tactic: Initial Access", | ||
| "Tactic: Persistence", | ||
| "Tactic: Execution", | ||
| "Data Source: Github", | ||
| "Resources: Investigation Guide", | ||
| ] | ||
| timestamp_override = "event.ingested" | ||
| type = "esql" | ||
|
|
||
| query = ''' | ||
| from logs-github.audit-* metadata _id, _index, _version | ||
| | where | ||
| data_stream.dataset == "github.audit" and | ||
| event.action == "protected_branch.rejected_ref_update" and | ||
| github.category == "protected_branch" and | ||
| github.reasons.code == "workflow_updates" and | ||
| match(github.reasons.message::STRING, "refusing to allow a GitHub App to create or update workflow") | ||
| | keep * | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a note too, we probably need to update #5441 to handle this as well. |
||
| ''' | ||
|
|
||
|
|
||
| [[rule.threat]] | ||
| framework = "MITRE ATT&CK" | ||
| [[rule.threat.technique]] | ||
| id = "T1195" | ||
| name = "Supply Chain Compromise" | ||
| reference = "https://attack.mitre.org/techniques/T1195/" | ||
| [[rule.threat.technique.subtechnique]] | ||
| id = "T1195.002" | ||
| name = "Compromise Software Supply Chain" | ||
| reference = "https://attack.mitre.org/techniques/T1195/002/" | ||
|
|
||
|
|
||
|
|
||
| [rule.threat.tactic] | ||
| id = "TA0001" | ||
| name = "Initial Access" | ||
| reference = "https://attack.mitre.org/tactics/TA0001/" | ||
| [[rule.threat]] | ||
| framework = "MITRE ATT&CK" | ||
| [[rule.threat.technique]] | ||
| id = "T1059" | ||
| name = "Command and Scripting Interpreter" | ||
| reference = "https://attack.mitre.org/techniques/T1059/" | ||
|
|
||
| [rule.threat.tactic] | ||
| id = "TA0002" | ||
| name = "Execution" | ||
| reference = "https://attack.mitre.org/tactics/TA0002/" | ||
|
|
||
| [[rule.threat]] | ||
| framework = "MITRE ATT&CK" | ||
| [[rule.threat.technique]] | ||
| id = "T1546" | ||
| name = "Event Triggered Execution" | ||
| reference = "https://attack.mitre.org/techniques/T1546/" | ||
|
|
||
|
|
||
| [rule.threat.tactic] | ||
| id = "TA0003" | ||
| name = "Persistence" | ||
| reference = "https://attack.mitre.org/tactics/TA0003/" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should keep all the default events for the docs since we are not aggregating anything.