<!-- Sanitized reference copy. Original comments removed; OAuth domains generalized.
     Logic is otherwise unchanged and includes known review issues.
     Read README.md and the draft Technical Review Notes before use. -->

<group name="gitlab,authentication,">

  <rule id="110100" level="5">
    <decoded_as>json</decoded_as>
    <field name="controller">^SessionsController$</field>
    <field name="path">^/users/sign_in$</field>
    <field name="method">^POST$</field>
    <action type="pcre2">^new$</action>
    <status type="pcre2">^200$</status>
    <description>GitLab failed web sign-in from $(remote_ip), UA $(ua), correlation $(correlation_id)</description>
    <mitre><id>T1110</id></mitre>
    <group>authentication_failed,credential_access,</group>
  </rule>

  <rule id="110105" level="3">
    <decoded_as>json</decoded_as>
    <field name="controller">^SessionsController$</field>
    <field name="path">^/users/sign_in$</field>
    <field name="method">^POST$</field>
    <status type="pcre2">^302$</status>
    <description>GitLab successful web sign-in from $(remote_ip), correlation $(correlation_id)</description>
    <group>authentication_success,</group>
  </rule>

  <rule id="110101" level="10" frequency="5" timeframe="600" ignore="300">
    <if_matched_sid>110100</if_matched_sid>
    <same_field>remote_ip</same_field>
    <description>GitLab: repeated failed web sign-ins from $(remote_ip)</description>
    <mitre><id>T1110.001</id></mitre>
    <group>brute_force,authentication_failures,</group>
  </rule>

  <rule id="110106" level="5">
    <decoded_as>gitlab-failed-login</decoded_as>
    <description>GitLab failed login for account $(dstuser) from $(srcip)</description>
    <mitre><id>T1110</id></mitre>
    <group>authentication_failed,credential_access,</group>
  </rule>

  <rule id="110102" level="10" frequency="5" timeframe="600" ignore="300">
    <if_matched_sid>110106</if_matched_sid>
    <same_field>dstuser</same_field>
    <description>GitLab: repeated failed logins against account $(dstuser)</description>
    <mitre><id>T1110.001</id></mitre>
    <group>brute_force,account_lockout_risk,</group>
  </rule>

  <rule id="110103" level="12" frequency="5" timeframe="600" ignore="300">
    <if_matched_sid>110106</if_matched_sid>
    <same_srcip />
    <different_field>dstuser</different_field>
    <description>GitLab: one source IP attempted multiple accounts: $(srcip)</description>
    <mitre><id>T1110.003</id></mitre>
    <group>password_spraying,</group>
  </rule>

</group>
