OpenPLC_v3 glue_generator Path Traversal — CVE-2026-31156
by unicorn-hyh · 2026-07-05
- Severity
- High
- CVE
- CVE-2026-31156
- Category
- hardware
- Affected product
- OpenPLC_v3 — utils/glue_generator_src/glue_generator.cpp build/code-generation utility
- Affected versions
- OpenPLC_v3 master (as of research date); glue_generator.cpp code-generation tool
- Disclosed
- 2026-07-05
- Patch status
- unpatched
Tags
Archive entry
intelseclab/poc-archiveMetadata
| Field | Value |
|---|---|
| Date Added | 2026-07-05 |
| Last Updated | 2026-05 |
| Author / Researcher | unicorn-hyh |
| CVE / Advisory | CVE-2026-31156 |
| Category | hardware |
| Severity | High |
| CVSS Score | Not specified in source |
| Status | PoC |
| Tags | openplc, ics, path-traversal, arbitrary-file-write, glue-generator, cpp, plc, industrial-control |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | OpenPLC_v3 — utils/glue_generator_src/glue_generator.cpp build/code-generation utility |
| Versions Affected | OpenPLC_v3 master (as of research date); glue_generator.cpp code-generation tool |
| Language / Platform | C++ (compiled utility) |
| Authentication Required | Local-only (ability to invoke the glue-generator tool with attacker-chosen input/output file paths) |
| Network Access Required | No |
Summary
glue_generator.cpp is a code-generation utility used in the OpenPLC_v3 build pipeline to parse a variable-definition header file and emit corresponding glue-code source. The tool accepts input and output file paths as command-line arguments without validating or restricting them to the expected project directory. An attacker able to influence the input file path argument (e.g. in an automated/CI build context, or a shared engineering workstation) can direct the tool to read and process a file outside the intended project tree, such as /etc/passwd, demonstrating unrestricted path traversal in a tool that is part of the PLC programming/build toolchain.
Vulnerability Details
Root Cause
glue_generator takes the input file path as a raw command-line argument and opens it directly with no path canonicalization or containment check against an expected project/working directory, allowing arbitrary absolute or relative (../) paths to be supplied.
Attack Vector
- Attacker gains the ability to control or influence the arguments passed to
glue_generator(e.g. via a compromised build script, CI job, or shared engineering environment for OpenPLC projects). - Attacker supplies a traversal path such as
../../../../../../../../../../etc/passwdas the input file argument instead of a legitimate variable-definition header. glue_generatorreads and processes the targeted file as if it were a normal input header, with its contents reflected into the generated glue-code output file.
Impact
Arbitrary file read (and, depending on how generated output is subsequently compiled/used, potential downstream code injection) within the OpenPLC build toolchain — relevant in industrial control system (ICS) engineering environments where build tooling may run with elevated trust.
Environment / Lab Setup
Target: OpenPLC_v3 (github.com/thiagoralves/OpenPLC_v3) glue_generator.cpp build utility
Attacker: g++ toolchain to compile glue_generator, shell access to invoke it with crafted paths
Proof of Concept
PoC Script
See
poc.txtin this folder.
| |
poc.txt documents the exact compile-and-run commands against the real upstream glue_generator.cpp source, demonstrating that supplying a traversal path as the input argument causes the tool to read and process a file well outside its intended project directory.
Detection & Indicators of Compromise
Signs of compromise:
- Generated glue-code output containing content that does not match any legitimate project variable-definition file
- Build tooling invocations referencing system paths (e.g.
/etc/) as input arguments - Unexpected file-read access by build utilities outside the expected project directory
Remediation
| Action | Detail |
|---|---|
| Primary fix | No vendor patch confirmed as of 2026-07-05 — monitor for advisory; validate/canonicalize input file paths against the expected project directory before processing |
| Interim mitigation | Run build tooling such as glue_generator with least-privilege file-system access and restrict who/what can supply its command-line arguments in CI/build pipelines |
References
Notes
Mirrored from https://github.com/unicorn-hyh/CVE-2026-31156 on 2026-07-05.