News for hackers. Stuff that matters.
Re:Hacking a VW Golf Power Steering ECU by bri3d on Monday January 03, 2022 @10:14AM (#29781517)
This is probably one of the best write-ups I've seen around the basics of automotive control unit reverse engineering.

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.

Re:Hacking a VW Golf Power Steering ECU by hodgesrm on Monday January 03, 2022 @07:27PM (#29789176)
Agree. Absolutely awesome article except for this one little line:

> 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.

Re:Hacking a VW Golf Power Steering ECU by bri3d on Monday January 03, 2022 @09:19PM (#29790400)
The calibration values were discovered through static analysis, so the code referencing those values can be followed to determine if unexpected side effects may be present. Obviously this process is imperfect, but it's not like blindly throwing bytes in and hoping something comes out.

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.

Re:Hacking a VW Golf Power Steering ECU by ptsneves on Monday January 03, 2022 @10:27AM (#29781648)
> 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

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.

Re:Hacking a VW Golf Power Steering ECU by bri3d on Monday January 03, 2022 @10:36AM (#29781752)
No, this EPS control module is remarkably primitive even by late 2000s standards and several generations behind today's state of the art.

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.

Re:Hacking a VW Golf Power Steering ECU by pd0wm on Monday January 03, 2022 @10:34AM (#29781724)
The XOR encryption was just for the update container. Newer update files usually employ some stronger forms of compression/encryption. However, it's usually some strange in-house crypto, so eventually people figure it out.

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

Re:Hacking a VW Golf Power Steering ECU by chrisseaton on Monday January 03, 2022 @10:36AM (#29781747)
> 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.

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.

Re:Hacking a VW Golf Power Steering ECU by marcan_42 on Monday January 03, 2022 @01:23PM (#29784199)
> I'm not a cryptographer - but I don't think there's anything wrong with XOR encryption

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.

Re:Hacking a VW Golf Power Steering ECU by monocasa on Monday January 03, 2022 @11:29AM (#29782468)
I think they mean using XOR with a repeated fixed tiny key _as_ the stream cipher, rather than just using XOR to mix the keystream and the plaintext.

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.

Re:Hacking a VW Golf Power Steering ECU by ptsneves on Monday January 03, 2022 @11:27AM (#29782444)
The article's XOR key was 0xFF :) Definitely out of the sufficiently large key range.
Re:Hacking a VW Golf Power Steering ECU by formerly_proven on Monday January 03, 2022 @10:47AM (#29781900)
I'm assuming they meant XOR-ECB with a block size of 1/2/4 bytes.
Re:Hacking a VW Golf Power Steering ECU by heavenlyblue on Monday January 03, 2022 @01:20PM (#29784157)
> XOR with a sufficiently large key is absolutely fine, and with a one-time pad is unbreakable

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.

Re:Hacking a VW Golf Power Steering ECU by chrisseaton on Monday January 03, 2022 @01:30PM (#29784324)
> Excuse me, how do you envision the use of one-time pads in the real world?

You load up as much one-time pad as you will have data to transmit - sometimes hundreds of MB of key if required. Storage is cheap.

Re:Hacking a VW Golf Power Steering ECU by danachow on Monday January 03, 2022 @01:46PM (#29784568)
Hundreds of Megabytes? That’s a big number to you? Did you step out of a time warp from 1990?

Also you are surprisingly quite clueless about basic crypto if you think storage is the biggest issue with practically using one time pads (though it is indeed one). I’m pretty sure even the Wikipedia article can explain this so no reason to spoon feed it here.

Re:Hacking a VW Golf Power Steering ECU by chrisseaton on Monday January 03, 2022 @01:52PM (#29784642)
> Hundreds of Megabytes? That’s a big number to you?

If you only have a hundred MB of data to send… a hundred MB of key is sufficient to use as a one-time pad.

Until digitisation the military literally did encryption over radios using physical pads - everyone carried a big one-time-pad (just a few tens of KB though). It was done as a lookup table rather than an XOR though.

Re:Hacking a VW Golf Power Steering ECU by monocasa on Monday January 03, 2022 @03:16PM (#29786106)
The pad system used by the military predigitisation[0] was a set of keys to input into a keystream generator rather than a strict one time pad style system, except for very specific and limited espionage use cases. And it wouldn't be one time, it'd be on the order of a daily key rotation with key reuse (with maybe a few chosen per day depending on classification level).

[0] I'm assuming we mean computerized here. Old school cipher machines of the type of the ENIGMA and M-209 were arguably digital machines, just base ~26.

Re:Hacking a VW Golf Power Steering ECU by chrisseaton on Monday January 03, 2022 @03:50PM (#29786679)
> I'm assuming we mean computerized here

No, pre common man-pack digital radios, so as recently as just prior to this century. They used paper one-time pads, with a big list of table indices for substitution. You still get them for use when you have no digital crypto for whatever reason.

Re:Hacking a VW Golf Power Steering ECU by monocasa on Monday January 03, 2022 @04:36PM (#29787283)
That's not quite what I'm seeing, instead that what I believe you're talking about (Morse code over open air with a Diana cipher backed by one time pads) were pretty much exclusively used by special forces in Vietnam. The issues with key distribution inherent in one time pads otherwise got in the way of cross team cooperation too much since each pad would only exist in two places (the spec ops team, and a major base close by, but not a FOB in case it was overrun).

They might have taught that use case to radio operator MOSs, but it wasn't actually deployed in the general case it seems.

Re:Hacking a VW Golf Power Steering ECU by chrisseaton on Monday January 03, 2022 @04:49PM (#29787443)
> That's not quite what I'm seeing ... it wasn't actually deployed in the general case

I'm was literally trained in the British variant of technique I'm describing. There's a wikipedia article about it, and it's referenced from this cryptography wiki's one-time-pad page. Other countries used similar systems.

https://en.wikipedia.org/wiki/BATCO

https://cryptography.fandom.com/wiki/One-time_pad

Re:Hacking a VW Golf Power Steering ECU by monocasa on Monday January 03, 2022 @06:08PM (#29788380)
So if I'm understanding BATCO correctly, there's an average key reuse by a single sender after 13 messages because of the how the traffic key rotation selects a row? That, combined with the sense I'm getting that the cipher sheets were distributed widely (auth tables imply multiple senders using the same cipher sheet at the same time) seems to imply broad reuse of key rows, making it a pad, but not a one time pad. Do my assumptions filing in the blanks line up?

I'll give it that's it's definitely way better than DRYAD, which is pretty universally not considered a OTP because of the much greater key reuse (like how auth uses the same cipher tables as encrypt, leaking tables). So it boils down to the practical use case on whether it falls into OTP.

Re:Hacking a VW Golf Power Steering ECU by chrisseaton on Monday January 03, 2022 @06:17PM (#29788487)
Yes entire radio net is moving through the shared pad together - so you when you send you consume a bit of the pad, and when someone sends to you they use the next bit of the pad, then you use the next, etc.

A new row per message means you don't re-use between messages (message is something like a sentence).

Each message should be short enough that you don't re-use (a 22-symbol message is already crazy), and you are not allowed to re-use if that means re-using a target symbol, but yes you might slightly re-use within messages if you're being sloppy.

In reality you don't get through the pad very quickly due to the 'compression' of a dictionary for typical parts of messages.

(This is all public info, not disclosing anything here.)

Re:Hacking a VW Golf Power Steering ECU by markus_zhang on Monday January 03, 2022 @11:10AM (#29782219)
> XOR with very large keys is how critical military encryption systems such as radios work.

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?

Re:Hacking a VW Golf Power Steering ECU by chrisseaton on Monday January 03, 2022 @11:14AM (#29782262)
XOR with a one-time pad doesn't work off factors of large numbers - you're thinking of asymmetric encryption there. You literally just XOR each plain text byte with a key byte.
Re:Hacking a VW Golf Power Steering ECU by markus_zhang on Monday January 03, 2022 @12:08PM (#29783061)
Thanks! I don't know much about cryptography and will check this out.
Re:Hacking a VW Golf Power Steering ECU by ncmncm on Monday January 03, 2022 @02:07PM (#29784874)
There are only two factors of any prime number, large or otherwise: 1 and the number.

But even correcting to what you must have meant to suggest doesn't make sense.

Re:Hacking a VW Golf Power Steering ECU by markus_zhang on Monday January 03, 2022 @03:30PM (#29786362)
Sorry I meant something else, can't wrap my head around to recall the name...
Re:Hacking a VW Golf Power Steering ECU by j4hdufd8 on Monday January 03, 2022 @11:00AM (#29782073)
> XOR with very large keys is how critical military encryption systems such as radios work.

Cool! Do you have any references?

Re:Hacking a VW Golf Power Steering ECU by chrisseaton on Monday January 03, 2022 @11:08AM (#29782185)
For example the TETRA standard for trunked radio, "The key stream bits shall be modules 2 added (XORed) with plain text bits in data, speech and control channels".
Re:Hacking a VW Golf Power Steering ECU by fanf2 on Monday January 03, 2022 @12:58PM (#29783860)
In the TETRA specification they use the term “key stream” to mean the output of a stream cipher, which they call a “key stream generator”. They aren’t XORing directly with a large key - the TETRA key size is 80 bits. See section 6.3.2.2 of https://www.etsi.org/deliver/etsi_en/300300_300399/30039207/...
Re:Hacking a VW Golf Power Steering ECU by chrisseaton on Monday January 03, 2022 @01:14PM (#29784073)
Yes you can programatically generate a key.
Re:Hacking a VW Golf Power Steering ECU by marcan_42 on Monday January 03, 2022 @01:24PM (#29784224)
And we call that a stream cipher, not "XOR encryption", even though it uses a XOR operation. You're programmatically generating a keystream, which is not the same thing as a key.
Re:Hacking a VW Golf Power Steering ECU by ncmncm on Monday January 03, 2022 @02:10PM (#29784920)
See, this is why we can't have secure things.
Re:Hacking a VW Golf Power Steering ECU by tyingq on Monday January 03, 2022 @10:33AM (#29781717)
>many EU modules started adding signature checking and encrypted updates in the late 2000s

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.

Re:Hacking a VW Golf Power Steering ECU by bri3d on Monday January 03, 2022 @10:40AM (#29781797)
This is unlikely to be related to encryption but just protectionism on an older vehicle. Generally speaking, until very recently (like 1-2 years ago), non-immobilizer related adaptation processes are just a matter of finding the correct UDS remoteRoutine to invoke, and aren't cryptographically protected at all. It's likely that the thing you're missing is the diagnostic documentation for the correct routine invocations to send, rather than keys or certificates.

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.

Re:Hacking a VW Golf Power Steering ECU by carlhjerpe on Monday January 03, 2022 @10:55AM (#29782006)
Seeing the amount of part theft in Stockholm I understand why they do it. Particularly steering wheels, they steal them and send them to the baltics where they put them in vehicles where the airbag has fired.
Re:Hacking a VW Golf Power Steering ECU by kalnins on Monday January 03, 2022 @12:01PM (#29782942)
I don't think they actually send them to baltics, as those are stolen from cars here also and they probably catch a better price in Stockholm anyway. Or sent a lot further than that.

The running "joke" is that insurers pay to put your original stuff back into car, as insurers somehow find "used" parts for mechanics.

Re:Hacking a VW Golf Power Steering ECU by carlhjerpe on Monday January 03, 2022 @12:10PM (#29783104)
The running joke is a joke indeed, we have accountability and traceability in our marvelous high-tax socialist haven, if you pay someone a significant amount it's VAT has to be tracked, parts can't just magically appear out of thin air, well maybe every now and then, but not systematically.

Edit: Especially airbags, they require special certifications to be installed and managed in Sweden, second hand airbags is NOT a thing here. Though other parts very well might be.

Re:Hacking a VW Golf Power Steering ECU by michaelt on Monday January 03, 2022 @01:02PM (#29783904)
In my country, if your car is missing (say) a wingmirror, you can go to a 'scrap dealer' who has a yard full of written off cars, and they'll sell you a wingmirror taken off a scrapped car.

There isn't any greater authority, keeping track of every car part or ensuring the number of wingmirrors leaving stock matches the number legitimately entering stock.

Re:Hacking a VW Golf Power Steering ECU by carlhjerpe on Monday January 03, 2022 @01:17PM (#29784120)
We're not talking wingmirrors, we're talking interior. And it's different for cheap stuff one could pay cash, but cars are registered when they come in to the junkyard and parts sold are declared.

I'm not saying it can't happen every now and then, but it wouldn't work systematically.

Re:Hacking a VW Golf Power Steering ECU by ugjka on Monday January 03, 2022 @11:15AM (#29782273)
Then you solve the problem in the baltics, not use it as excuse to turn your cars into "iphones"
Re:Hacking a VW Golf Power Steering ECU by natch on Monday January 03, 2022 @11:38AM (#29782592)
You really think that is a realistic goal, for the car companies to solve crime in other countries?

Just as Apple can’t prevent abusive people from having the desire to track, stalk, and creep on their own family members, I don’t think you have a practical outlook or plan here.

The manufacturers do what they can, and they deserve all our respect for that, not derision.

Re:Hacking a VW Golf Power Steering ECU by ugjka on Monday January 03, 2022 @11:55AM (#29782843)
Yet these big corporations spend billions of dollars lobbying the governments to their advantage every year. But when there is a practical problem, people like you come in here and throw their hands up "There is nothing we can do, but to lock our cars down"
Re:Hacking a VW Golf Power Steering ECU by tonyedgecombe on Monday January 03, 2022 @11:23AM (#29782384)
What are you proposing, that Sweden invades in order to stop car part theft?
Re:Hacking a VW Golf Power Steering ECU by ugjka on Monday January 03, 2022 @11:39AM (#29782605)
You know they are in the EU? Surely there are political tools to solve why there is a demand for stolen car parts in the Baltics
Re:Hacking a VW Golf Power Steering ECU by the_mitsuhiko on Monday January 03, 2022 @11:47AM (#29782736)
Just look at how many tailgates and catalysts are stolen from trucks in the US. That problem is not solvable by more law enforcement.
Re:Hacking a VW Golf Power Steering ECU by kalnins on Monday January 03, 2022 @12:07PM (#29783047)
There isn't a demand for stolen car parts. There is a demand for cheeper/used car parts. This is in part due to lower salaries combined with people wanting to buy "cool" cars that are way over their budget hence they aren't able to afford new car parts for them.
Re:Hacking a VW Golf Power Steering ECU by ugjka on Monday January 03, 2022 @12:17PM (#29783210)
And the only solution is lock our cars down and have no right to repair? And there is no question why something like this is happening within the EU? The union which is supposed to solve inequalities like this within its borders?
Re:Hacking a VW Golf Power Steering ECU by mantas on Monday January 03, 2022 @12:50PM (#29783724)
Lithuanian here.

It’s not inequality when instead of a cheap hatchback you NEED to buy BMW 5-Series or Porsche Macan. But you import a damaged one from US. And then you need a bunch of „used“ parts to repair it.

Re:Hacking a VW Golf Power Steering ECU by carlhjerpe on Monday January 03, 2022 @01:02PM (#29783892)
I mean it is inequality since the people they steal parts from can afford them, but it's not the kind of inequality we'd shed tears over.
Re:Hacking a VW Golf Power Steering ECU by mantas on Monday January 03, 2022 @02:27PM (#29785170)
Or different priorities. Why pick between a nice house and Porsche if you can repair a crashed Porsche with stolen parts and build a house paying workers under table and skipping few regulations here and there.
Re:Hacking a VW Golf Power Steering ECU by carlhjerpe on Monday January 03, 2022 @02:30PM (#29785216)
True Robin Hood, steal from the rich and give to the poor. Too bad it destroys so much capital every time.
Re:Hacking a VW Golf Power Steering ECU by carlhjerpe on Monday January 03, 2022 @11:32AM (#29782509)
Not our jurisdiction, and what could car manufacturers do?
Re:Hacking a VW Golf Power Steering ECU by ugjka on Monday January 03, 2022 @12:39PM (#29783558)
Address the problem at the EU level because both Sweden and the Baltics are in it. This what the EU is for. But obviously it is much convenient to solve this the "Apple" way and claim that there was no other way...
Re:Hacking a VW Golf Power Steering ECU by mantas on Monday January 03, 2022 @12:51PM (#29783758)
Reintroducing border control would be a good 1st step. But gods forbid movement of „goods“ is endangered :)
Re:Hacking a VW Golf Power Steering ECU by carlhjerpe on Monday January 03, 2022 @01:06PM (#29783947)
I know of no state that controls their outbound goods, so it'd be on the countries benefiting from this to get more strict, not gonna happen.
Re:Hacking a VW Golf Power Steering ECU by mantas on Monday January 03, 2022 @02:02PM (#29784799)
Here in Lithuania we’re still checking cars leaving to Belarus to make sure they ain’t stolen. Random car papers checks on Poland/Lithuania border is still a thing too. Both to make sure Porsche stolen in Berlin last night don’t end up in Moscow 24 hours later.

Unfortunately it’s hard to check every boot for stolen headlights and steering wheels without border control

Re:Hacking a VW Golf Power Steering ECU by rasz on Wednesday January 05, 2022 @08:49AM (#29808827)
You havent seen Border Control: Europe by Discovery network. Border Control: Spain in particular often shows them stopping whole lorries loaded to the gills with stolen chopped up cars trying to cross to Morocco.
Re:Hacking a VW Golf Power Steering ECU by carlhjerpe on Wednesday January 05, 2022 @09:06AM (#29809048)
I mean while you invalidate my literal point, it's things leaving the EU. State<->state is quite uncommon is what my point should be.
Re:Hacking a VW Golf Power Steering ECU by rasz on Wednesday January 05, 2022 @11:31AM (#29811083)
:) https://www.interpol.int/en/News-and-Events/News/2020/Intern...

"Involving checks at border crossing points and in-land activities in 16 EU countries and five countries in the Balkan region"

Re:Hacking a VW Golf Power Steering ECU by tyingq on Monday January 03, 2022 @11:40AM (#29782617)
This is possible, though it's essentially the same because the tools require an active "VIDA" subscription. So the ECU gatekeeps normal stuff with a high level blocker type thing. And, perhaps there are ways around it, but enough hassle to kill right-to-repair.