CVE-2024-56337: Apache Tomcat - Write-Enabled Default Servlet (TOCTOU RCE Exposure)

2026-11-16 PoC Public

Description

Apache Tomcat (9.0.0.M1-9.0.97, 10.1.0-M1-10.1.33, 11.0.0-M1-11.0.1, and EOL 8.5.x) is vulnerable to a TOCTOU race condition during JSP compilation (CVE-2024-56337, an incomplete fix for CVE-2024-50379). On a case-insensitive file system, a concurrent read and upload of the same file bypasses Tomcat's case-sensitivity check, causing an uploaded file to be treated as a JSP and leading to remote code execution. Exploitation requires the default servlet to be configured with write support enabled (readonly=false), which is not the default. This template actively confirms that necessary precondition - it uploads a benign file via PUT and reads it back to prove the default servlet is write-enabled - without performing the destructive race or uploading a JSP.

Details

CVE
CVE-2024-56337 · CVE.org
Severity
高危
Published
PoC
Public

PoC

id: CVE-2024-56337

info:
  name: Apache Tomcat - Write-Enabled Default Servlet (TOCTOU RCE Exposure)
  author: DhiyaneshDk
  severity: critical
  description: |
    Apache Tomcat (9.0.0.M1-9.0.97, 10.1.0-M1-10.1.33, 11.0.0-M1-11.0.1, and EOL 8.5.x) is vulnerable to a TOCTOU race condition during JSP compilation (CVE-2024-56337, an incomplete fix for CVE-2024-50379). On a case-insensitive file system, a concurrent read and upload of the same file bypasses Tomcat's case-sensitivity check, causing an uploaded file to be treated as a JSP and leading to remote code execution. Exploitation requires the default servlet to be configured with write support enabled (readonly=false), which is not the default. This template actively confirms that necessary precondition - it uploads a benign file via PUT and reads it back to prove the default servlet is write-enabled - without performing the destructive race or uploading a JSP.
  impact: |
    A write-enabled default servlet lets an unauthenticated attacker upload files to the web root. Combined with a vulnerable Tomcat version on a case-insensitive file system (and, on Java 8/11, sun.io.useCanonCaches left at true), this enables remote code execution via the TOCTOU race.
  remediation: |
    Set the default servlet readonly to true (the default) unless write access is required, upgrade Tomcat to 9.0.98 / 10.1.34 / 11.0.2 or later, and on Java 8/11 set the system property sun.io.useCanonCaches to false.
  reference:
    - https://nvd.nist.gov/vuln/detail/CVE-2024-56337
    - https://lists.apache.org/thread/2bjnh3p78b89n5hw539hh31sr7tt7m22
    - https://github.com/advisories/GHSA-27hp-xhwr-wr2m
  classification:
    cvss-metrics: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
    cvss-score: 9.8
    cve-id: CVE-2024-56337
    epss-score: 0.08969
    epss-percentile: 0.95342
    cwe-id: CWE-367
  metadata:
    verified: true
    max-request: 3
    shodan-query: title:"Apache Tomcat"
    fofa-query: title="Apache Tomcat"
  tags: cve,cve2024,tomcat,apache,rce,race-condition,toctou,intrusive,vkev

variables:
  canary: "{{rand_base(18)}}"
  filename: "{{rand_base(10)}}.txt"

flow: http(1) && http(2) && http(3)

http:
  - raw:
      - |
        PUT /{{filename}} HTTP/1.1
        Host: {{Hostname}}
        Content-Type: text/plain

        {{canary}}

    matchers:
      - type: dsl
        dsl:
          - "status_code == 201"
          - "status_code == 204"
        condition: or
        internal: true

  - raw:
      - |
        GET /{{filename}} HTTP/1.1
        Host: {{Hostname}}

    matchers-condition: and
    matchers:
      - type: dsl
        name: file-written-and-served
        dsl:
          - "status_code == 200"
          - "contains(body, canary)"
        condition: and

      - type: regex
        name: tomcat-default-servlet
        part: header
        regex:
          - 'W/"[0-9]+-[0-9]+"'

    extractors:
      - type: regex
        part: header
        group: 1
        regex:
          - '(?i)etag: (W/"[0-9]+-[0-9]+")'

  - raw:
      - |
        DELETE /{{filename}} HTTP/1.1
        Host: {{Hostname}}

    matchers:
      - type: dsl
        dsl:
          - "status_code >= 100"
        internal: true
# digest: 4a0a00473045022039e0241656bc3bc3f27644727cbec2a2281731f8d144488ea8d2a9178413de33022100f469c09605fac02a8b74de90142888a22ccb66029bf5fb45c05c862289bc7c6c:922c64590222798bb761d5b6d8e72950

# Visit https://trap.biu.life/ to view exploit trends for this vulnerability.

References

微信搜一搜 biu.life