|
| 1 | +[metadata] |
| 2 | +creation_date = "2025/12/09" |
| 3 | +integration = ["github"] |
| 4 | +maturity = "production" |
| 5 | +updated_date = "2025/12/09" |
| 6 | + |
| 7 | +[rule] |
| 8 | +author = ["Elastic"] |
| 9 | +description = """ |
| 10 | +Detects when the github-actions[bot] pushes code to a repository where it has not performed this behavior before in a certain time window. This may |
| 11 | +indicate a supply chain attack where malicious code running in a CI workflow attempts to modify repository contents, |
| 12 | +such as injecting backdoor workflow files. The Shai-Hulud 2.0 attack used npm preinstall hooks to push malicious |
| 13 | +workflow files from within GitHub Actions runners. |
| 14 | +""" |
| 15 | +false_positives = [ |
| 16 | + """ |
| 17 | + Legitimate CI/CD automation that commits and pushes changes (e.g., auto-formatting, changelog updates, version |
| 18 | + bumps, Dependabot auto-merge) will trigger this alert on first use in a repository. Review the repository's |
| 19 | + workflow configurations to determine if bot pushes are expected. |
| 20 | + """, |
| 21 | +] |
| 22 | +from = "now-9m" |
| 23 | +index = ["logs-github.audit-*"] |
| 24 | +language = "kuery" |
| 25 | +license = "Elastic License v2" |
| 26 | +name = "GitHub Actions Bot Pushed to Repository for First Time" |
| 27 | +note = """## Triage and analysis |
| 28 | +
|
| 29 | +### Investigating GitHub Actions Bot Pushed to Repository for First Time |
| 30 | +
|
| 31 | +This rule detects when the GitHub Actions bot pushes to a repository where it hasn't pushed before. While this can be |
| 32 | +legitimate automation, it may also indicate a supply chain attack where malicious code executes during CI and attempts |
| 33 | +to modify repository contents. |
| 34 | +
|
| 35 | +### Possible investigation steps |
| 36 | +
|
| 37 | +- Review the `github.repo` field to identify the affected repository. |
| 38 | +- Check recent workflow runs in the repository to identify which workflow triggered the push. |
| 39 | +- Examine the repository's commit history to see what files were modified by the bot push. |
| 40 | +- Look for newly added or modified files in `.github/workflows/` directory. |
| 41 | +- Review the repository's dependencies for recently added or updated packages with preinstall/postinstall hooks. |
| 42 | +- Check if the repository has legitimate automation that would explain bot pushes (Dependabot, Renovate, release automation). |
| 43 | +- Correlate with `protected_branch.rejected_ref_update` events to see if workflow injection was blocked. |
| 44 | +- Search for other repositories in the organization with similar suspicious activity. |
| 45 | +
|
| 46 | +### False positive analysis |
| 47 | +
|
| 48 | +- Repositories with auto-commit workflows (formatting, changelog generation, version bumps) will trigger on first run. |
| 49 | +- Dependabot or Renovate auto-merge configurations cause legitimate bot pushes. |
| 50 | +- GitHub Pages deployment workflows may push to gh-pages branches. |
| 51 | +- Release automation that updates version files or generates artifacts. |
| 52 | +
|
| 53 | +### Response and remediation |
| 54 | +
|
| 55 | +- If the push is unexpected, immediately review the commit contents for malicious files. |
| 56 | +- Check for suspicious workflow files (e.g., `discussion_*.yaml`, `formatter_*.yml`). |
| 57 | +- Audit all dependencies in the affected repository for malicious packages. |
| 58 | +- Rotate any secrets that may have been exposed during the workflow run. |
| 59 | +- Enable branch protection rules to require PR reviews for all changes. |
| 60 | +- Consider restricting GITHUB_TOKEN permissions in workflow files using `permissions:` key. |
| 61 | +""" |
| 62 | +references = [ |
| 63 | + "https://www.wiz.io/blog/shai-hulud-2-0-ongoing-supply-chain-attack", |
| 64 | + "https://www.elastic.co/blog/shai-hulud-worm-npm-supply-chain-compromise", |
| 65 | +] |
| 66 | +risk_score = 21 |
| 67 | +rule_id = "03245b25-3849-4052-ab48-72de65a82c35" |
| 68 | +severity = "low" |
| 69 | +tags = [ |
| 70 | + "Domain: Cloud", |
| 71 | + "Use Case: Threat Detection", |
| 72 | + "Tactic: Initial Access", |
| 73 | + "Tactic: Persistence", |
| 74 | + "Data Source: Github", |
| 75 | + "Resources: Investigation Guide", |
| 76 | +] |
| 77 | +timestamp_override = "event.ingested" |
| 78 | +type = "new_terms" |
| 79 | + |
| 80 | +query = ''' |
| 81 | +event.dataset: "github.audit" and |
| 82 | + event.action: "git.push" and |
| 83 | + user.name: "github-actions[bot]" |
| 84 | +''' |
| 85 | + |
| 86 | +[[rule.threat]] |
| 87 | +framework = "MITRE ATT&CK" |
| 88 | +[[rule.threat.technique]] |
| 89 | +id = "T1195" |
| 90 | +name = "Supply Chain Compromise" |
| 91 | +reference = "https://attack.mitre.org/techniques/T1195/" |
| 92 | +[[rule.threat.technique.subtechnique]] |
| 93 | +id = "T1195.002" |
| 94 | +name = "Compromise Software Supply Chain" |
| 95 | +reference = "https://attack.mitre.org/techniques/T1195/002/" |
| 96 | + |
| 97 | +[rule.threat.tactic] |
| 98 | +id = "TA0001" |
| 99 | +name = "Initial Access" |
| 100 | +reference = "https://attack.mitre.org/tactics/TA0001/" |
| 101 | + |
| 102 | +[[rule.threat]] |
| 103 | +framework = "MITRE ATT&CK" |
| 104 | +[[rule.threat.technique]] |
| 105 | +id = "T1059" |
| 106 | +name = "Command and Scripting Interpreter" |
| 107 | +reference = "https://attack.mitre.org/techniques/T1059/" |
| 108 | + |
| 109 | +[rule.threat.tactic] |
| 110 | +id = "TA0002" |
| 111 | +name = "Execution" |
| 112 | +reference = "https://attack.mitre.org/tactics/TA0002/" |
| 113 | + |
| 114 | +[rule.new_terms] |
| 115 | +field = "new_terms_fields" |
| 116 | +value = ["github.org_id","github.repo"] |
| 117 | + |
| 118 | +[[rule.new_terms.history_window_start]] |
| 119 | +field = "history_window_start" |
| 120 | +value = "now-7d" |
0 commit comments