GitHub Advanced Security Change WITHOUT Repo Archived


Description

Identifies when GitHub Advanced Security (GHAS) settings are modified without the repository being archived within 90 minutes. GHAS provides code scanning, secret scanning, and dependency review to detect vulnerabilities and exposed credentials. Disabling GHAS while keeping repositories active suggests attackers hiding malicious code, preventing security alert detection, or facilitating backdoors and supply chain attacks.

Query

Detection:
  - Group:
      - ID: GHASChange
        RuleID: GitHub.Advanced.Security.Change
      - ID: RepoArchived
        RuleID: Github.Repo.Archived
        Absence: true
    MatchCriteria: 
      field_name:
      - GroupID: GHASChange
        Match: p_alert_context.repo
      - GroupID: RepoArchived
        Match: p_alert_context.repo
    EventEvaluationOrder: Chronological
    LookbackWindowMinutes: 1800
    Schedule:
      RateMinutes: 1440
      TimeoutMinutes: 10

Rule dependencies

Higher-order rule. It fires on other rules' alerts, not on raw events, so it cannot fire on its own. Deploy the rules it depends on too.

Depends on

Excludes

  • Github.Repo.Archived — excluded, not a dependency

Analyst notes

  1. Query GitHub audit logs for the repository in p_alert_context.repo in the 6 hours around the GHAS change to identify all commits, secret scanning alerts, code scanning alerts, and CI/CD configuration changes made by the user who disabled GHAS
  2. Review GitHub secret scanning history and code scanning alerts for the repository to check if new secrets or vulnerabilities were introduced around the time GHAS was disabled
  3. Check the user account's recent activity across all repositories in the organization audit log to identify if they made similar GHAS changes on other repositories or exhibited other suspicious behavior
Raw source GitHub Advanced Security Change WITHOUT Repo Archived · Panther Python
Esc
Published by panther-labs/panther-analysis ↗, licensed under Apache 2.0 ↗. Reproduced here unmodified.
AnalysisType: correlation_rule
RuleID: "GitHub.Advanced.Security.Change.NOT.FOLLOWED.BY.Repo.Archived"
DisplayName: "GitHub Advanced Security Change WITHOUT Repo Archived"
Enabled: false
Severity: Critical
Tags:
  - GitHub
  - Code Security
  - Defense Evasion
  - Configuration Change
Reports:
  MITRE ATT&CK:
    - TA0005:T1562.001
Description: >
  Identifies when GitHub Advanced Security (GHAS) settings are modified without the repository being archived within 90 minutes. GHAS provides code scanning, secret scanning, and dependency review to detect vulnerabilities and exposed credentials. Disabling GHAS while keeping repositories active suggests attackers hiding malicious code, preventing security alert detection, or facilitating backdoors and supply chain attacks.
Runbook: |
  1. Query GitHub audit logs for the repository in p_alert_context.repo in the 6 hours around the GHAS change to identify all commits, secret scanning alerts, code scanning alerts, and CI/CD configuration changes made by the user who disabled GHAS
  2. Review GitHub secret scanning history and code scanning alerts for the repository to check if new secrets or vulnerabilities were introduced around the time GHAS was disabled
  3. Check the user account's recent activity across all repositories in the organization audit log to identify if they made similar GHAS changes on other repositories or exhibited other suspicious behavior
Reference: https://docs.github.com/en/code-security/getting-started/auditing-security-alerts
Detection:
  - Group:
      - ID: GHASChange
        RuleID: GitHub.Advanced.Security.Change
      - ID: RepoArchived
        RuleID: Github.Repo.Archived
        Absence: true
    MatchCriteria: 
      field_name:
      - GroupID: GHASChange
        Match: p_alert_context.repo
      - GroupID: RepoArchived
        Match: p_alert_context.repo
    EventEvaluationOrder: Chronological
    LookbackWindowMinutes: 1800
    Schedule:
      RateMinutes: 1440
      TimeoutMinutes: 10
Tests:
    - Name: Security Change on Repo, Followed By Same Repo Archived
      ExpectedResult: false
      RuleOutputs:
        - ID: RepoArchived
          Matches:
            p_alert_context.repo:
              my-org/example-repo:
                - "2024-06-01T10:00:05Z"
        - ID: GHASChange
          Matches:
            p_alert_context.repo:
              my-org/example-repo:
                - "2024-06-01T10:00:01Z"
    - Name: Repo Archived followed by GHAS change on same repo
      ExpectedResult: false
      RuleOutputs:
        - ID: RepoArchived
          Matches:
            p_alert_context.repo:
              my-org/example-repo:
                - "2024-06-01T10:00:01Z"
        - ID: GHASChange
          Matches:
            p_alert_context.repo:
              my-org/example-repo:
                - "2024-06-01T10:00:05Z"
    - Name: Security Change on Repo, Followed By Different Repo Archived
      ExpectedResult: true
      RuleOutputs:
        - ID: GHASChange
          Matches:
            p_alert_context.repo:
              my-org/example-repo:
                - "2024-06-01T10:00:00Z"
        - ID: RepoArchived
          Matches:
            p_alert_context.repo:
              my-org/other-repo:
                - "2024-06-01T10:00:01Z"
    - Name: Security Change on Repo, Not Followed By Repo Archived
      ExpectedResult: true
      RuleOutputs:
        - ID: GHASChange
          Matches:
            p_alert_context.repo:
              my-org/example-repo:
                - "2024-06-01T10:00:00Z"

Detection rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.