A PLC runs whatever logic and firmware it was last given, and that
state is rarely checked after commissioning. Firmware review answers
three questions. What version is actually running, does the logic
match the approved baseline, and who could have changed either one.
All three are answered offline, from copies, never by flashing or
editing a live controller to see what happens.
Safety warning. Never upload, download, or flash firmware or logic
to a live PLC during a security review. Work from exports and
backups provided by operations, in a lab or on an offline
workstation. A failed or interrupted transfer can stop a process,
and a logic change made for testing can leave a plant in an unsafe
state after you leave.
Quick Workflow
- Get written authorization and the approved baseline from
operations. Without a baseline, you can inventory but you cannot
verdict a difference.
- Inventory every PLC in scope. Vendor, model, firmware version,
logic version, and engineering workstation software version.
- Hash every firmware image, logic export, and project file the
moment you receive it, and keep the hashes with your notes.
- Compare firmware versions against vendor advisories and the
approved patch level. Flag unsupported or known vulnerable
versions with their advisory reference.
- Diff the logic against the baseline. List added rungs, changed
timers, changed set points, and new network or remote access
blocks separately.
- Check for unsafe defaults. Default or shared engineering
passwords, programming mode left enabled, and unused protocols
still listening.
- Review change control. Who approved the last change, when, and
is there a backup that matches what is running now.
- Report each controller with its version verdict, its logic diff
summary, and the exact remediation, such as patch in a
maintenance window or restore from the approved baseline.
1. Inventory and hashing
Hash first, analyze second. A hash taken at receipt proves the copy
you analyzed is the copy operations gave you.
# Inventory template: one line per controller, filled with operations
cat > /tmp/plc_inventory.csv << 'EOF'
hostname,ip,vendor,model,firmware,logic_version,mode
plc-press-01,192.168.10.20,example-vendor,example-model,see-export,v1.4,run
plc-mixer-02,192.168.10.21,example-vendor,example-model,see-export,v1.2,run
EOF
cat /tmp/plc_inventory.csv
# Hash every export the moment you receive it
mkdir -p /tmp/plc_review
sha256sum /tmp/plc_review/* > /tmp/plc_review/hashes.txt 2>/dev/null || true
cat /tmp/plc_review/hashes.txt
#!/usr/bin/env python3
"""Hash a directory of PLC exports and write a manifest."""
import hashlib
import pathlib
BASE = pathlib.Path("/tmp/plc_review")
out = []
for path in sorted(BASE.iterdir()):
if path.is_file() and path.name != "hashes.txt":
digest = hashlib.sha256(path.read_bytes()).hexdigest()
out.append("%s %s" % (digest, path.name))
print("%s %s" % (digest, path.name))
(BASE / "hashes.txt").write_text("\n".join(out) + "\n")
2. Logic diff against the baseline
Logic diffs are most useful when they separate cosmetic changes from
process changes. A renamed tag is noise. A changed timer, a new
output coil, or a removed interlock is a finding.
#!/usr/bin/env python3
"""Diff two plain text logic exports, grouped by change type."""
import difflib
import pathlib
baseline = pathlib.Path("/tmp/plc_review/baseline_logic.txt").read_text().splitlines()
current = pathlib.Path("/tmp/plc_review/current_logic.txt").read_text().splitlines()
for line in difflib.unified_diff(baseline, current, lineterm="",
fromfile="baseline", tofile="current"):
print(line)
print("\nReview each added or removed line and classify it:")
print(" cosmetic: rename, comment, layout only")
print(" process: timer, counter, set point, output coil, interlock")
print(" access: new comms block, new remote access, new user or role")
# Quick text signals in an exported project (offline copy only)
grep -r -i -n "password\|default\|admin" /tmp/plc_review/ \
| head -40
echo "Every hit needs context. A password string in an export is"
echo "evidence for review, not proof of a live credential."
# Look for programming mode and protocol exposure in the export notes
grep -r -i -n "program mode\|remote\|ethernet\|serial" /tmp/plc_review/ \
| head -40
3. Version and advisory comparison
Versions only mean something against a reference. Record the vendor
advisory or release note for each version, and never guess a patch
level from a version string you have not checked.
#!/usr/bin/env python3
"""Version comparison table that forces an advisory reference."""
controllers = [
{"name": "plc-press-01", "running": "see-export",
"approved": "see-baseline", "advisory": "vendor advisory reference here",
"verdict": "unverdicted until advisory is checked"},
{"name": "plc-mixer-02", "running": "see-export",
"approved": "see-baseline", "advisory": "vendor advisory reference here",
"verdict": "unverdicted until advisory is checked"},
]
for ctrl in controllers:
print("%s: running %s, approved %s" % (
ctrl["name"], ctrl["running"], ctrl["approved"]))
print(" advisory: %s" % ctrl["advisory"])
print(" verdict: %s" % ctrl["verdict"])
Edge cases
- No baseline exists. Say so plainly. Inventory and flag obvious
unsafe defaults, but do not claim the logic is clean or tampered
with when there is nothing to compare it against.
- Firmware version hidden. Some controllers report firmware only
through vendor software, not over the network. Record the version
as not observable over the network and get it from operations.
- Logic exports differ by tool version. The same logic exported by
two tool versions can diff heavily. Normalize with the same tool
version for baseline and current before diffing.
- Compiled logic only. Without source, compare hashes and behavior
notes instead of rung level diffs, and say the review depth was
limited by the available artifact.
- Safety logic mixed with control logic. If safety logic appears in
the same project, stop and escalate to the safety team. Do not
verdict safety logic from a general PLC review.
- Backups that do not match. A backup dated after the last approved
change, with no change record, is itself a finding about change
control, even if the logic looks reasonable.
Key references
- Vendor firmware release notes and security advisories for the
exact controller models in scope, checked per device.
- NIST SP 800-82 Rev 3, Guide to Operational Technology Security,
for PLC inventory, baseline, and change control practice.
- IEC 62443 patch management and system hardening concepts, for
how firmware updates should be approved and staged in OT.
- Parent skill plc-basics, for PLC architecture, scan cycle, and
operating modes that frame every firmware and logic finding.
1---2name: plc-basics-firmware-review3parent: plc-basics4description: Use when reviewing PLC firmware, PLC logic, or engineering workstation software on an authorized OT engagement or lab. Covers firmware inventory and hashing, version and patch comparison, logic change review, hardcoded credential and unsafe default checks, and change control evidence. Also use when a PLC program must be proven to match its approved baseline before it is trusted again.5version: 1.0.06domain: ics-scada7lifecycle: stable8last_verified: '2026-10-27'9requires: [plc-basics]10extends: []11relates: [safety-systems, ics-incident-response, modbus-security]12tools:13 - name: Python14 version: "3.12"15 - name: Wireshark16 version: "4.4"17 - name: nmap18 version: "7.98"19metadata:20 source: https://skillmd.com/skills/mizazhaider-ceh/plc-basics-firmware-review21---2223A PLC runs whatever logic and firmware it was last given, and that24state is rarely checked after commissioning. Firmware review answers25three questions. What version is actually running, does the logic26match the approved baseline, and who could have changed either one.27All three are answered offline, from copies, never by flashing or28editing a live controller to see what happens.2930Safety warning. Never upload, download, or flash firmware or logic31to a live PLC during a security review. Work from exports and32backups provided by operations, in a lab or on an offline33workstation. A failed or interrupted transfer can stop a process,34and a logic change made for testing can leave a plant in an unsafe35state after you leave.3637## Quick Workflow38391. Get written authorization and the approved baseline from40 operations. Without a baseline, you can inventory but you cannot41 verdict a difference.422. Inventory every PLC in scope. Vendor, model, firmware version,43 logic version, and engineering workstation software version.443. Hash every firmware image, logic export, and project file the45 moment you receive it, and keep the hashes with your notes.464. Compare firmware versions against vendor advisories and the47 approved patch level. Flag unsupported or known vulnerable48 versions with their advisory reference.495. Diff the logic against the baseline. List added rungs, changed50 timers, changed set points, and new network or remote access51 blocks separately.526. Check for unsafe defaults. Default or shared engineering53 passwords, programming mode left enabled, and unused protocols54 still listening.557. Review change control. Who approved the last change, when, and56 is there a backup that matches what is running now.578. Report each controller with its version verdict, its logic diff58 summary, and the exact remediation, such as patch in a59 maintenance window or restore from the approved baseline.6061## 1. Inventory and hashing6263Hash first, analyze second. A hash taken at receipt proves the copy64you analyzed is the copy operations gave you.6566```bash67# Inventory template: one line per controller, filled with operations68cat > /tmp/plc_inventory.csv << 'EOF'69hostname,ip,vendor,model,firmware,logic_version,mode70plc-press-01,192.168.10.20,example-vendor,example-model,see-export,v1.4,run71plc-mixer-02,192.168.10.21,example-vendor,example-model,see-export,v1.2,run72EOF73cat /tmp/plc_inventory.csv7475# Hash every export the moment you receive it76mkdir -p /tmp/plc_review77sha256sum /tmp/plc_review/* > /tmp/plc_review/hashes.txt 2>/dev/null || true78cat /tmp/plc_review/hashes.txt79```8081```python82#!/usr/bin/env python383"""Hash a directory of PLC exports and write a manifest."""84import hashlib85import pathlib8687BASE = pathlib.Path("/tmp/plc_review")88out = []89for path in sorted(BASE.iterdir()):90 if path.is_file() and path.name != "hashes.txt":91 digest = hashlib.sha256(path.read_bytes()).hexdigest()92 out.append("%s %s" % (digest, path.name))93 print("%s %s" % (digest, path.name))94(BASE / "hashes.txt").write_text("\n".join(out) + "\n")95```9697## 2. Logic diff against the baseline9899Logic diffs are most useful when they separate cosmetic changes from100process changes. A renamed tag is noise. A changed timer, a new101output coil, or a removed interlock is a finding.102103```python104#!/usr/bin/env python3105"""Diff two plain text logic exports, grouped by change type."""106import difflib107import pathlib108109baseline = pathlib.Path("/tmp/plc_review/baseline_logic.txt").read_text().splitlines()110current = pathlib.Path("/tmp/plc_review/current_logic.txt").read_text().splitlines()111for line in difflib.unified_diff(baseline, current, lineterm="",112 fromfile="baseline", tofile="current"):113 print(line)114print("\nReview each added or removed line and classify it:")115print(" cosmetic: rename, comment, layout only")116print(" process: timer, counter, set point, output coil, interlock")117print(" access: new comms block, new remote access, new user or role")118```119120```bash121# Quick text signals in an exported project (offline copy only)122grep -r -i -n "password\|default\|admin" /tmp/plc_review/ \123 | head -40124echo "Every hit needs context. A password string in an export is"125echo "evidence for review, not proof of a live credential."126# Look for programming mode and protocol exposure in the export notes127grep -r -i -n "program mode\|remote\|ethernet\|serial" /tmp/plc_review/ \128 | head -40129```130131## 3. Version and advisory comparison132133Versions only mean something against a reference. Record the vendor134advisory or release note for each version, and never guess a patch135level from a version string you have not checked.136137```python138#!/usr/bin/env python3139"""Version comparison table that forces an advisory reference."""140controllers = [141 {"name": "plc-press-01", "running": "see-export",142 "approved": "see-baseline", "advisory": "vendor advisory reference here",143 "verdict": "unverdicted until advisory is checked"},144 {"name": "plc-mixer-02", "running": "see-export",145 "approved": "see-baseline", "advisory": "vendor advisory reference here",146 "verdict": "unverdicted until advisory is checked"},147]148for ctrl in controllers:149 print("%s: running %s, approved %s" % (150 ctrl["name"], ctrl["running"], ctrl["approved"]))151 print(" advisory: %s" % ctrl["advisory"])152 print(" verdict: %s" % ctrl["verdict"])153```154155## Edge cases156157- No baseline exists. Say so plainly. Inventory and flag obvious158 unsafe defaults, but do not claim the logic is clean or tampered159 with when there is nothing to compare it against.160- Firmware version hidden. Some controllers report firmware only161 through vendor software, not over the network. Record the version162 as not observable over the network and get it from operations.163- Logic exports differ by tool version. The same logic exported by164 two tool versions can diff heavily. Normalize with the same tool165 version for baseline and current before diffing.166- Compiled logic only. Without source, compare hashes and behavior167 notes instead of rung level diffs, and say the review depth was168 limited by the available artifact.169- Safety logic mixed with control logic. If safety logic appears in170 the same project, stop and escalate to the safety team. Do not171 verdict safety logic from a general PLC review.172- Backups that do not match. A backup dated after the last approved173 change, with no change record, is itself a finding about change174 control, even if the logic looks reasonable.175176## Key references177178- Vendor firmware release notes and security advisories for the179 exact controller models in scope, checked per device.180- NIST SP 800-82 Rev 3, Guide to Operational Technology Security,181 for PLC inventory, baseline, and change control practice.182- IEC 62443 patch management and system hardening concepts, for183 how firmware updates should be approved and staged in OT.184- Parent skill plc-basics, for PLC architecture, scan cycle, and185 operating modes that frame every firmware and logic finding.