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
relevantTechniques:
- T1136
name: GitLab - External User Added to GitLab
requiredDataConnectors:
- dataTypes:
  - Syslog
  connectorId: Syslog
entityMappings:
- fieldMappings:
  - identifier: Address
    columnName: IPAddress
  entityType: IP
- fieldMappings:
  - identifier: FullName
    columnName: User
  entityType: Account
- fieldMappings:
  - identifier: FullName
    columnName: AuthorName
  entityType: Account
- fieldMappings:
  - identifier: DomainName
    columnName: DomainName
  entityType: DNS
triggerThreshold: 0
id: c1544d8f-cbbd-4e35-8d32-5b9312279833
tactics:
- Persistence
version: 1.0.0
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/GitLab/Analytic Rules/GitLab_ExternalUser.yaml
queryPeriod: 1d
kind: Scheduled
queryFrequency: 1h
severity: Medium
status: Available
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.'
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  
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": "2024-01-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",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "Persistence"
        ],
        "techniques": [
          "T1136"
        ],
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}