repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
4840-pentesting-opc-ua.mdMarkdown161 lines14.0 KiBsource raw download

title: "4840 - Pentesting OPC UA" section: "Network Services" sectionSlug: "network-services-pentesting" sourcePath: "src/network-services-pentesting/4840-pentesting-opc-ua.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/network-services-pentesting/4840-pentesting-opc-ua.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

4840 - Pentesting OPC UA#

Basic Information#

OPC UA, standing for Open Platform Communications Unified Access, is a crucial open-source protocol used in various industries like Manufacturing, Energy, Aerospace, and Defence for data exchange and equipment control. It uniquely enables different vendors' equipment to communicate, especially with PLCs.

Its configuration allows for strong security measures, but often, for compatibility with older devices, these are lessened, exposing systems to risks. Additionally, finding OPC UA services can be tricky since network scanners might not detect them if they're on nonstandard ports.

Default port: 4840 (binary opc.tcp). Many vendors expose separate discovery endpoints (/discovery), HTTPS bindings (4843/443), or vendor-specific listener ports such as 49320 (KepServerEX), 62541 (OPC Foundation reference stack) and 48050 (UaGateway). Expect multiple endpoints per host, each advertising transport profile, security policy and user-token support.

Built-in NodeId Why it matters
i=2253 (0:Server) Holds ServerArray, vendor/product strings and namespace URIs.
i=2256 (ServerStatus) Reveals uptime, current state, and optionally build info.
i=2267 (ServerDiagnosticsSummary) Shows session counts, aborted requests, etc. Great for fingerprinting brute-force attempts.
i=85 (ObjectsFolder) Entry point to walk exposed device tags, methods and alarms.
PORT     STATE SERVICE REASON
4840/tcp open  unknown syn-ack

Pentesting OPC UA#

To reveal security issues in OPC UA servers, scan it with OpalOPC.[1]

opalopc -vv opc.tcp://$target_ip_or_hostname:$target_port

Discovery & Enumeration Playbook#

  1. Locate all OPC UA transports

    nmap -sV -Pn -n --open -p 4840,4843,49320,48050,53530,62541 $TARGET
    

    Repeat on UDP group addresses if the environment uses LDS-ME multicast discovery.

  2. Fingerprint endpoints

    • Invoke FindServers/GetEndpoints over each transport to capture SecurityPolicyUri, SecurityMode, UserTokenType, application URI and product strings.
    • Enumerate namespaces so you can resolve vendor-specific NodeIds; abuse namespace collisions to coax clients into loading attacker-controlled schemas.
  3. Walk the address space

    • Start at ObjectsFolder (i=85) and recursively Browse/Read to find writable process variables, Method nodes and historian/log nodes.
    • Query ServerStatus.BuildInfo to understand firmware provenance, and ServerCapabilities.OperationLimits to gauge how easy it is to exhaust server resources.
    • If anonymous access is allowed, immediately test Call on maintenance methods (e.g., ns=2;s=Reset, ns=2;s=StartMotor). Many vendors forget to bind role permissions to custom methods.
  4. Session abuse

    • Reuse or clone AuthenticationToken values from other sessions (captured via MITM or diagnostics exposure) to hijack existing subscriptions.
    • Force the server into SessionDiagnostics flooding by creating dozens of inactive sessions; some stacks crash once the MaxSessionCount limit is exceeded.

Automated assessment with OpalOPC#

Targeting discovery infrastructure, GDS & Reverse Connect#

Attacking legacy security policies (Basic128Rsa15)#

2024-2025 exploit watchlist#

Crafting OPC UA clients for exploitation#

Fuzzing & exploit development tooling#

Claroty Team82 released an open-source opcua-exploit-framework that packages years of Pwn2Own-grade research into reusable modules:[2]

Exploiting authentication bypasses#

If authentication bypass vulnerabilities are found, you can configure an OPC UA client accordingly and see what you can access. This may allow anything from merely reading process values to actually operating heavy-duty industrial equipment.

To get a clue of the device you have access to, read the "ServerStatus" node values in the address space and google for a usage manual.

Targeting OPC UA clients instead of servers#

Shodan#

Combine the search with vendor strings ("Ignition OPC UA", "KepServerEX") or certificates ("CN=UaServerCert") to prioritize high-value assets before starting intrusive testing.

References#