Microsoft Sentinel Analytic Rules
cloudbrothers.infoAzure Sentinel RepoToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

GitLab - External User Added to GitLab

Back
Idc1544d8f-cbbd-4e35-8d32-5b9312279833
RulenameGitLab - External User Added to GitLab
DescriptionThis queries GitLab Application logs to list external user accounts (i.e.: account not in allow-listed domains) which have been added to GitLab users.
SeverityMedium
TacticsPersistence
TechniquesT1136
Required data connectorsSyslog
KindScheduled
Query frequency1h
Query period1d
Trigger threshold0
Trigger operatorgt
Source Urihttps://github.com/Azure/Azure-Sentinel/blob/master/Solutions/GitLab/Analytic Rules/GitLab_ExternalUser.yaml
Version1.0.0
Arm templatec1544d8f-cbbd-4e35-8d32-5b9312279833.json
Deploy To Azure
// List of allow-listed domains
let allowedDomain = pack_array("mydomain.com");
GitLabAudit
| where AddAction == "user"
| project AuthorName, IPAddress, User = EntityName
| join (GitLabApp 
| where UserAdded == 1
| parse kind=regex Message with "User \"" User "\"" EmailAddress " was created"
| project tostring(User), EmailAddress = substring(EmailAddress,2,strlen(EmailAddress)-3)) on User
| project  AuthorName, IPAddress, User, EmailAddress, DomainName = tostring(extract("@(.*)$", 1, EmailAddress))
| where allowedDomain !contains DomainName
severity: Medium
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/GitLab/Analytic Rules/GitLab_ExternalUser.yaml
id: c1544d8f-cbbd-4e35-8d32-5b9312279833
name: GitLab - External User Added to GitLab
query: |
  // List of allow-listed domains
  let allowedDomain = pack_array("mydomain.com");
  GitLabAudit
  | where AddAction == "user"
  | project AuthorName, IPAddress, User = EntityName
  | join (GitLabApp 
  | where UserAdded == 1
  | parse kind=regex Message with "User \"" User "\"" EmailAddress " was created"
  | project tostring(User), EmailAddress = substring(EmailAddress,2,strlen(EmailAddress)-3)) on User
  | project  AuthorName, IPAddress, User, EmailAddress, DomainName = tostring(extract("@(.*)$", 1, EmailAddress))
  | where allowedDomain !contains DomainName  
entityMappings:
- fieldMappings:
  - columnName: IPAddress
    identifier: Address
  entityType: IP
- fieldMappings:
  - columnName: User
    identifier: FullName
  entityType: Account
- fieldMappings:
  - columnName: AuthorName
    identifier: FullName
  entityType: Account
- fieldMappings:
  - columnName: DomainName
    identifier: DomainName
  entityType: DNS
queryPeriod: 1d
triggerThreshold: 0
tactics:
- Persistence
version: 1.0.0
kind: Scheduled
relevantTechniques:
- T1136
queryFrequency: 1h
status: Available
requiredDataConnectors:
- dataTypes:
  - Syslog
  connectorId: Syslog
description: |
    'This queries GitLab Application logs to list external user accounts (i.e.: account not in allow-listed domains) which have been added to GitLab users.'
triggerOperator: gt
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workspace": {
      "type": "String"
    }
  },
  "resources": [
    {
      "apiVersion": "2023-02-01-preview",
      "id": "[concat(resourceId('Microsoft.OperationalInsights/workspaces/providers', parameters('workspace'), 'Microsoft.SecurityInsights'),'/alertRules/c1544d8f-cbbd-4e35-8d32-5b9312279833')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/c1544d8f-cbbd-4e35-8d32-5b9312279833')]",
      "properties": {
        "alertRuleTemplateName": "c1544d8f-cbbd-4e35-8d32-5b9312279833",
        "customDetails": null,
        "description": "'This queries GitLab Application logs to list external user accounts (i.e.: account not in allow-listed domains) which have been added to GitLab users.'\n",
        "displayName": "GitLab - External User Added to GitLab",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "IP",
            "fieldMappings": [
              {
                "columnName": "IPAddress",
                "identifier": "Address"
              }
            ]
          },
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "User",
                "identifier": "FullName"
              }
            ]
          },
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "AuthorName",
                "identifier": "FullName"
              }
            ]
          },
          {
            "entityType": "DNS",
            "fieldMappings": [
              {
                "columnName": "DomainName",
                "identifier": "DomainName"
              }
            ]
          }
        ],
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/GitLab/Analytic Rules/GitLab_ExternalUser.yaml",
        "query": "// List of allow-listed domains\nlet allowedDomain = pack_array(\"mydomain.com\");\nGitLabAudit\n| where AddAction == \"user\"\n| project AuthorName, IPAddress, User = EntityName\n| join (GitLabApp \n| where UserAdded == 1\n| parse kind=regex Message with \"User \\\"\" User \"\\\"\" EmailAddress \" was created\"\n| project tostring(User), EmailAddress = substring(EmailAddress,2,strlen(EmailAddress)-3)) on User\n| project  AuthorName, IPAddress, User, EmailAddress, DomainName = tostring(extract(\"@(.*)$\", 1, EmailAddress))\n| where allowedDomain !contains DomainName\n",
        "queryFrequency": "PT1H",
        "queryPeriod": "P1D",
        "severity": "Medium",
        "status": "Available",
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "Persistence"
        ],
        "techniques": [
          "T1136"
        ],
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}