383 points · by ingve · 4y ago · 165 comments
More modern VW control units are the same in broad strokes - they use UDS on ISO-TP instead of KWP on TP2.0, but this is just evolution of the same fundamentals. And instead of the wacky SGO format inside of FRF update files, they use the ASAM MCD-2 D-ODX format to define flashing layers. Most European automakers are similar.
One interesting difference and trend in automotive control modules (also mentioned in Willem's fantastic write-up) is that many EU modules started adding signature checking and encrypted updates in the late 2000s, while most US and Japanese automakers have only done so in the last 2-3 years.
These encrypted and signature checked updates are by and large still fairly vulnerable - often due to logic errors in the complex upgrade processes and occasionally due to a strange insistence on using RSA using PKCS#1.5 with e=3 and inadequate padding validation.
> Ensure the patches to the calibration values are safe before using.
How would you do that? I've worked on both ends of steering on VW Bugs and Golfs (steering column fixes and tie rod replacements). You don't want to mess either of these up either, but the repairs are (a) well documented and (b) relatively easy to verify you did them correctly.
By contrast, I've seen software break catastrophically in the past from "harmless" updates like changing the number of commas in a version string. In this case it's not the kinda doesn't work problem but hitting an unexpected corner case on the freeway that would worry me.
I'm not a big advocate for comma/OpenPilot or EPS patching stuff in general, but I thought the patch in this example was fairly benign and reasonable as these things go - it was a data patch to the calibration area rather than a code patch, and the altered calibration contained relatively straightforward values with clear references and obvious effects.
Do you mean the XOR encryption used? As someone working on the embedded linux(!= than embedded MCU) side i was very surprised to find such a crude "encryption" scheme employed. On the other hand i reckon there is only so much encryption an 8bit MCU can do. Also tolerance for complex encryption designs must be very low when you are trying to limit the scope of a life critical component.
The anti brute force measure was a bit more refined and almost got the job done.
Regardless, i agree. An great write-up. The binwalk and narrow down of possible CPUs used due to the ASIL-D constraint were really illuminating.
More modern control modules with a bit more resource available to them will use AES as the symmetric encryption (although there are also fixed-key XOR schemes and custom stuff used like this: https://github.com/bri3d/VW_Flash/blob/master/lib/decryptdsg... ).
The keys and even IV are usually fixed across a "model line" of ECUs, so once a decrypted flash memory can be extracted, this isn't much of a protection measure, but it's a lot better than XOR.
Then, in more modern control units, flash areas are also usually protected by both a checksum (usually some CRC permutation, although cute tweaks and random nonsense are common here too) and some form of digital signature.
bri3d refers to using RSA signatures on the firmware once it's written to the flash. By ensuring the firmware is signed using the manufacturers private key it should (in theory) prevent messing with the firmware, even if all encryption/flashing steps have been reverse engineered.
Some interesting reading: https://github.com/bri3d/VW_Flash/blob/master/docs/docs.md https://github.com/jglim/UnsignedFlash
I'm not a cryptographer - but I don't think there's anything wrong with XOR encryption, and I'm not sure why you're putting it in scare-quotes - XOR with a sufficiently large key is absolutely fine, and with a one-time pad is unbreakable. XOR with very large keys is how critical military encryption systems such as radios work.
When cryptographers and security professionals talk about XORing the keystream output of a pseudorandom function with plaintext to encrypt it, we don't call it "XOR encryption", we call it a stream cipher.
When we talk about XORing with a random pad of equal length to the plaintext, we don't call it "XOR encryption", we call it a one-time pad.
When we say "XOR encryption" we invariably mean "silly insecure thing with a repeating keystream no longer than a few bytes".
> XOR with a sufficiently large key is absolutely fine
It isn't. XOR with any key ever used more than once or looped around isn't not just "not unbreakable", it's demonstrably insecure. There is no "sufficiently large key" other than "same size as the plaintext and used only once for that plaintext" (a one time pad). To use smaller keys you need real cryptography, not XOR. Military radios absolutely do not work like this. They use stream ciphers, which can produce ~arbitrary length keystreams without repetition from a small seed key.
These ECUs aren't using one time pads with key lengths the same size as the firmware. I doubt they're using one time pads at all, which would necessitate each version of firmware using a different key.
Excuse me, how do you envision the use of one-time pads in the real world?
And with sufficiently large block keys - how do you deal with data full of zeros? Because XOR of 0 will give you the exact key you have encrypted the data with.
You are not a cryptographer, and indeed, I don’t think you’ve spent enough time thinking about it.
Is it that large keys are factors of very large prime numbers so that to know the keys you will need a very powerful computer?
Cool! Do you have any references?
Ah, yeah, and this is irritating if you're a used car owner, particularly an owner of a car that's now lower value. I can't, for example, pick up a cheap used throttle body for my older Volvo because the main ECU will reject it until someone from the stealership charges me a LOT of money to "program" it.
Although, unfortunately this too is changing, starting in the 2021 model year VW AG have introduced a rather evil technology called SFD which requires server-signed tokens to perform these kinds of basic adaptations. This is all being done in the name of anti-theft security.
We really need better right-to-repair rules for vehicles.
> https://blog.willemmelching.nl/images/vw/IMG_3181.jpg
It doesn't really look cheap to me (large machined surfaces on the cast aluminium casing, two ceramic PCBs, everything connected with wire bonding, even the motor windings and the external connector, which means that at least those bonds are carried out on an almost completely assembled product; also look at the sheer size of the motor bonds) but it does look very reliable - everything is bonded or welded, zero connectors, no fasteners, all solid state.
It probably wouldn't be incredibly expensive in this case (automotive) because all the wire bonding and tab welding can be automated, but clearly cost isn't the main concern behind the design!
I wasn't directly involved but I still have nightmares about wirebonding. For a large partice physics experiment, we bonded electronics to silicon (wafer) sensors. Those small bonds would start oscillating and break as soon as there was any noise with their resonance frequency. It took cooling and heating cycles also pretty badly. In the end they sorted out all problems somehow, but the association "wirebond = delicate" stuck with me.
Recently I opened up a Mitsubishi Electric power steering unit, and while mine looked a bit like a parallel world Enterprise, this one looks like Enterprise with a suffix couple alphabets later than the one in the intro. Mine was just a two PCB build of a logic board with Fujitsu microcontroller and a power board with an H bridge and input/output emergency isolation MOSFETs.
Until around mid 90's cars still had lots of relays and barely comprehensible wiring looms if you could get your hands on workshop manuals.
The sooner we go back to a BEV with the simplicity of a 1960's VW Beetle the better imo, not least so that the third world can get a look in.
And manufactures see them as a chance to make an always connected car that phones home. Tesla was first but everyone else is copying them now.
We urgently need a new generation of very basic transportation devices. The 3rd world relies on Toyo HiLuxes etc which are still easy to keep running. LandRover used to be all over the third world because they were rugged, basic and easy to work on. You'd think Tata who now own them would be continuing the tradition but they are building luxury vehicles with no clear purpose except signaling pretensions to offroad abilities. Embroidered with ECM controlled chips, wiring and sensors...</rant>
> “Question 1 (2020) required manufacturers that sell motor vehicles equipped with telematics systems to install a standardized open data platform beginning with model year 2022. The initiative defined telematics systems as a system in a motor vehicle that collects information generated by the operation of the vehicle that is then transmitted through wireless communications to a remote receiving point where it is stored. The measure allowed vehicle owners to access telematics system data through a mobile device application and to give consent for independent repair facilities to access that data and send commands to the system for repair, maintenance, and diagnostic testing.”
https://ballotpedia.org/Massachusetts_Question_1,_%22Right_t...
Excuse me sir, Did you upload your drive path to NHTSA today? No that will be a $300 fine...
The author has no idea what he's doing, or more specifically what hazards might be lurking right under his nose. I worked in EPS for 6 years and it's all really cool stuff right up until you download code and it promptly turns left all the way to the stop the first time you touch the wheel. That was a bug ;-) I can't tell you how hazardous it may be to tweak tuning parameters - that depends on a lot of things. Tuning aside, just commanding it over CAN might allow you to do things that wouldn't normally happen and might damage something - i.e. are all protections still in place when taking an external command? I didn't work on this model, or at this company, I'm just saying I've seen a lot of stuff and wouldn't recommend messing around with safety-critical ECUs like this.
The first time I did it, my thumb was dislocated because it was inside the wheel! Didn't realise quite how powerful power steering systems are!
Now I have tape over the heated seats button with a warning to only use them or the rear defroster, not both.
Fun fact: The power steering uses 170 Amps when turning the wheel fast! Of course the voltage drops!
Holy cow, that's a crazy failure. Many cars have a zone between idle, and some greater RPM that is essentially a no charge condition. But what a consequence! Having dimmed lights, or an erratic instrumement display is the worst I've seen.
My older Honda has a fairly wide zone, 600 to about 1200 RPM. Annoying on high load days, and I've often wondered why this isn't designed out. Maybe it's wider due to car age and component wear / variation. I've installed a pretty great battery and see a little light dim, and that's about it.
One day I had an alternator failure and some distance to drive to get a new one basically. Made it, but right near the end, the instrument panel would go into reset and the car into some limp mode. Not the end of the world, particularly given I was expecting some failure as battery voltage dropped below 11 volts.
It was close enough to lose instruments entirely, but the engine ran anyway. All in all, it was a pretty graceful failure.
That rando full torque action seems crazy! And at 10! That's definitely a scenario, as you have found out, that can happen enough to seemingly be a problem.
So, what happened! Suddenly, your car is off the road, or what?
Seems like your sore thumb is the least of the potential bad things going on right then.
I bet many have had nearly the same experience with rebuilding a power steering gear... yet that's no justification for taking away control from the things you own.
"Life is risk, risk is life."
I'm a big believer in owning what you buy, but if what you're buying requires a license to operate and you intend to use it publicly, not to mention the various safety regulations and certifications required just for the product to be legal in the first place (which are likely ignored if not violated while modifying the product), then the justification is "not killing someone else accidentally."
This doesn't mean you can never hack anything, but you should be aware of the risks and potential consequences of your actions.
It's also much more benign to destroy components than to have actual bugs. And he's not changing software at the source level.
Diagnostic-specific commands are often restricted when the vehicle is in motion. On VW I remember that any "write" command such as an actuator test being declined even for "innocent" stuff such as lights or power windows on the body control module.
It's completely taboo in openpilot discussions (e.g., the Discord channel), so I'm curious if there's an alternative community open to talking about it (distributing pre-patched or providing a patcher).
For Honda cars at least, openpilot is absolutely hindered by the low torque allowed by the stock firmware.
For the "how" of what happens inside so it can't be repaired please see the sibling comments.
Colloquially means rendering a device in useless state which cannot be recovered.
"Bricking" typically occurs when performing some sort of software update that goes awry, such as during powerfailure, using unofficial updates, etc.
More and more systems have ways to recover from a bad update, especially when the manufacturer offers OTA updates, but in the case like article where an the ECU is not designed to be updated by end-consumers, a bad flash/update can lead to the device being left useless.
and there is no way to obtain the original ROM? and flash it and everything is ok again?
Example: https://github.com/NationalSecurityAgency/ghidra/blob/master...
I'm being half serious - this seems harmless enough, but where do you draw the line? I'm all for the fun of reverse engineering but maybe keep that shit off public roads.
So do the other participants in traffic around him.
Putting a computer between my foot/hands and the physics unfolding in front of me is a total non-starter.
With ABS and ESC, most cars on the road today have a computer involved in the braking system. It seems pretty safe.
Absolutely. These systems have very simple feedback loops and controller algorithms. Determining that you lost traction is a simple problem to solve. Determining that a dangerous obstruction is in front of your vehicle is not.
ABS/ESC also tend to have a more limited impact on the vehicle, even if they do malfunction. You can typically disable these pretty easily (pull fuse/drive system configure).
Because we do have a lot of numbers on cars were there is a computer in-between. Which should indicate to me that it is safer to drive with one instead of without one.
Like just yesterday (I'm driving a new car) I thought about emergency breaking automatic vs. manual and I actually feel safer knowing that the car can potentially break faster.
In the brochure of my mother's potentially future car, it actually advertise emergency breaking with emergency steering to drive left or right. I also found that quite good to have as it should be able to determine much faster if it can evade and where to evade.
Or do you mean this different?
For me, the knowledge that some other engineer designed a system that is a complete black box (from my perspective), which can arbitrarily stop my car with incredible braking force is terrifying.
What happens if the emergency braking system decides to have a bug while you are exiting the freeway at 75mph?
I am picturing this as a scene out of a '50s sci-fi horror movie. The mad scientist with a power steering controller on a tray in his lab. :-)
I’m aware that tuning is a thing, but it’s generally not my scene. What I really want is to do the work myself instead of going to a tuner or buying one of those Cobb kits.
Can HN recommend any resources and/or other technically-oriented communities?
I'm not sure if Openport is still actively developed. Oh, and stay away from the cheap clones. They're reportedly not good[3][4].
Does anyone have experience with the Pandas for remapping and use as a diagnostic tool?
[1] https://www.tactrix.com/index.php?page=shop.product_details&...
[2] https://comma.ai/shop/products/panda
Is there a place where one can download ECU mappings for various car models? Maybe this is silly, but it seems like there ought to be some kind of community-maintained repo, no?
But cool POC for sure.
is this for safety or does the duty cycle of this require some off-time for cooling or whatever?
Granted, if this happens while driving you're likely to have an accident anyway, but if you don't, then waiting 6 minutes would allow you to reclaim your steering for the rest of the journey.
As others have mentioned most USA manufacturers are moving to encrypted CAN buses now though.
He should not do this on any public road and potentially he broke already some law.
EPS is much more powerful than humans. It can apply huge torque and cause incredibly fast acceleration of the steering wheel (from full lock on one side to the other in a split second). Messing with the firmware definitely could cause a situation where the car just does whatever it wants to and the driver can do nothing about it.
However it would be interesting to learn how type approvals handle the self-driving things. Maybe they really do allow all kinds of computer-assisted things? I don't know. If you change some structural beams in the car you surely lose approval. But can you mod steering and braking? What about openpilot users that crash?