CODESYS — 1 vulnerability check
noctis ships 1 vulnerability check for CODESYS, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
CODESYS Runtime System unauthenticated PLC shell access
| CVE | CVE-2012-6068, CVE-2012-6069 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | exposure — Exposure |
| Services | codesys, softplc, wago-io-system, scol |
| Detection | tcp_dialogue, script, match · highest QoD 75 |
| Feed | tests/vulnerabilities/codesys/codesys-runtime-unauthenticated-shell.yaml |
Sends the CODESYS V2.3 PLC-browser shell help command `?` to the runtime's gateway TCP listener, without logging in, in little-endian and then big-endian framing (one connection each). A runtime affected by CVE-2012-6068 executes the command and answers with a shell reply frame listing its implemented commands ("show implemented commands"), which proves that any shell command can be run on the PLC without authentication. The help command is read-only; nothing is changed on the device. The related file-transfer path traversal (CVE-2012-6069), fixed by the same runtime update, is not exercised.
How noctis detects it
- TCP dialogue: one binary protocol frame
- Parses / computes the next value with a Rhai script
- TCP dialogue: one binary protocol frame
- Parses / computes the next value with a Rhai script
- Checks
shell.okfor^true$→ finding QoD 75: CODESYS Runtime System PLC shell accessible without authentication
References:
- https://nvd.nist.gov/vuln/detail/CVE-2012-6068
- https://nvd.nist.gov/vuln/detail/CVE-2012-6069
- https://www.cisa.gov/news-events/ics-advisories/icsa-13-011-01
- https://github.com/digitalbond/Basecamp/blob/master/codesys-shell.py
- http://www.securityfocus.com/bid/56300
Feed source — tests/vulnerabilities/codesys/codesys-runtime-unauthenticated-shell.yaml
# CODESYS V2.3 Runtime System — unauthenticated PLC shell (CVE-2012-6068),
# tracked together with the file-transfer traversal CVE-2012-6069 (same advisory
# ICSA-13-011-01, same runtime fix).
#
# The Runtime Toolkit in CODESYS Runtime System 2.3.x / 2.4.x accepts commands
# for its PLC-browser shell on the gateway TCP listener (2455, also 1200) without
# any login. Frame (Digital Bond Basecamp codesys-shell.py):
#
# cc cc 01 00 <L:2> 00*10 01 00 00 00 23 <L:2> 00 | 92 00 00 00 00 '?' 00
# L = 7 = length of the 92.. block, in the PLC CPU's byte order
#
# `?` is the shell's built-in help: a read-only command that lists the
# implemented commands. A runtime that executes it without a login replies with
# a cc cc frame whose text contains "show implemented commands" (the help line
# of `?` itself). Nothing is changed on the PLC.
#
# Ported from OpenVAS NVT 2012/gb_CoDeSys_56300.nasl (GPL-2.0-only,
# OID 1.3.6.1.4.1.25623.1.0.103599). Same frames and the same match (reply
# starts with cc cc and contains "show implemented commands").
#
# Better than the NASL:
# - the NASL sends the big-endian frame on the SAME socket after the
# little-endian one got no reply; a runtime that drops the connection on a
# frame it cannot parse then never sees the second frame. Here each byte
# order goes out on its own connection, and the big-endian frame is also tried
# when the first reply was not a valid shell reply.
# - the marker must sit at a byte boundary of the reply (matched on hex), and
# the finding quotes the returned command list.
# - the finding names only CVE-2012-6068, which is what the probe proves; the
# file-transfer traversal (CVE-2012-6069) is not exercised (it would need a
# file read/write outside the PLC's directory), so it stays on the feed for
# tracking/exclusion only.
#
# Limits (shared with the NASL): no `bb bb 01 00 00 00 01` connect frame is
# sent before the command (codesys-shell.py sends one; a runtime that insists
# on it is missed). tcp_dialogue waits up to `timeout_secs` for the reply's
# first byte, then stops after 500 ms without data.
uid: b110c79a-7313-45e2-8e31-9c356f39a591
name: "CODESYS Runtime System unauthenticated PLC shell access"
description: |
Sends the CODESYS V2.3 PLC-browser shell help command `?` to the runtime's
gateway TCP listener, without logging in, in little-endian and then
big-endian framing (one connection each). A runtime affected by
CVE-2012-6068 executes the command and answers with a shell reply frame
listing its implemented commands ("show implemented commands"), which proves
that any shell command can be run on the PLC without authentication. The
help command is read-only; nothing is changed on the device. The related
file-transfer path traversal (CVE-2012-6069), fixed by the same runtime
update, is not exercised.
category: exposure
cves: [CVE-2012-6068, CVE-2012-6069]
cvss: 9.8
severity: critical
confidence_base: 0.30
tags: [codesys, 3s, plc, ics, scada, runtime, unauthenticated, shell]
services: [codesys, softplc, wago-io-system, scol]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2012-6068"
- "https://nvd.nist.gov/vuln/detail/CVE-2012-6069"
- "https://www.cisa.gov/news-events/ics-advisories/icsa-13-011-01"
- "https://github.com/digitalbond/Basecamp/blob/master/codesys-shell.py"
- "http://www.securityfocus.com/bid/56300"
steps:
# `?` with little-endian length fields (x86 / ARM runtimes).
- id: shell-help-le
action: tcp_dialogue
port: "{{port}}"
read_banner: false
timeout_secs: 10
send_hex: "cccc0100070000000000000000000000010000002307000092000000003f00"
store_as: le_reply
# Parse a reply into `shell`:
# ok bool — a cc cc shell frame carrying the `?` help text
# order str — byte order the runtime answered to
# commands str — the returned help text (one line per command, " | " joined)
- id: parse-le
action: script
condition: "le_reply.connected == true"
store_as: shell
code: |
let hex = if type_of(le_reply.response_hex) == "string" { tolower(le_reply.response_hex) } else { "" };
let idx = stridx(hex, hexstr("show implemented commands"));
let ok = strlen(hex) > 62 && substr(hex, 0, 3) == "cccc" && idx >= 0 && idx % 2 == 0;
let text = if ok { base64_decode(base64_encode_hex(substr(hex, 62))) } else { "" };
text = str_replace(str_replace(chomp(text), "\x00", ""), "\n", " | ");
#{ ok: ok, order: "little-endian", commands: substr(text, 0, 399) }
# Same command with big-endian length fields (PowerPC runtimes), on a fresh
# connection, when the little-endian frame got no valid shell reply.
- id: shell-help-be
action: tcp_dialogue
condition: "shell.ok != true"
port: "{{port}}"
read_banner: false
timeout_secs: 10
send_hex: "cccc0100000700000000000000000000010000002300070092000000003f00"
store_as: be_reply
- id: parse-be
action: script
condition: "be_reply.connected == true"
store_as: shell
code: |
let hex = if type_of(be_reply.response_hex) == "string" { tolower(be_reply.response_hex) } else { "" };
let idx = stridx(hex, hexstr("show implemented commands"));
let ok = strlen(hex) > 62 && substr(hex, 0, 3) == "cccc" && idx >= 0 && idx % 2 == 0;
let text = if ok { base64_decode(base64_encode_hex(substr(hex, 62))) } else { "" };
text = str_replace(str_replace(chomp(text), "\x00", ""), "\n", " | ");
#{ ok: ok, order: "big-endian", commands: substr(text, 0, 399) }
- id: check-shell
action: match
condition: "shell.ok == true"
source: shell.ok
pattern: "^true$"
on_match:
finding:
title: "CODESYS Runtime System PLC shell accessible without authentication"
description: "The CODESYS runtime executed the PLC-browser shell command `?` sent without any login and returned its list of implemented commands. Any shell command (memory reads, task and project information, file transfer) can be run on the PLC by an unauthenticated network attacker (CVE-2012-6068)."
remediation: "Update the CODESYS V2.3 Runtime System to a version that requires a login for the PLC shell and file transfer (per the vendor's 2012 advisory / ICSA-13-011-01), and restrict access to the runtime's TCP ports (1200, 2455) to engineering workstations."
cves: [CVE-2012-6068]
confidence_delta: 0.55
qod: 75
evidence: "Shell command `?` ({{shell.order}} framing) answered without login: {{shell.commands}}"