Listen to this Post

Introduction:
In the world of industrial control systems, security is not found in slides, policies, or compliance checklists—it lives in the logic that starts motors, opens valves, and moves pressure across the grid. The choice of PLC programming language is far more than an engineering preference; it determines how easily a system can be tested, how quickly faults can be found, and how clearly an attack path can be seen. With IT/OT convergence expanding attack surfaces and legacy systems lacking basic security functions, understanding the security implications of each IEC 61131-3 language is no longer optional—it is mission-critical.
Learning Objectives:
- Understand the five IEC 61131-3 PLC programming languages and their distinct security postures.
- Identify how language choice impacts testability, fault visibility, and attack path analysis.
- Learn practical commands and techniques for auditing, testing, and hardening OT environments.
You Should Know:
- Ladder Diagram (LD) – The Visual Relay That Hides Complexity
Ladder Diagram is the most widely used PLC language, built for relay logic and favored by technicians who need to see what happens fast. It uses contacts, coils, timers, and interlocks in a graphical format that mimics electrical schematics. While this visual approach is intuitive and useful for machine-level logic, large ladder diagrams become notoriously hard to reason about—and that is where security risks emerge.
The challenge is that ladder logic bombs—malware written in ladder logic—can lie dormant, replacing sensor values or taking over actuators once triggered. Attackers can manipulate ladder logic on the PLC such that engineering software cannot process it while the PLC continues to execute it successfully. Furthermore, weak cryptography and predictable key generation in some PLC ecosystems let attackers passively decrypt traffic and extract ladder programs.
Step‑by‑step guide – Auditing Ladder Logic for Security Weaknesses:
- Extract the ladder program from the PLC using the manufacturer’s engineering software (e.g., Schneider EcoStruxure, Siemens TIA Portal).
- Perform a control flow analysis to identify unprotected rungs that can be bypassed or overridden.
- Check for unauthenticated Modbus/TCP access that could allow remote manipulation of ladder logic.
- Use Wireshark to capture and dissect industrial protocol traffic (Modbus, S7) to detect plaintext credential transmission.
-
Function Block Diagram (FBD) – Process Flow with a Blinding Problem
Function Block Diagram is ideal for process automation, handling analog values, PID loops, and scaling. It represents flow visually: input goes into a block, the block changes the value, and output moves the process. This clarity makes FBD common in process automation environments.
However, FBD programs are susceptible to obfuscation techniques that make them harder to understand and reverse-engineer. An attacker with access to the engineering workstation can modify function blocks to introduce subtle logic errors that are nearly invisible during visual inspection. Without proper access control and change management, FBD programs become a blind spot in OT security.
Step‑by‑step guide – Securing Function Block Diagrams:
- Implement version control for all FBD programs to track and audit changes.
- Restrict access to engineering workstations using Windows Group Policy and local security policies.
- Enable project file encryption where supported by the PLC development environment.
- Use formal verification techniques—convert FBD programs to Verilog and run model checking with SMV to detect logic flaws.
-
Structured Text (ST) – The Powerful Double-Edged Sword
Structured Text is where PLC programming starts to look like traditional software—with IF, FOR, CASE, arrays, functions, and math. This high-level, Pascal-like language is powerful for complex logic and protocol logic. But power comes with danger: bad ST hides behavior, and hidden behavior is bad for operations and bad for security.
Modern PLCs programmed in ST were never designed with security as a core priority. ST is prone to subtle logic vulnerabilities that traditional static analysis and fuzzing struggle to detect. Logic-level vulnerabilities range from simple bugs to advanced control flow manipulations that have led to real-world consequences—including the 2015 Ukraine blackout, where attackers exploited PLC weaknesses.
Step‑by‑step guide – Hardening Structured Text Code:
- Apply the Top 20 Secure PLC Coding Practices published by ISAGCA, which cover buffer overflow prevention, input validation, and secure state management.
- Use static analysis tools designed for ST, such as ICSQuartz, the first native fuzzer for IEC 61131-3 Structured Text.
- Fine-tune LLMs for vulnerability detection—research shows that open-source models like CodeLlama and Qwen2.5-Coder can achieve significant gains in binary and multi-class vulnerability classification when fine-tuned on ST code.
- Conduct peer reviews of all ST code, focusing on state transitions, race conditions, and duplicate output assignments.
-
Sequential Function Chart (SFC) – States That Demand Visibility
Machines do not always run as pure logic; they run as states: Start → Fill → Heat → Mix → Drain → Stop. Sequential Function Chart makes these states visible, making it useful for batch processes, startup sequences, and shutdown procedures. SFC’s step-by-step process control provides clarity for operations teams.
From a security perspective, SFC’s strength is its visibility into state transitions. An attacker who modifies transition conditions can force the system into unsafe states—opening a valve at the wrong time or starting a motor during maintenance. Without proper monitoring of state transitions against expected sequences, these manipulations go unnoticed.
Step‑by‑step guide – Monitoring SFC State Transitions:
- Define expected state transition sequences for each operational mode (startup, normal operation, shutdown, emergency).
- Implement anomaly detection that alerts when state transitions deviate from expected sequences.
- Use SIEM integration to correlate SFC state changes with network events and logs.
- Test SFC logic in a safe environment using platforms like Labshock before deployment.
-
Instruction List (IL) – The Legacy That Won’t Die
Instruction List is the assembly-style language of PLCs, now deprecated but still found in legacy systems. It is not where new systems should go, but many plants still run IL because “the old system says hello.” Legacy programming languages contain design flaws that can lead to vulnerable automation programs.
Step‑by‑step guide – Managing Legacy Instruction List Risk:
- Inventory all IL-based PLCs in your environment and prioritize them for migration.
- Implement network segmentation to isolate legacy PLCs from IT networks and the internet.
- Use protocol-level monitoring to detect unauthorized commands targeting legacy controllers.
- Plan a phased migration to modern languages (ST or FBD) with proper security controls.
6. Real-World OT Security Testing with Labshock
The point is simple: OT security cannot stop at documentation. You need testable logic, traffic, process state, and proof. Labshock is a practical, environment-driven platform for learning and practicing OT and ICS security using real industrial components, real protocols, and real telemetry. It is not a simulator—it is a controlled OT security laboratory that provides a ready-to-use environment to learn, simulate, and test defensive strategies.
Step‑by‑step guide – Deploying Labshock for OT Security Testing:
- Install Docker on your system (minimum: 2 CPU, 2GB RAM, 10GB storage).
- Clone the Labshock repository from GitHub and follow the installation instructions.
- Launch Labshock in trial mode—it starts with a 5-minute initialization delay and a 40-minute session limit (unlimited restarts).
- Deploy a complete OT/ICS cyber range with SCADA, PLC, Engineering Workstation, and DMZ in less than 10 minutes.
- Capture traffic, test SIEM rules, and refine IDS detection in a safe, isolated environment.
- Practice offensive techniques against virtual PLCs using Modbus and other industrial protocols.
Linux/Windows Commands for OT Security Auditing:
- Network discovery in OT environments (Linux):
nmap -sS -p 502,102,4840,44818 --open 192.168.1.0/24
(Scans for Modbus, S7, OPC-UA, and EtherNet/IP services)
- Capturing industrial protocol traffic (Linux/Windows with Wireshark CLI):
tshark -i eth0 -f "port 502 or port 102 or port 4840" -w ot_traffic.pcap
-
Modbus enumeration (Linux):
modbus-cli 192.168.1.100 read_holding_registers 0 10
-
Active Directory enumeration in OT environments (Windows):
Get-ADComputer -Filter | Select-Object Name, OperatingSystem
-
Using PEAT for OT device data collection (Linux/Windows/Docker):
docker run -it sandialabs/peat scan 192.168.1.0/24
PEAT pulls configuration, firmware, and process logic from OT devices
What Undercode Say:
-
Key Takeaway 1: The five PLC languages are not merely syntax—they are control surfaces that define how a system can be tested, attacked, and defended. Ladder Diagram provides visibility but hides complexity; Structured Text offers power but obscures behavior; Function Block Diagrams clarify process flow but can be obfuscated; Sequential Function Charts expose state transitions but require vigilant monitoring; Instruction List is a legacy liability that must be managed.
-
Key Takeaway 2: Security in OT environments must be testable, not theoretical. Platforms like Labshock enable hands-on experimentation with real industrial components and protocols, bridging the gap between compliance-driven security and operationally verifiable security. The future of OT security lies in testable logic, traffic analysis, process state monitoring, and proof—not slides and policies.
Analysis:
The discussion around PLC programming languages has historically focused on engineering efficiency and maintainability. However, as IT/OT convergence accelerates and industrial systems become increasingly networked, the security implications of language choice can no longer be ignored. Zakhar Bernhardt’s insight that “PLC languages are control surfaces” reframes the conversation: these languages define not just how logic is written, but how easily an attacker can understand, manipulate, and exploit that logic. The fact that security functions were virtually nonexistent in OT devices until about five years ago means that most installed PLCs were designed without security in mind. This legacy creates a massive attack surface that requires active testing, not passive compliance. The emergence of LLM-based vulnerability detection for Structured Text and platforms like Labshock signals a maturation of the OT security field—moving from theoretical best practices to practical, testable security.
Prediction:
- +1 The integration of AI and LLMs into PLC code security will accelerate vulnerability discovery, enabling proactive identification of logic flaws before they can be exploited in production environments.
- -1 The shortage of OT security professionals with deep understanding of all five IEC 61131-3 languages will persist, leaving many plants reliant on legacy systems with known vulnerabilities.
- +1 Platforms like Labshock will become standard training tools for OT security, democratizing access to realistic industrial environments and reducing the barrier to entry for security professionals.
- -1 The continued use of unauthenticated industrial protocols (Modbus, EtherNet/IP) over flat networks will enable attackers to manipulate logic across all language types, regardless of coding best practices.
- +1 Formal verification techniques for FBD and LD will become more accessible, allowing organizations to mathematically prove the safety and security of critical control logic.
- -1 As soft-PLCs running on Linux and Windows become more prevalent, the OT attack surface will expand dramatically, introducing traditional IT vulnerabilities into industrial environments.
- +1 The development of secure PLC coding practices and standards, such as the ISAGCA Top 20, will gradually raise the baseline security of new PLC deployments.
- -1 Attackers will continue to develop ladder logic bombs and other PLC-specific malware that can lie dormant and evade detection.
- +1 The convergence of OT security with DevOps practices—including version control, CI/CD pipelines, and automated testing—will improve the quality and security of PLC code.
- -1 Without mandatory security requirements in IEC 61131-3 itself, manufacturers will continue to prioritize functionality over security, leaving the burden on end-users to implement defensive measures.
▶️ Related Video (82% Match):
🎯Let’s Practice For Free:
🎓 Live Courses & Certifications:
Join Undercode Academy for Verified Certifications
🚀 Request a Custom Project:
Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands
IT/Security Reporter URL:
Reported By: Zakharb Labshock – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅


