pFile — 1 vulnerability check

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

← All products · Feeds on GitHub

pFile kommentar.php reflected cross-site scripting

CVECVE-2012-1211
Severitymedium
Categoryxss — XSS
Serviceshttp, https
Detectionset_var, script, http_request, match · highest QoD 75
Feedtests/vulnerabilities/pfile/CVE-2012-1211.yaml

pFile, a PHP file-download manager, prints the filecat parameter of kommentar.php back into the action attribute of its comment form without encoding it, so a crafted link closes the attribute and injects a script tag that runs in the visitor's browser. Version 1.02 is affected.

The check requests kommentar.php on the usual install paths (/pfile, the web root, /pfile2) with filecat set to a quote, a closing bracket and a script tag holding a random marker. It reports the flaw when the reply is a 200 page whose form action contains that payload unescaped.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/kommentar.php?filecat=%22%3E%3Cscript%3E{{mark}}%3C/script%3E&fileid=0
  3. Parses / computes the next value with a Rhai script
  4. Checks hit for echoes the filecat → finding QoD 75: pFile kommentar.php reflected cross-site scripting

References:

Feed source — tests/vulnerabilities/pfile/CVE-2012-1211.yaml
# Powie pFile 1.02 — kommentar.php reflected cross-site scripting, CVE-2012-1211.
#
# CVE mapping: the backlog issue (#1674) lists CVE-2012-1210 (SQL injection in
# file.php, id parameter) and CVE-2012-1211 (XSS in kommentar.php, filecat
# parameter). The check this feed ports only exercises the XSS, so `cves` names
# CVE-2012-1211. The SQL injection is not covered: the product's source is no
# longer distributed and the advisory (BID 51982) gives only a truncated
# example URL for file.php, so there is no known query to prove it with.
# NVD carries no CVSS v3 score for CVE-2012-1211 (v2 only, 4.3), hence no `cvss`.
#
# Ported from OpenVAS/Greenbone NVT `2012/gb_pfile_51982.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.103435, GPL-2.0-only): GET
# <dir>/kommentar.php?filecat="><script>alert(/xss-test/)</script>&fileid=0 on
# /pfile and the CGI dirs; vulnerable when the reply is a 200 whose form action
# echoes the payload: ACTION="kommentar.php?fileid=.&filecat="><script>...
#
# Better than the NVT:
#   - the script body is a random marker instead of the fixed alert(/xss-test/),
#     so a page that happens to print that text cannot match;
#   - the marker must appear inside the product's own form action, unescaped,
#     so a generic reflector (which does not print that form) is not reported;
#   - also tries the web root and /pfile2 style paths (the NVT only uses /pfile
#     and the CGI dirs).
uid: 5b5c9a2e-7e2a-4d0c-9a54-3f6c1a8e2d17
name: "pFile kommentar.php reflected cross-site scripting"
description: |
  pFile, a PHP file-download manager, prints the filecat parameter of
  kommentar.php back into the action attribute of its comment form without
  encoding it, so a crafted link closes the attribute and injects a script
  tag that runs in the visitor's browser. Version 1.02 is affected.

  The check requests kommentar.php on the usual install paths (/pfile, the web
  root, /pfile2) with filecat set to a quote, a closing bracket and a script
  tag holding a random marker. It reports the flaw when the reply is a 200 page
  whose form action contains that payload unescaped.
category: xss
cves: [CVE-2012-1211]
severity: medium
confidence_base: 0.30
tags: [pfile, powie, xss, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-1211"
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-1210"
  - "http://www.securityfocus.com/bid/51982"

steps:
  - id: init-hit
    action: set_var
    var_name: hit
    var_value: ""

  - id: init-page
    action: set_var
    var_name: page
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["/pfile", "", "/pfile2"]

  - id: marker
    action: script
    code: "\"nx\" + rand_hex(8)"
    store_as: mark

  - id: fetch
    action: http_request
    method: GET
    path: "{{dir}}/kommentar.php?filecat=%22%3E%3Cscript%3E{{mark}}%3C/script%3E&fileid=0"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 8
    condition: 'hit == ""'
    store_as: page

  - id: check
    action: script
    condition: 'hit == ""'
    code: |
      let b = if type_of(page.body) == "string" { page.body } else { "" };
      if page.status == 200
         && ereg("(?i)action=.kommentar\\.php\\?fileid=[^&]*&filecat=\"><script>" + mark + "</script>", b) {
        dir + "/kommentar.php echoes the filecat script tag unescaped"
      } else { "" }
    store_as: hit

  - id: report
    action: match
    source: hit
    pattern: "echoes the filecat"
    on_match:
      finding:
        title: "pFile kommentar.php reflected cross-site scripting"
        description: "kommentar.php of pFile writes the filecat parameter into its comment form's action attribute without encoding it. A quote followed by a script tag sent in a link comes back as markup, so script runs in the browser of anyone who follows the link."
        remediation: "Encode filecat (htmlspecialchars with ENT_QUOTES) before printing it, or replace this unmaintained script."
        confidence_delta: 0.45
        qod: 75
        evidence: "{{hit}}"
      stop: true

View these feeds on GitHub