/

CVE-2021-47770

Severity:

HIGH RISK

(8.8)

Code Injection in OpenPLC v3

CVE-2021-47770

Awaiting Analysis

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Authenticated Remote Code Execution

Severity:

HIGH RISK

(8.8)

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 v3 contains an authenticated remote code execution vulnerability where a user with valid credentials can inject malicious code through the hardware configuration interface.

By uploading a custom hardware layer that includes attacker-controlled logic (such as a reverse shell), an authenticated attacker can establish a network connection to a chosen host and execute arbitrary commands on the underlying system.

Affected context

This vulnerability affects OpenPLC v3 deployments that allow authenticated users to manage or upload hardware configuration layers through the web or management interface.

The issue arises when the platform accepts user-supplied hardware configuration code and incorporates it into the runtime environment without adequately constraining what code can execute.

Environments where multiple users share access to the OpenPLC interface, or where credentials may be exposed, are at higher risk.

Exploit preconditions

  • Attack surface: OpenPLC v3 hardware configuration upload interface (typically web-based management UI or API).
  • Required access: Valid authenticated credentials with permission to upload or modify hardware layer configurations.
  • Trigger point: Import, compilation, or activation of the uploaded custom hardware layer within the OpenPLC runtime.
  • Why exploitation is possible: The platform treats uploaded hardware layer components as trusted executable code, enabling direct injection of arbitrary logic such as reverse shells without sufficient validation or sandboxing.

Why this happens

The root cause is a code injection flaw consistent with CWE-94: Improper Control of Generation of Code.

OpenPLC v3 allows user-provided hardware layer implementations to be uploaded and executed as part of the control logic.

Because these inputs are not sufficiently restricted, validated, or isolated, an attacker can embed arbitrary code that runs with the privileges of the OpenPLC process.

Conceptually, the system blurs the line between configuration and executable code, treating user-controlled artifacts as trusted logic in the runtime environment.

Potential impact

  • Execution of arbitrary system commands on the host running OpenPLC v3
  • Establishment of reverse shells for persistent remote access
  • Unauthorized manipulation of PLC logic and I/O behavior
  • Disruption of industrial or operational processes controlled by the PLC
  • Lateral movement within the operational technology (OT) or corporate network
  • Theft or tampering of configuration and process data

General mitigation guidance

Effective mitigation focuses on restricting how and when user-supplied code can enter the execution path and minimizing the trust boundary around hardware configuration:

  • Treat uploaded hardware layers as untrusted input and enforce strict validation of allowed constructs and APIs.
  • Prefer declarative, data-only configuration formats over executable or scriptable hardware definitions.
  • Introduce a constrained execution environment (sandbox or restricted runtime) for any user-supplied extension logic.
  • Apply least-privilege principles to the OpenPLC runtime, limiting OS-level permissions to reduce the blast radius if code executes.
  • Implement strong authentication and authorization controls so only highly trusted administrators can upload or modify hardware layers.
  • Use change control, code review, and approval workflows for any hardware configuration updates in production environments.

How teams detect issues like this

Detection typically combines code-centric and operational monitoring approaches:

  • Review the codebase and configuration pipeline for flows where uploaded hardware layers or configuration bundles are compiled or executed directly.
  • Use static analysis or manual review to flag components that load, compile, or dynamically link user-supplied code without constraints.
  • Monitor audit logs for unusual hardware configuration uploads, especially from accounts not normally performing administrative tasks.
  • Implement file integrity monitoring on directories where hardware layers or configuration modules are stored and loaded at runtime.
  • Use network monitoring to detect unexpected outbound connections from the OpenPLC host, particularly reverse shell-like patterns to unapproved IPs and ports.

Sources

SourceLink
github.comgithub.com/thiagoralves/OpenPLC_v3
exploit-db.comexploit-db.com/exploits/49803
openplcproject.comopenplcproject.com/
vulncheck.comvulncheck.com/advisories/openplc-remote-code-execution

Frequently asked

questions

Yes, it can be exploited remotely, but only by an attacker who can authenticate to the OpenPLC v3 interface and has sufficient permissions to upload or modify hardware configurations.

The attacker must possess valid credentials with rights to manage hardware configuration layers.

Without authenticated access, the vulnerable functionality is not directly reachable.

The most robust pattern is to eliminate direct execution of user-supplied code in configuration paths.

Where extensibility is required, constrain it to a well-defined, declarative format or a heavily sandboxed extension model with strict validation of allowed operations.

Future designs should clearly separate configuration data from executable logic, avoid treating uploaded artifacts as trusted code, enforce principle of least privilege for runtime components, and integrate security review and automated checks into the development and deployment pipelines for any feature that loads or executes user-supplied content.

Find out what's already
exploitable in your codebase.