/

CVE-2026-71268

Severity:

CRITICAL RISK

(9.9)

Path Traversal (CWE-22) in OpenPLC Runtime v3 Webserver

CVE-2026-71268

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write and Potential Remote Code Execution

Severity:

CRITICAL RISK

(9.9)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

OpenPLC Runtime v3 contains a path traversal flaw in the Structured Text compilation workflow. An attacker who can upload a crafted .st program may cause attacker-controlled content to be written outside the intended ./core directory, potentially enabling remote code execution through writable operating-system-managed files.

Affected context

The vulnerability occurs in the OpenPLC webserver's compile_program() function when uploaded Structured Text files contain special file-writing directives. The referenced path is joined with ./core without confirming that the resulting location remains within that directory. Exploitability depends on access to the program-upload workflow and on the runtime account having permission to write to a security-sensitive filesystem location. Default credentials may reduce the barrier where they remain enabled.

Exploit preconditions

  • Attack surface: OpenPLC webserver program-upload and compilation workflow
  • Required access: Ability to authenticate to, or otherwise reach, the upload functionality; shipped default credentials may make access easier if unchanged
  • Trigger point: Processing of a file-writing directive during compile_program()
  • Why exploitation is possible: The supplied path is used in a filesystem write without containment validation, allowing traversal outside the intended ./core directory
  • Additional condition: The OpenPLC process must have write permission for the selected target path or for a file that influences later execution

Why this happens

The underlying bug is failure to enforce a trusted path boundary before writing attacker-influenced content. compile_program() combines a user-controlled path with the intended base directory but does not canonicalize and verify that the resulting path remains beneath that directory. This is a path traversal weakness mapped to CWE-22, and it can become an arbitrary file-write or code-execution issue when the process has access to executable, scheduled-task, authentication, or other security-sensitive files. Although a path-validation helper exists elsewhere in the codebase, the vulnerable write path does not invoke it.

Potential impact

  • An attacker may write arbitrary content to files outside the intended application directory.
  • The OpenPLC process may be compromised through files that are later executed or interpreted.
  • System integrity, scheduled tasks, or service configuration may be altered.
  • Credentials, access controls, or authorized access mechanisms could be affected.
  • The host or connected industrial environment could be exposed to further compromise.

General mitigation guidance

Mitigation generally focuses on enforcing a strict destination boundary for every file-writing operation.

Common defensive patterns include:

  • Resolve and canonicalize the candidate path before writing, then require it to remain beneath a fixed, trusted base directory.
  • Reuse a centralized path-validation function consistently at the actual filesystem sink.
  • Prefer application-managed filenames or opaque identifiers over user-supplied paths.
  • Reject absolute paths, traversal components, symbolic-link escapes, and unexpected path formats.
  • Restrict the runtime account to the minimum filesystem permissions required for operation.
  • Disable or rotate shipped default credentials and require unique, strong authentication secrets.
  • Store uploaded files in an isolated, non-executable location and apply restrictive filesystem and container policies.

How teams detect issues like this

Detection can combine source analysis, runtime monitoring, and deployment policy checks:

  • Use static analysis to identify filesystem writes that combine a trusted directory with request-derived or uploaded path components.
  • Review code for canonicalization, containment checks, symbolic-link handling, and validation immediately before the write sink.
  • Monitor OpenPLC processes for writes outside approved application directories and for unexpected changes to system-managed files.
  • Add CI policy checks that reject default credentials and unvalidated path construction in upload handlers.
  • Test upload and compilation workflows with traversal-oriented path variations in controlled security testing.
  • Neutral automated code-review tools may help identify inconsistent use of existing validation helpers.

Sources

SourceLink
github.comgithub.com/thiagoralves/OpenPLC_v3
github.comgithub.com/thiagoralves/OpenPLC_v3/blob/master/webserver/openplc.py

Frequently asked

questions

Potentially. An attacker generally needs access to the OpenPLC webserver's program-upload workflow, after which the vulnerable compilation process performs the file write. The practical scope depends on network exposure, authentication, and filesystem permissions.

Usually, access controls on the upload endpoint are relevant. However, unchanged default credentials can substantially lower the access barrier, so deployments should not rely on those credentials for protection.

Treat uploaded paths as untrusted, use application-controlled filenames where possible, and enforce canonical path containment immediately before every write. The OpenPLC process should also run with minimal filesystem privileges.

Apply centralized path-validation policies to all file sinks, test for traversal and symlink escapes, monitor unexpected filesystem writes, remove default credentials, and enforce secure upload handling through code review and CI controls.

Find out what's already
exploitable in your codebase.