PoC Archive PoC Archive
CVE-2026-127148 category: network CVSS 9.8 (CRITICAL)
Patched

CODESYS Control CmpChannelMgr Out-of-Order Block Out-of-Bounds Write (CVE-2026-127148)

Published: 2026-12-03 • Researcher: Nicolas Krassas (dinosn); CODESYS Security Advisory 2026-17 / CERT@VDE VDE-2026-169

Target software CODESYS Control runtime system — CmpChannelMgr / CmpChannelMgrEmbedded
Affected versions Windows product family before 3.5.22.50; Linux product family before 4.24.0.0
Status Weaponized
Severity Critical · CVSS 9.8
CVSS 9.8/10
Severity
Critical
CVE
CVE-2026-127148
Category
network
Affected product
CODESYS Control runtime system — CmpChannelMgr / CmpChannelMgrEmbedded
Affected versions
Windows product family before 3.5.22.50; Linux product family before 4.24.0.0
Disclosed
2026-12-03
Patch status
Patched
On this page

Metadata

FieldValue
Date Added2026-12-03
Last Updated2026-12-03
Author / ResearcherNicolas Krassas (dinosn); CODESYS Security Advisory 2026-17 / CERT@VDE VDE-2026-169
CVE / AdvisoryCVE-2026-127148
Categorynetwork
SeverityCritical
CVSS Score9.8 (CVSSv3.1)
StatusWeaponized
Tagscodesys, plc, ics, ot, cmpchannelmgr, out-of-bounds-write, unauthenticated, rce, network, cwe-787
RelatedSeparate in-order full-size-block overflow, no CVE assigned

Affected Target

FieldValue
Software / SystemCODESYS Control runtime system — CmpChannelMgr / CmpChannelMgrEmbedded
Versions AffectedWindows product family before 3.5.22.50; Linux product family before 4.24.0.0
Tested BuildsCODESYS Control Win 64 3.5.22.40; CODESYS Virtual Control for Linux SL 4.23.0.0, runtime 3.5.22.40
Fixed VersionsWindows 3.5.22.50; Linux 4.24.0.0
Language / PlatformCODESYS online protocol over TCP 11740; Python 3.8+ PoC
Authentication RequiredNo
Network Access RequiredYes

Summary

CVE-2026-127148 is an unauthenticated out-of-bounds write in CODESYS Control’s CmpChannelMgr online service. The runtime accepts a maximum-size out-of-order L4 data block without verifying that the block fits in the channel communication buffer. The copy extends beyond the declared buffer into reserved channel memory, poisoning the channel state; the repository’s bounded detector distinguishes that vulnerable state from a fixed runtime without crashing it. The same repository also contains build-specific network-only RCE chains for Linux and Windows that derive addresses, install a fake object/vtable and invoke system or WinExec. The CVE is fixed in CODESYS Control Win 64 3.5.22.50 and the Linux 4.24.0.0 family.

Vulnerability Details

Root Cause

The CmpChannelMgr and CmpChannelMgrEmbedded components perform improper length checking when handling online service packets. An out-of-order block whose length equals the channel’s maximum block size is copied without checking whether it fits the declared communication buffer (CWE-787). In the tested build the copy extends 392 bytes past a 95,752-byte communication buffer but remains inside reserved channel memory, which is why the bounded detector can observe the poisoned state without crashing the service.

Attack Vector

An unauthenticated attacker connects to the CODESYS runtime on TCP 11740 and opens a channel with a 95,752-byte communication buffer. The PoC sends a valid first block and a full-size out-of-order block 202, completes blocks 2 through 201, and sends the proper final block. A vulnerable runtime accepts the oversized out-of-order block and enters the poisoned state; a fixed runtime rejects it and accepts the final block normally.

Impact

Out-of-bounds write in the runtime process, enabling memory corruption and, with the build-specific chains, native code execution as the runtime user (root on the tested Linux image, SYSTEM on the tested Windows service). A malformed sequence can also destabilize or crash the runtime. The network-only Linux and Windows chains run id / whoami marker commands and leave the service running.

Environment / Lab Setup

Output
OS:          Linux or Windows CODESYS runtime
Target:      CODESYS Control runtime with online protocol on TCP 11740
Attacker:    Python 3.8+ on a reachable network path
Tools:       python3, socket/struct/zlib; build-specific RCE chains in subdirectories

Setup Steps

Shell script
1
python3 poc.py <runtime-ip> --port 11740

For the network-only RCE chains, the target must be the exact tested build and the lab endpoint must be forwarded to runtime port 11740. See:

Both chains require build-specific offsets; they are not generic one-click exploits.

Proof of Concept

Step-by-Step Reproduction

  1. Confirm the runtime is reachable on TCP 11740 and has free channel slots.
  2. Run the bounded detector; exit code 0 indicates the vulnerable poisoned state, 1 indicates the fixed runtime, and 2 means undetermined (for example, all four slots occupied).
  3. For the RCE proof, use the Linux or Windows chain matching the tested runtime and follow its README. The Linux chain uses a response disclosure, absolute reads, a preserved special-protocol registry, a fake object/vtable and a packet-dispatched JOP path to run id>/tmp/n. The Windows chain uses a response disclosure, KERNEL32 resolution and a fake object/vtable to run whoami>C:\c.
  4. Confirm the marker and that the CODESYS service remains running.

Exploit Code

See poc.py, poc-inorder.py and the linux-network-rce/ and windows-network-rce/ directories.

The separate in-order full-size-block overflow is a distinct bug. It remains present in every tested build, including Control Win 64 3.5.22.50, and is not evidence that the CVE-2026-127148 fix failed.

Expected Output

Output
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
exit 0

NETWORK_HEALTH=OPEN_OK
TRIGGER_DISPATCHED mode=command
IDENTITY=uid=0(root) gid=0(root) groups=0(root)
PROCESS=RUNNING

TRIGGER_DISPATCHED
MARK=nt authority\system
SERVICE=Running

Detection & Indicators of Compromise

  • CODESYS online protocol traffic on TCP 11740 with maximum-size out-of-order L4 blocks or block 202 before blocks 2–201.
  • Channel state corruption, unexpected runtime restarts, crashes, or unavailable channel slots.
  • Unexpected child processes from the CODESYS runtime: /bin/sh, id, hostname, cmd.exe, whoami.
  • New marker files such as /tmp/n or C:\c on runtime hosts.
  • CODESYS runtime versions below 3.5.22.50 (Windows) or 4.24.0.0 (Linux).

SIEM / IDS rule (example):

Output
1
2
alert tcp any any -> any 11740 (msg:"CODESYS CVE-2026-127148 oversized out-of-order block"; \
  flow:to_server; content:"|CD 55|"; depth:2; sid:9003001;)

Remediation

ActionDetail
PatchUpgrade CODESYS Control Win 64 to 3.5.22.50 or later; upgrade the Linux product family to 4.24.0.0 or later.
WorkaroundRestrict TCP 11740 to trusted engineering networks; do not expose CODESYS runtimes directly to untrusted networks.
Config HardeningMonitor channel exhaustion and runtime crashes; limit PLC/engineering protocol access at the network boundary.

References

Notes

Reviewed 2026-12-03 from the linked repository. The detectors are bounded and non-crashing; the Linux and Windows network-only chains are build-specific and were verified upstream against Virtual Control Linux SL 4.23.0.0 and Control Win 64 3.5.22.40. They run only marker commands (id, whoami) and do not contain persistence, credential theft, C2 or worm behavior.

No CVE is assigned to the separate in-order overflow, which is included only as a related detector. The gdb-assisted sibling harness (poc-rce.py, rce.sh, build_rce_payload.py), geometry measurement scripts, __pycache__ binaries, pcaps and captured evidence were not copied; the entry keeps the CVE detector, both network RCE chains, the oracles and their READMEs/provenance/verification notes. The repository has no license file; the code is archived with attribution for authorized research only. No exploit code was executed during archival; only Python syntax checks were used.

codesys_info.py
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
#!/usr/bin/env python3
"""codesys_info.py - read-only interactive CODESYS V3 online-protocol info client.

Talks the CmpBlkDrvTcp online protocol (runtime TCP 11740) to pull device
information: it opens an unauthenticated channel and issues standard *read*
service requests (e.g. CmpDevice identify), then dumps/parses the replies.

READ-ONLY BY DESIGN. It never sends an out-of-order block and never sends a
block larger than the granted communication buffer, so it cannot trigger the
CmpChannelMgr overflow (CVE-2026-127148) or the in-order overflow. It is an
inventory/diagnostic client, not an exploit.

Usage:
  codesys_info.py HOST [--port 11740]            # interactive REPL
  codesys_info.py HOST --identify                # one-shot identify
  codesys_info.py HOST --svc GROUP SERVICE [HEXBODY]
  codesys_info.py HOST --probe                   # try identify framing variants

REPL commands:
  open                 (re)open a channel, show handle/sizes
  id | identify        send CmpDevice identify (group 1, service 1)
  svc G S [HEXBODY]    send an arbitrary read service request
  probe                try a few benign identify framings, report which replies
  listen [SECS]        passively dump incoming frames
  quit | exit
"""
import argparse
import socket
import struct
import sys
import time
import zlib

BD_MAGIC = 0xE8170100
OPEN = 0xC3
PKT_BLK, PKT_ACK, PKT_STATUS = 0x01, 0x02, 0x03
META_REPLY = 0x83
L7_MAGIC = 0xCD55
IDENT_BODY_HEX = "01 0c 00 10 00 00 00 00 00 00 00 00 00 00"  # tag(0x01, 12 zero-ish bytes)
MAX_DATAGRAM = 512


def leb128(value):
    out = bytearray()
    while True:
        b = value & 0x7F
        value >>= 7
        if value:
            out.append(b | 0x80)
        else:
            out.append(b)
            return bytes(out)


def tag(tag_id, value):
    return leb128(tag_id) + leb128(len(value)) + value


def services(group, service, session, body):
    return struct.pack("<HHHHII", L7_MAGIC, 16, group, service, session, len(body)) + b"\x00" * 4 + body


def meta(req, tail):
    p = bytes([req, 0x00]) + struct.pack("<HI", 0x0102, 0) + tail
    return p[:4] + struct.pack("<I", zlib.crc32(p) & 0xFFFFFFFF) + p[8:]


def ascii_strings(buf, minlen=3):
    import re
    return [m.decode("latin1") for m in re.findall(rb"[\x20-\x7e]{%d,}" % minlen, buf)]


class Codesys:
    def __init__(self, host, port, timeout=4.0):
        self.host, self.port, self.timeout = host, port, timeout
        self.sock = None
        self.tok16 = self.chan32 = self.granted = self.addr_size = None

    def connect(self):
        self.sock = socket.create_connection((self.host, self.port), self.timeout)
        self.sock.settimeout(self.timeout)
        self.lip, self.lport = self.sock.getsockname()[:2]

    def close(self):
        try:
            if self.sock:
                self.sock.close()
        except OSError:
            pass

    def _send(self, payload):
        dg = (bytes([0xC5, (14 << 3) | 3, 0x40, 0x40, 0, 0x33])
              + struct.pack(">H", self.port) + socket.inet_aton(self.host)
              + struct.pack(">H", self.lport) + socket.inet_aton(self.lip) + b"\x00\x00" + payload)
        if len(dg) > MAX_DATAGRAM:
            raise ValueError("datagram %d exceeds %d (read-only cap)" % (len(dg), MAX_DATAGRAM))
        self.sock.sendall(struct.pack("<II", BD_MAGIC, len(dg) + 8) + dg)

    def _read_all(self, dur):
        buf = b""
        dl = time.time() + dur
        while time.time() < dl:
            try:
                self.sock.settimeout(max(0.1, dl - time.time()))
                c = self.sock.recv(8192)
            except socket.timeout:
                break
            except (ConnectionError, OSError):
                break
            if not c:
                break
            buf += c
        return buf

    @staticmethod
    def _frames(buf):
        out, i = [], 0
        while i + 8 <= len(buf):
            m, l = struct.unpack_from("<II", buf, i)
            if m != BD_MAGIC or l < 8:
                break
            out.append(buf[i + 8:i + l])
            i += l
        return out

    @staticmethod
    def _l4(dg):
        """Return the L4 payload: scan for a known opcode after the address header."""
        for i in range(18, min(len(dg), 30)):
            if dg[i] in (META_REPLY, PKT_BLK, PKT_ACK, PKT_STATUS):
                return dg[i:]
        return dg[20:] if len(dg) > 20 else b""

    def open_channel(self, requested=0x001F4000):
        self._send(meta(OPEN, struct.pack("<IIBBH", 0x22125B11, requested, 4, 0, 0)))
        for dg in self._frames(self._read_all(2.0)):
            pl = self._l4(dg)
            if pl and pl[0] == META_REPLY and len(pl) >= 22:
                self.chan32 = struct.unpack_from("<I", pl, 4)[0]
                result = struct.unpack_from("<H", pl, 12)[0]
                self.tok16 = struct.unpack_from("<H", pl, 14)[0]
                self.granted = struct.unpack_from("<I", pl, 16)[0]
                self.addr_size = pl[21]
                return result
        return None

    # Data-block header layouts seen in the wild:
    #   "A" = 24-byte header WITH a 32-bit channel handle (protocol 0x0102, PoC reference builds)
    #   "B" = 20-byte header WITHOUT the channel handle (older revisions whose OPEN reply
    #         carries no chan32 field, e.g. Eaton XC / CODESYS 3.5 SP16 runtimes)
    block_layout = None  # auto-detected on first service() call

    def _first_block(self, blk, data, msglen, crc, layout, flag=0x81):
        hdr = bytes([PKT_BLK, flag]) + struct.pack("<H", self.tok16)
        if layout == "A":
            hdr += struct.pack("<I", self.chan32 or 0)
        hdr += struct.pack("<III", blk, 0, msglen) + struct.pack("<I", crc)
        return hdr + data

    def service(self, group, service_id, body=b"", wait=3.0, layout=None):
        """Send ONE read service request as a single block (bounded) and collect replies.

        Auto-detects the data-block header layout (A/B) on first use and caches it."""
        if self.tok16 is None:
            raise RuntimeError("open a channel first")
        msg = services(group, service_id, 0, body)
        if self.granted and len(msg) > self.granted - 64:
            raise RuntimeError("message too large for read-only single-block send")
        crc = zlib.crc32(msg) & 0xFFFFFFFF
        order = [layout] if layout else ([self.block_layout] if self.block_layout else ["B", "A"])
        last = None
        for lay in order:
            self._send(self._first_block(1, msg, len(msg), crc, lay))
            r = self._parse_reply(self._read_all(wait))
            last = r
            if r["l7"] or r["data_frames"]:
                if self.block_layout is None:
                    self.block_layout = lay
                r["layout"] = lay
                return r
            if self.open_channel() != 0:  # re-open before trying the next layout
                break
        return last

    def _parse_reply(self, buf):
        result = {"status_frames": 0, "ack_frames": 0, "data_frames": 0, "l7": [], "raw": []}
        for dg in self._frames(buf):
            result["raw"].append(dg)
            pl = self._l4(dg)
            op = pl[0] if pl else None
            if op == PKT_STATUS:
                result["status_frames"] += 1
            elif op == PKT_ACK:
                result["ack_frames"] += 1
            elif op == PKT_BLK:
                result["data_frames"] += 1
            k = dg.find(struct.pack("<H", L7_MAGIC))
            if k >= 0:
                result["l7"].append(dg[k:])
        return result


def parse_device_info(l7_list):
    """Extract device name / vendor / project / version from a CmpDevice identify reply."""
    import re
    raw = b"".join(l7_list)
    info = {"utf16": [], "ascii": [], "versions": []}
    seen = set()
    for mo in re.finditer(rb"(?:[\x20-\x7e]\x00){3,}", raw):
        txt = mo.group().decode("utf-16-le").strip()
        if txt and txt not in seen:
            seen.add(txt)
            info["utf16"].append(txt)
    for m in re.findall(rb"[\x20-\x7e]{5,}", raw):
        t = m.decode("latin1")
        if t not in info["ascii"]:
            info["ascii"].append(t)
    vers = set()
    for i in range(0, len(raw) - 3):
        d, c, b, a = raw[i], raw[i + 1], raw[i + 2], raw[i + 3]
        if a == 3 and b == 5 and c < 64 and 0 < d < 128:  # 3.5.x.x version quad
            vers.add("%d.%d.%d.%d" % (a, b, c, d))
    info["versions"] = sorted(vers)
    return info


def show_reply(r, decode=False):
    print("  frames: data=%d ack=%d status=%d%s"
          % (r["data_frames"], r["ack_frames"], r["status_frames"],
             "  layout=%s" % r.get("layout", "") if r.get("layout") else ""))
    if r["l7"]:
        if decode:
            info = parse_device_info(r["l7"])
            print("  --- device info ---")
            if info["utf16"]:
                labels = ["node/device", "vendor", "project/app"]
                for i, s in enumerate(info["utf16"]):
                    print("    %-12s: %s" % (labels[i] if i < len(labels) else "string", s))
            if info["ascii"]:
                print("    %-12s: %s" % ("ids", ", ".join(info["ascii"])))
            if info["versions"]:
                print("    %-12s: %s" % ("version", ", ".join(info["versions"])))
        else:
            for l7 in r["l7"]:
                print("  L7 (%d B): %s" % (len(l7), l7[:160].hex()))
                ss = ascii_strings(l7)
                if ss:
                    print("    strings:", ss)
    elif r["data_frames"] == 0:
        print("  (no L7 data reply - only channel keepalive/status)")


def do_identify(cli, **kw):
    return cli.service(1, 1, bytes.fromhex(IDENT_BODY_HEX.replace(" ", "")), **kw)


def probe(cli):
    """Try both BENIGN identify header layouts and report which this build speaks."""
    for lay in ("B", "A"):
        if cli.open_channel() != 0:
            print("[layout %s] re-open failed" % lay)
            continue
        r = do_identify(cli, layout=lay)
        hit = r["data_frames"] > 0 or bool(r["l7"])
        print("[layout %s] -> %s" % (lay, "REPLY" if hit else "keepalive only"))
        if hit:
            cli.block_layout = lay
            show_reply(r, decode=True)
            return True
        time.sleep(0.3)
    print("neither benign identify layout produced a data reply")
    return False


def repl(cli):
    print("codesys_info interactive (read-only). type 'help'.")
    r = cli.open_channel()
    print("open: result=%s tok16=%s chan32=%s granted=%s addr_size=%s"
          % (r, hex(cli.tok16) if cli.tok16 else None,
             hex(cli.chan32) if cli.chan32 else None, cli.granted, cli.addr_size))
    while True:
        try:
            line = input("codesys> ").strip()
        except (EOFError, KeyboardInterrupt):
            print()
            break
        if not line:
            continue
        parts = line.split()
        cmd = parts[0].lower()
        try:
            if cmd in ("quit", "exit"):
                break
            elif cmd == "help":
                print(__doc__)
            elif cmd == "open":
                r = cli.open_channel()
                print("open: result=%s tok16=%s chan32=%s granted=%s addr_size=%s"
                      % (r, hex(cli.tok16), hex(cli.chan32), cli.granted, cli.addr_size))
            elif cmd in ("id", "identify"):
                show_reply(do_identify(cli), decode=True)
            elif cmd == "svc":
                g, s = int(parts[1], 0), int(parts[2], 0)
                body = bytes.fromhex("".join(parts[3:])) if len(parts) > 3 else b""
                show_reply(cli.service(g, s, body))
            elif cmd == "probe":
                probe(cli)
            elif cmd == "listen":
                secs = float(parts[1]) if len(parts) > 1 else 2.0
                show_reply(cli._parse_reply(cli._read_all(secs)))
            else:
                print("unknown command; 'help' for list")
        except Exception as e:
            print("error:", repr(e))


def main():
    ap = argparse.ArgumentParser(description="read-only CODESYS V3 info client")
    ap.add_argument("host")
    ap.add_argument("--port", type=int, default=11740)
    ap.add_argument("--timeout", type=float, default=4.0)
    ap.add_argument("--identify", action="store_true")
    ap.add_argument("--probe", action="store_true")
    ap.add_argument("--svc", nargs="+", metavar="G S [HEX]")
    a = ap.parse_args()
    cli = Codesys(a.host, a.port, a.timeout)
    cli.connect()
    try:
        if a.identify:
            r = cli.open_channel()
            print("open result:", r, "tok16:", hex(cli.tok16) if cli.tok16 else None,
                  "chan32:", hex(cli.chan32) if cli.chan32 else None,
                  "granted:", cli.granted, "addr_size:", cli.addr_size)
            show_reply(do_identify(cli), decode=True)
        elif a.probe:
            cli.open_channel()
            probe(cli)
        elif a.svc:
            cli.open_channel()
            g, s = int(a.svc[0], 0), int(a.svc[1], 0)
            body = bytes.fromhex("".join(a.svc[2:])) if len(a.svc) > 2 else b""
            show_reply(cli.service(g, s, body))
        else:
            repl(cli)
    finally:
        cli.close()


if __name__ == "__main__":
    main()