-
Notifications
You must be signed in to change notification settings - Fork 612
[New Rules] Several GitHub Related Rules #5470
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
Aegrah
wants to merge
7
commits into
main
Choose a base branch
from
new-github-rules
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.
+644
−0
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f3a09a9
[New Rules] Several GitHub Related Rules
Aegrah d9481b0
Added additional references
Aegrah a0f5874
Update defense_evasion_secret_scanning_disabled.toml
Aegrah 3031194
Update persistence_new_pat_created.toml
Aegrah 0cb3342
Added two more rules
Aegrah 423e05c
Merge branch 'new-github-rules' of https://github.com/elastic/detecti…
Aegrah 10f6245
Merge branch 'main' into new-github-rules
Mikaayenson 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
55 changes: 55 additions & 0 deletions
55
rules/integrations/github/defense_evasion_secret_scanning_disabled.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,55 @@ | ||
| [metadata] | ||
| creation_date = "2023/12/16" | ||
| integration = ["github"] | ||
| maturity = "production" | ||
| updated_date = "2025/12/16" | ||
|
|
||
| [rule] | ||
| author = ["Elastic"] | ||
| description = """ | ||
| Detects when GitHub Secret Scanning is disabled for a repository. Adversaries may disable secret scanning to | ||
| evade detection of hardcoded secrets, such as API keys or credentials, that could be used for further | ||
| compromise or data exfiltration. | ||
| """ | ||
| from = "now-9m" | ||
| index = ["logs-github.audit-*"] | ||
| language = "eql" | ||
| license = "Elastic License v2" | ||
| name = "GitHub Secret Scanning Disabled" | ||
| references = [ | ||
| "https://www.wiz.io/blog/shai-hulud-2-0-ongoing-supply-chain-attack", | ||
| "https://trigger.dev/blog/shai-hulud-postmortem", | ||
| "https://posthog.com/blog/nov-24-shai-hulud-attack-post-mortem", | ||
| ] | ||
| risk_score = 21 | ||
| rule_id = "21c3536f-b674-43db-9bfc-dcf4cf9dcc37" | ||
| severity = "low" | ||
| tags = [ | ||
| "Domain: Cloud", | ||
| "Use Case: Threat Detection", | ||
| "Tactic: Defense Evasion", | ||
| "Data Source: Github", | ||
| ] | ||
| timestamp_override = "event.ingested" | ||
| type = "eql" | ||
| query = ''' | ||
| configuration where event.dataset == "github.audit" and event.type == "change" and event.action == "repository_secret_scanning.disable" | ||
| ''' | ||
|
|
||
| [[rule.threat]] | ||
| framework = "MITRE ATT&CK" | ||
|
|
||
| [[rule.threat.technique]] | ||
| id = "T1562" | ||
| name = "Impair Defenses" | ||
| reference = "https://attack.mitre.org/techniques/T1562/" | ||
|
|
||
| [[rule.threat.technique.subtechnique]] | ||
| id = "T1562.001" | ||
| name = "Disable or Modify Tools" | ||
| reference = "https://attack.mitre.org/techniques/T1562/001/" | ||
|
|
||
| [rule.threat.tactic] | ||
| id = "TA0005" | ||
| name = "Defense Evasion" | ||
| reference = "https://attack.mitre.org/tactics/TA0005/" |
65 changes: 65 additions & 0 deletions
65
rules/integrations/github/exfiltration_github_private_repository_turned_public.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,65 @@ | ||
| [metadata] | ||
| creation_date = "2023/12/16" | ||
| integration = ["github"] | ||
| maturity = "production" | ||
| updated_date = "2025/12/16" | ||
|
|
||
| [rule] | ||
| author = ["Elastic"] | ||
| description = """ | ||
| Detects when a private GitHub repository is changed to public visibility. Adversaries may change repository | ||
| visibility to public in order to exfiltrate sensitive code or data, potentially indicating a compromise or | ||
| unauthorized access. | ||
| """ | ||
| from = "now-9m" | ||
| index = ["logs-github.audit-*"] | ||
| language = "eql" | ||
| license = "Elastic License v2" | ||
| name = "GitHub Private Repository Turned Public" | ||
| risk_score = 21 | ||
| rule_id = "8c707e4c-bd20-4ff4-bda5-4dc3b34ce298" | ||
| severity = "low" | ||
| tags = [ | ||
| "Domain: Cloud", | ||
| "Use Case: Threat Detection", | ||
| "Tactic: Exfiltration", | ||
| "Tactic: Impact", | ||
| "Data Source: Github", | ||
| ] | ||
| timestamp_override = "event.ingested" | ||
| type = "eql" | ||
| query = ''' | ||
| configuration where event.dataset == "github.audit" and github.operation_type == "modify" and github.category == "repo" and | ||
| event.action == "repo.access" and github.previous_visibility == "private" and github.visibility == "public" | ||
| ''' | ||
|
|
||
| [[rule.threat]] | ||
| framework = "MITRE ATT&CK" | ||
|
|
||
| [[rule.threat.technique]] | ||
| id = "T1020" | ||
| name = "Automated Exfiltration" | ||
| reference = "https://attack.mitre.org/techniques/T1020/" | ||
|
|
||
| [[rule.threat.technique]] | ||
| id = "T1567" | ||
| name = "Exfiltration Over Web Service" | ||
| reference = "https://attack.mitre.org/techniques/T1567/" | ||
|
|
||
| [[rule.threat.technique.subtechnique]] | ||
| id = "T1567.001" | ||
| name = "Exfiltration to Code Repository" | ||
| reference = "https://attack.mitre.org/techniques/T1567/001/" | ||
|
|
||
| [rule.threat.tactic] | ||
| id = "TA0010" | ||
| name = "Exfiltration" | ||
| reference = "https://attack.mitre.org/tactics/TA0010/" | ||
|
|
||
| [[rule.threat]] | ||
| framework = "MITRE ATT&CK" | ||
|
|
||
| [rule.threat.tactic] | ||
| id = "TA0040" | ||
| name = "Impact" | ||
| reference = "https://attack.mitre.org/tactics/TA0040/" | ||
79 changes: 79 additions & 0 deletions
79
rules/integrations/github/exfiltration_high_number_of_cloning_by_user.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,79 @@ | ||
| [metadata] | ||
| creation_date = "2025/12/16" | ||
| integration = ["github"] | ||
| maturity = "production" | ||
| updated_date = "2025/12/16" | ||
|
|
||
| [rule] | ||
| author = ["Elastic"] | ||
| description = """ | ||
| Detects a high number of repository cloning actions by a single user within a short time frame. Adversaries may | ||
| clone multiple repositories to exfiltrate sensitive data. | ||
| """ | ||
| from = "now-9m" | ||
| interval = "8m" | ||
| language = "esql" | ||
| license = "Elastic License v2" | ||
| name = "GitHub Exfiltration via High Number of Repository Clones by User" | ||
| references = [ | ||
| "https://www.wiz.io/blog/shai-hulud-2-0-ongoing-supply-chain-attack", | ||
| "https://trigger.dev/blog/shai-hulud-postmortem", | ||
| "https://posthog.com/blog/nov-24-shai-hulud-attack-post-mortem", | ||
| ] | ||
| risk_score = 47 | ||
| rule_id = "19f3674c-f4a1-43bb-a89c-e4c6212275e0" | ||
| severity = "medium" | ||
| tags = [ | ||
| "Domain: Cloud", | ||
| "Use Case: Threat Detection", | ||
| "Tactic: Exfiltration", | ||
| "Data Source: Github", | ||
| ] | ||
| timestamp_override = "event.ingested" | ||
| type = "esql" | ||
| query = ''' | ||
| from logs-github.audit* metadata _id, _index, _version | ||
| | where | ||
| data_stream.dataset == "github.audit" and event.type == "change" and event.action == "git.clone" | ||
| | stats | ||
| Esql.event_count = COUNT(*), | ||
| Esql.github_org_values = values(github.org), | ||
| Esql.github_repo_values = values(github.repo), | ||
| Esql.github_repository_public_values = values(github.repository_public), | ||
| Esql.github_token_id_values = values(github.token_id), | ||
| Esql.github_user_agent_values = values(github.user_agent), | ||
| Esql.user_name_values = values(user.name), | ||
| Esql.agent_id_values = values(agent.id), | ||
| Esql.event_dataset_values = values(event.dataset), | ||
| Esql.data_stream_namespace_values = values(data_stream.namespace) | ||
|
|
||
| by user.name | ||
|
|
||
| | keep Esql.* | ||
|
|
||
| | where | ||
| Esql.event_count >= 25 | ||
| ''' | ||
|
|
||
| [[rule.threat]] | ||
| framework = "MITRE ATT&CK" | ||
|
|
||
| [[rule.threat.technique]] | ||
| id = "T1020" | ||
| name = "Automated Exfiltration" | ||
| reference = "https://attack.mitre.org/techniques/T1020/" | ||
|
|
||
| [[rule.threat.technique]] | ||
| id = "T1567" | ||
| name = "Exfiltration Over Web Service" | ||
| reference = "https://attack.mitre.org/techniques/T1567/" | ||
|
|
||
| [[rule.threat.technique.subtechnique]] | ||
| id = "T1567.001" | ||
| name = "Exfiltration to Code Repository" | ||
| reference = "https://attack.mitre.org/techniques/T1567/001/" | ||
|
|
||
| [rule.threat.tactic] | ||
| id = "TA0010" | ||
| name = "Exfiltration" | ||
| reference = "https://attack.mitre.org/tactics/TA0010/" |
87 changes: 87 additions & 0 deletions
87
rules/integrations/github/impact_github_repository_activity_from_unusual_ip.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,87 @@ | ||
| [metadata] | ||
| creation_date = "2025/12/16" | ||
| integration = ["github"] | ||
| maturity = "production" | ||
| updated_date = "2025/12/16" | ||
|
|
||
| [rule] | ||
| author = ["Elastic"] | ||
| description = """ | ||
| Detects when there is activity on a private GitHub repository from an unusual IP address. Adversaries may | ||
| access private repositories from unfamiliar IPs to exfiltrate sensitive code or data, potentially indicating | ||
| a compromise or unauthorized access. | ||
| """ | ||
| from = "now-9m" | ||
| index = ["logs-github.audit-*"] | ||
| language = "kuery" | ||
| license = "Elastic License v2" | ||
| name = "Github Activity on a Private Repository from an Unusual IP" | ||
| references = [ | ||
| "https://www.wiz.io/blog/shai-hulud-2-0-ongoing-supply-chain-attack", | ||
| "https://trigger.dev/blog/shai-hulud-postmortem", | ||
| "https://posthog.com/blog/nov-24-shai-hulud-attack-post-mortem", | ||
| ] | ||
| risk_score = 21 | ||
| rule_id = "daf2e0e0-0bab-4672-bfa1-62db0ee5ec22" | ||
| severity = "low" | ||
| tags = [ | ||
| "Domain: Cloud", | ||
| "Use Case: Threat Detection", | ||
| "Tactic: Impact", | ||
| "Tactic: Initial Access", | ||
| "Tactic: Persistence", | ||
| "Data Source: Github", | ||
| "Resources: Investigation Guide", | ||
| ] | ||
| timestamp_override = "event.ingested" | ||
| type = "new_terms" | ||
| query = ''' | ||
| event.dataset:"github.audit" and event.action:("git.push" or "git.clone") and repository_public:"false" | ||
| ''' | ||
|
|
||
| [[rule.threat]] | ||
| framework = "MITRE ATT&CK" | ||
|
|
||
| [rule.threat.tactic] | ||
| id = "TA0040" | ||
| name = "Impact" | ||
| reference = "https://attack.mitre.org/tactics/TA0040/" | ||
|
|
||
| [[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.new_terms] | ||
| field = "new_terms_fields" | ||
| value = ["source.ip", "github.repo"] | ||
|
|
||
| [[rule.new_terms.history_window_start]] | ||
| field = "history_window_start" | ||
| value = "now-7d" |
95 changes: 95 additions & 0 deletions
95
rules/integrations/github/impact_high_number_of_closed_pull_requests_by_user.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,95 @@ | ||
| [metadata] | ||
| creation_date = "2025/12/16" | ||
| integration = ["github"] | ||
| maturity = "production" | ||
| updated_date = "2025/12/16" | ||
|
|
||
| [rule] | ||
| author = ["Elastic"] | ||
| description = """ | ||
| Detects a high number of closed pull requests by a single user within a short time frame. Adversaries may | ||
| close multiple pull requests to disrupt development workflows or hide malicious changes. | ||
| """ | ||
| from = "now-9m" | ||
| interval = "8m" | ||
| language = "esql" | ||
| license = "Elastic License v2" | ||
| name = "High Number of Closed Pull Requests by User" | ||
| references = [ | ||
| "https://www.wiz.io/blog/shai-hulud-2-0-ongoing-supply-chain-attack", | ||
| "https://trigger.dev/blog/shai-hulud-postmortem", | ||
| "https://posthog.com/blog/nov-24-shai-hulud-attack-post-mortem", | ||
| ] | ||
| risk_score = 47 | ||
| rule_id = "098bd5cc-fd55-438f-b354-7d6cd9856a08" | ||
| severity = "medium" | ||
| tags = [ | ||
| "Domain: Cloud", | ||
| "Use Case: Threat Detection", | ||
| "Tactic: Impact", | ||
| "Tactic: Exfiltration", | ||
| "Data Source: Github", | ||
| ] | ||
| timestamp_override = "event.ingested" | ||
| type = "esql" | ||
| query = ''' | ||
| from logs-github.audit* metadata _id, _index, _version | ||
| | where | ||
| data_stream.dataset == "github.audit" and | ||
| github.category == "pull_request" and | ||
| event.type == "change" and | ||
| event.action == "pull_request.close" | ||
| | stats | ||
| Esql.document_count = COUNT(*), | ||
| Esql.github_org_values = values(github.org), | ||
| Esql.github_repo_values = values(github.repo), | ||
| Esql.github_user_agent_values = values(github.user_agent), | ||
| Esql.github_pull_request_url_values = values(github.pull_request_url), | ||
| Esql.user_name_values = values(user.name), | ||
| Esql.agent_id_values = values(agent.id), | ||
| Esql.event_dataset_values = values(event.dataset), | ||
| Esql.data_stream_namespace_values = values(data_stream.namespace) | ||
|
|
||
| by user.name | ||
|
|
||
| | keep Esql.* | ||
|
|
||
| | where | ||
| Esql.document_count >= 10 | ||
| ''' | ||
|
|
||
| [[rule.threat]] | ||
| framework = "MITRE ATT&CK" | ||
|
|
||
| [[rule.threat.technique]] | ||
| id = "T1485" | ||
| name = "Data Destruction" | ||
| reference = "https://attack.mitre.org/techniques/T1485/" | ||
|
|
||
| [rule.threat.tactic] | ||
| id = "TA0040" | ||
| name = "Impact" | ||
| reference = "https://attack.mitre.org/tactics/TA0040/" | ||
|
|
||
| [[rule.threat]] | ||
| framework = "MITRE ATT&CK" | ||
|
|
||
| [[rule.threat.technique]] | ||
| id = "T1020" | ||
| name = "Automated Exfiltration" | ||
| reference = "https://attack.mitre.org/techniques/T1020/" | ||
|
|
||
| [[rule.threat.technique]] | ||
| id = "T1567" | ||
| name = "Exfiltration Over Web Service" | ||
| reference = "https://attack.mitre.org/techniques/T1567/" | ||
|
|
||
| [[rule.threat.technique.subtechnique]] | ||
| id = "T1567.001" | ||
| name = "Exfiltration to Code Repository" | ||
| reference = "https://attack.mitre.org/techniques/T1567/001/" | ||
|
|
||
| [rule.threat.tactic] | ||
| id = "TA0010" | ||
| name = "Exfiltration" | ||
| reference = "https://attack.mitre.org/tactics/TA0010/" |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Can you find
previous_visibilityhttps://github.com/elastic/integrations/blob/main/packages/github/data_stream/audit/fields/fields.yml Might be somewhere else.May have to add to the non-ecs file.
Uh oh!
There was an error while loading. Please reload this page.
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.
++ its not in any of the other fields ymls under the Github Integration either:
Since:
is specified in the metadata, all of the data stream integrations are loaded under Github, probably needs to be added to non-ecs as it is either missing or more likely dynamic like other Github fields we have seen.