# Dieselgate, but for trains - some heavyweight hardware hacking

Newag trains contained hidden software locks that disabled them after 10 days at competitor workshops, at GPS coordinates of rival maintenance sites, or after component swaps.

- Payout: Real-world hack
- Severity: high
- Program: Newag
- Analysis by: Dragon Sector
- Disclosed: 2023-12-05
- Write-up quality: 8/10
- Original: https://badcyber.com/dieselgate-but-for-trains-some-heavyweight-hardware-hacking/
- Library page: https://bugbountylibrary.com/r/blog%3Abadcyber-com-dieselgate-but-for-trains-some-heavyweight-hardware-hacking
- Tags: area:critical domain:critical-infra domain:iot impact:dos kind:incident platform:research sev:high tech:linux technique:reverse-engineering technique:source-review vuln:business-logic vuln:misconfiguration

**Target:** Impuls 45WE train on-board computer (TriCore-based)
**Root cause:** Firmware embedded GPS-coordinate geofences and serial-number/odometer/date conditions that deliberately disabled train operation when serviced by third parties or after defined thresholds.
**Steps:**
1. Dump on-board computer memory byte-by-byte via a discovered debugging interface (no SDK dump option).
2. Improve Ghidra for TriCore and reverse the firmware.
3. Compare memory images of working vs. bricked trains to find flag values that gate inverter startup.
4. Identify GPS coordinate ranges (e.g. `53.13845 < lat && lat < 53.13882 && 17.99011 < long && long < 17.99837`) matching rival PESA/workshop sites.
5. Find condition disabling train after >=10 days inside those coordinates.
6. Find serial-number check blocking train after component replacement, plus a button-sequence unlock later removed by update.
7. Find date condition: day>=21 && month>=11 && year>=2021 triggers fake compressor failure.
8. Build a tool to clear software locks on the on-board computer.
**How found:** Trains ran fine before maintenance but refused to start after, with no fault codes; team dumped firmware, compared images across working/bricked units, and spotted suspicious float constants that turned out to be GPS coordinates of competitor workshops.
**Exploitation:** Locks triggered automatically by GPS position, dwell time, component serial change, odometer, or date, leaving trains immobile while diagnostics reported all-clear; manufacturer's update removed the button-sequence unlock, forcing memory-level flag patching.
**Escalation:** Same lock mechanism found across 29 trains at multiple operators (Wrocław, Opole, Kraków, Szczecin, Warszawa, Zielona Góra, Kolej Mazowieckie); a UDP<->CAN converter with GSM modem exfiltrated lock status remotely.
**Insight:** When a device 'works until serviced', diff firmware/memory images between healthy and bricked units and grep for float constants that decode to GPS coordinates, dates, or serial numbers — vendor sabotage often hides as magic numbers.

## Proof of concept (copied exactly from the original report)

**GPS coordinate lock pseudo-code for workshops**

```
check1 = 53.13845 < lat && lat < 53.13882 && 17.99011 < long && long < 17.99837; 
check2 = 53.14453 < lat && lat < 53.14828 && 18.00428 < long && long < 18.00555; 
check3 = 52.17048 < lat && lat < 52.17736 && 21.53480 < long && long < 21.54437; 
check4 = 49.60336 < lat && lat < 49.60686 && 20.70073 < long && long < 20.70840 
 && (this->lock_function_test & 1); 
check5 = 53.10244 < lat && lat < 53.10406 && 18.07817 < long && long < 18.08243; 
check6 = 50.12608 < lat && lat < 50.12830 && 19.38411 < long && long < 19.38872; 
check7 = 52.77292 < lat && lat < 52.77551 && 18.22117 < long && long < 18.22724;
```

