Apache Tapestry — 1 vulnerability check

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

← All products · Feeds on GitHub

Apache Tapestry AppModule.class disclosure via the asset path

CVECVE-2021-27850
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionset_var, http_request, match, script · highest QoD 75
Feedtests/vulnerabilities/tapestry/CVE-2021-27850.yaml

Requests AppModule.class through the assets path with a trailing slash, follows the redirect and reports when Tapestry serves the compiled class, which holds the HMAC key used to sign serialized data.

How noctis detects it

  1. HTTP(S) request GET /assets/app/something/services/AppModule.class/
  2. Checks r1.headers.location for (?:https?://[^/]+)?(/.+)$
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET {{loc}}/
  5. Checks r2.headers.content-type for application/java
  6. Checks r2.body for InnerClasses → finding QoD 75: Apache Tapestry exposed the compiled AppModule.class (application/java, 'InnerClasses') after a redirect from the asset path — CVE-2021-278…

References:

Feed source — tests/vulnerabilities/tapestry/CVE-2021-27850.yaml
uid: 7c1f0a2e-3b64-4a7d-9e21-2f8c6d50a11b
name: "CVE-2021-27850 — Apache Tapestry AppModule.class disclosure via the asset path (CVSS 9.8)"
description: "Requests AppModule.class through the assets path with a trailing slash, follows the redirect and reports when Tapestry serves the compiled class, which holds the HMAC key used to sign serialized data."
cves: [CVE-2021-27850]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.30
tags: [apache, tapestry, rce]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2021-27850"
  - "OpenVAS NASL 2021/apache/gb_apache_tapestry_rce_vuln_apr21.nasl (GPL-2.0-only)"
# Ported from OpenVAS/Greenbone NASL 2021/apache/gb_apache_tapestry_rce_vuln_apr21.nasl
# (GPL-2.0-only, Greenbone Community Feed). Faithful two-request flow, exactly as the plugin:
#   1. GET the AppModule.class asset directory — a vulnerable build answers 30x with a Location
#      pointing at the downloadable compiled class (the HMAC-key disclosure primitive).
#   2. Follow that Location WITH A TRAILING SLASH appended (the NASL appends "/", which is what
#      bypasses the .class blocklist on a real target), then require the class served as
#      application/java containing "InnerClasses".
# A patched build (>=5.6.3 / >=5.7.1) still redirects but then refuses the class (404), so the
# content-type/body gate never fires (non-trivial negative that exercises the real fix).
steps:
  - id: init
    action: set_var
    var_name: redirect_seen
    var_value: false
  - id: init2
    action: set_var
    var_name: java_ct
    var_value: false

  - id: probe-asset
    action: http_request
    method: GET
    path: "/assets/app/something/services/AppModule.class/"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: r1

  # Extract the redirect target (the downloadable class URL) and follow it, exactly as the NASL
  # does with http_extract_location_from_redirect. Any 30x counts, and an absolute Location
  # (http://host/path) is reduced to its path so the follow-up request stays on this host.
  - id: redirect-gate
    action: match
    source: r1.headers.location
    pattern: "(?:https?://[^/]+)?(/.+)$"
    condition: "r1.status >= 300 && r1.status < 400"
    store_as: loc_match
    on_match:
      set_vars:
        redirect_seen: true
  - id: loc-store
    action: script
    code: 'loc_match["captures"][0]'
    store_as: loc
    condition: "redirect_seen == true"

  - id: fetch-class
    action: http_request
    method: GET
    path: "{{loc}}/"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "redirect_seen == true"
    store_as: r2
  # The NASL also requires the class to be served as application/java, not just any 200 body.
  - id: ct-gate
    action: match
    source: r2.headers.content-type
    pattern: "application/java"
    condition: "redirect_seen == true && r2.status == 200"
    on_match:
      set_vars:
        java_ct: true

  - id: detect
    action: match
    source: r2.body
    pattern: "InnerClasses"
    condition: "java_ct == true"
    on_match:
      finding:
        confidence_delta: 0.50
        qod: 75
        evidence: "Apache Tapestry exposed the compiled AppModule.class (application/java, 'InnerClasses') after a redirect from the asset path — CVE-2021-27850 HMAC-key disclosure / RCE primitive."
      stop: true

View these feeds on GitHub