GitHub Protected Branch Settings Changed

This rule detects protected branch setting changes on a GitHub repository originating from a user agent not previously seen performing protected branch changes in the last 7 days. Branch protection rules enforce workflows and requirements before a contributor can push changes to a branch. Unauthorized changes could be used to lower your organization's security posture and leave you exposed for future attacks. Both push-time enforcement events (protected_branch.rejected_ref_update, a push blocked by branch protection) and administrative bypasses (protected_branch.policy_override) are retained, because a failed modification attempt and an admin override are each security-relevant indicators, particularly during CI/CD compromise once administrative access is obtained. Keying on a new user agent suppresses the recurring, expected automation that drives most of the event volume while surfacing changes from unfamiliar tooling or clients. If a specific user agent is noisy in a given environment, scope it with an exception rather than removing the action from the query.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2023/08/29"
  3integration = ["github"]
  4maturity = "production"
  5updated_date = "2026/11/02"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10This rule detects protected branch setting changes on a GitHub repository originating from a user agent not previously
 11seen performing protected branch changes in the last 7 days. Branch protection rules enforce workflows and requirements
 12before a contributor can push changes to a branch. Unauthorized changes could be used to lower your organization's
 13security posture and leave you exposed for future attacks. Both push-time enforcement events
 14(`protected_branch.rejected_ref_update`, a push blocked by branch protection) and administrative bypasses
 15(`protected_branch.policy_override`) are retained, because a failed modification attempt and an admin override are each
 16security-relevant indicators, particularly during CI/CD compromise once administrative access is obtained. Keying on a
 17new user agent suppresses the recurring, expected automation that drives most of the event volume while surfacing
 18changes from unfamiliar tooling or clients. If a specific user agent is noisy in a given environment, scope it with an
 19exception rather than removing the action from the query.
 20"""
 21from = "now-9m"
 22index = ["logs-github.audit-*"]
 23language = "kuery"
 24license = "Elastic License v2"
 25name = "GitHub Protected Branch Settings Changed"
 26note = """## Triage and analysis
 27
 28> **Disclaimer**:
 29> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
 30
 31### Investigating GitHub Protected Branch Settings Changed
 32
 33GitHub's protected branch settings are crucial for maintaining code integrity by enforcing rules like requiring reviews before merging. Adversaries may alter these settings to bypass security measures, facilitating unauthorized code changes. The detection rule monitors audit logs for changes in branch protection, flagging potential defense evasion attempts for further investigation.
 34
 35### Possible investigation steps
 36
 37- Review the GitHub audit logs to identify the specific changes made to the protected branch settings, focusing on entries where event.dataset is "github.audit" and github.category is "protected_branch".
 38- Determine the user account responsible for the changes by examining the audit log details, and verify if the account has a legitimate reason to modify branch protection settings.
 39- Check the timing of the changes to see if they coincide with any other suspicious activities or known incidents within the organization.
 40- Investigate the context of the change by reviewing recent pull requests or commits to the affected branch to assess if the changes align with ongoing development activities.
 41- Communicate with the repository owner or relevant team members to confirm if the changes were authorized and necessary for current project requirements.
 42- Evaluate the impact of the changes on the repository's security posture and consider reverting the changes if they were unauthorized or pose a security risk.
 43
 44### False positive analysis
 45
 46- Routine updates by trusted team members may trigger alerts. To manage this, create exceptions for specific users or teams who regularly update branch protection settings as part of their role.
 47- Automated tools or scripts that modify branch settings for legitimate reasons can cause false positives. Identify these tools and whitelist their activities in the monitoring system.
 48- Scheduled maintenance or policy updates might lead to expected changes in branch protection settings. Document these events and adjust the detection rule to ignore changes during these periods.
 49- Changes made by administrators during onboarding or offboarding processes can be mistaken for unauthorized activity. Ensure these processes are well-documented and communicated to the security team to prevent unnecessary alerts.
 50
 51### Response and remediation
 52
 53- Immediately revert any unauthorized changes to the protected branch settings to restore the original security posture.
 54- Conduct a review of recent commits and merges to the affected branch to identify any unauthorized code changes that may have occurred during the period of altered settings.
 55- Temporarily restrict access to the repository for users who made unauthorized changes until a full investigation is completed.
 56- Notify the security team and relevant stakeholders about the incident for further analysis and to determine if additional security measures are needed.
 57- Implement additional monitoring on the affected repository to detect any further unauthorized changes or suspicious activities.
 58- Review and update access controls and permissions for the repository to ensure that only authorized personnel can modify branch protection settings.
 59- Document the incident, including the timeline of events and actions taken, to improve future response efforts and update incident response plans."""
 60risk_score = 47
 61rule_id = "07639887-da3a-4fbf-9532-8ce748ff8c50"
 62severity = "medium"
 63tags = [
 64    "Domain: Cloud",
 65    "Use Case: Threat Detection",
 66    "Tactic: Defense Evasion",
 67    "Data Source: Github",
 68    "Data Source: GitHub Audit Logs",
 69    "Resources: Investigation Guide",
 70    "Noise: High",
 71    "Performance: Fast",
 72    "Profile: Aggressive",
 73    "Rule Type: New Terms",
 74    "Platform: GitHub",
 75    "Domain: SaaS",
 76]
 77timestamp_override = "event.ingested"
 78type = "new_terms"
 79
 80query = '''
 81data_stream.dataset: "github.audit" and
 82    github.category: "protected_branch" and
 83    event.type: "change"
 84'''
 85
 86
 87[rule.new_terms]
 88field = "new_terms_fields"
 89value = ["user_agent.original"]
 90
 91[[rule.new_terms.history_window_start]]
 92field = "history_window_start"
 93value = "now-7d"
 94
 95
 96[[rule.threat]]
 97framework = "MITRE ATT&CK"
 98[[rule.threat.technique]]
 99id = "T1562"
100name = "Impair Defenses"
101reference = "https://attack.mitre.org/techniques/T1562/"
102[[rule.threat.technique.subtechnique]]
103id = "T1562.001"
104name = "Disable or Modify Tools"
105reference = "https://attack.mitre.org/techniques/T1562/001/"
106
107
108
109[rule.threat.tactic]
110id = "TA0005"
111name = "Defense Evasion"
112reference = "https://attack.mitre.org/tactics/TA0005/"

Triage and analysis

Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.

Investigating GitHub Protected Branch Settings Changed

GitHub's protected branch settings are crucial for maintaining code integrity by enforcing rules like requiring reviews before merging. Adversaries may alter these settings to bypass security measures, facilitating unauthorized code changes. The detection rule monitors audit logs for changes in branch protection, flagging potential defense evasion attempts for further investigation.

Possible investigation steps

  • Review the GitHub audit logs to identify the specific changes made to the protected branch settings, focusing on entries where event.dataset is "github.audit" and github.category is "protected_branch".
  • Determine the user account responsible for the changes by examining the audit log details, and verify if the account has a legitimate reason to modify branch protection settings.
  • Check the timing of the changes to see if they coincide with any other suspicious activities or known incidents within the organization.
  • Investigate the context of the change by reviewing recent pull requests or commits to the affected branch to assess if the changes align with ongoing development activities.
  • Communicate with the repository owner or relevant team members to confirm if the changes were authorized and necessary for current project requirements.
  • Evaluate the impact of the changes on the repository's security posture and consider reverting the changes if they were unauthorized or pose a security risk.

False positive analysis

  • Routine updates by trusted team members may trigger alerts. To manage this, create exceptions for specific users or teams who regularly update branch protection settings as part of their role.
  • Automated tools or scripts that modify branch settings for legitimate reasons can cause false positives. Identify these tools and whitelist their activities in the monitoring system.
  • Scheduled maintenance or policy updates might lead to expected changes in branch protection settings. Document these events and adjust the detection rule to ignore changes during these periods.
  • Changes made by administrators during onboarding or offboarding processes can be mistaken for unauthorized activity. Ensure these processes are well-documented and communicated to the security team to prevent unnecessary alerts.

Response and remediation

  • Immediately revert any unauthorized changes to the protected branch settings to restore the original security posture.
  • Conduct a review of recent commits and merges to the affected branch to identify any unauthorized code changes that may have occurred during the period of altered settings.
  • Temporarily restrict access to the repository for users who made unauthorized changes until a full investigation is completed.
  • Notify the security team and relevant stakeholders about the incident for further analysis and to determine if additional security measures are needed.
  • Implement additional monitoring on the affected repository to detect any further unauthorized changes or suspicious activities.
  • Review and update access controls and permissions for the repository to ensure that only authorized personnel can modify branch protection settings.
  • Document the incident, including the timeline of events and actions taken, to improve future response efforts and update incident response plans.

Related rules

to-top