Kategorien
Brewing

NAVEE = Xiaomi – Security

Disclaimer: Educational research only. Modifying your e-scooter can be dangerous and may be illegal where you live. Also: reading this post may cause involuntary eye-rolling at firmware that still sends speed limits in cleartext.

If you followed this blog, you’ll know that Xiaomi doesn’t make scooters. It sources the scooters from manufacturers like Ninebot, LEQI and Brightway. A while back I investigated security in new Xiaomi scooters and ran case studies on two Brightway scooters: the 3Lite and 4 Pro (2nd gen)y.

Brightway doesn’t only produce scooters for Xiaomi but also for the brand „NAVEE“ – though, newer NAVEE models seem to come from another company called „SPACEWALKER PTE. LTD.“. Anyway, it was about to time that we looked into one of those NAVEE scooters, as we expect similar hardware, but different executation.

„WAIT, ISN’T THIS JUST A 4 PRO 2ND GEN?“

I decided to get myself a used NAVEE V40i (Pro) on the German Craigslist (Kleinanzeigen). Right after getting it back home, I ripped out the organs and placed them on a stick to „experiment on“.

NAVEE V40i „scooter on a stick“

As it turns out, the NAVEE V40i uses the EXACT same controller hardware as the 4 Pro (2nd gen): same MCU, same readout protection, same attack vector to dump the chip, and also, same flash layout, same REMAP trick, same DFU handshake, but… a different APP image (of course) and different IAP flashing sequence! Interesting…

The motor silicon is a EastSoft FS026R7L, Cortex-M0, 128 KiB flash @ 0x08000000. OTA packages are unencrypted. No openssl verify. No Mijia cert appendix.

0x8000000Bootloader: IAP + DFU engine
0x8003000App: FOC, limits, UART hub, …
0x801FC00„Please reboot into IAP“ flag
Flash map of NAVEE V40: same as 4 Pro (2nd gen)

AI-assisted reverse-engineering speedrun

Because of their great similarity, all the hacking techniques used in the 4 Pro (2nd gen) reverse engineering could be applied in this project. Back in the day, I used to spend months, with endless sleepless nights, tinkering on one problem. Nowadays, we can use an AI agent to boost every step in the hacking process.

For this scooter specifically, it took me two days from tear-down to a working BLE flasher. AI has made things so easy that I wonder how manufacturers will keep up with their device or IT system security. The mouse and cat race has gotten 100 times faster and currently the mice are everywhere…

Day 1:

  • SWD dump
  • Rev firmware
  • Patch ESC
  • Sniff UART
  • Formalize DFU protocol
  • Create flasher
  • Flash via UART

Day 2:

  • HCI Sniff
  • Rev BLE protocol
  • Create / update flasher
  • BLE DFU with sniffed key
  • Rev Cloud API
  • Key from Cloud API
  • Full BLE flasher

Btw, in the process of development, I find it helpful to use AI for generating documentation. This is the save point for the current and future projects!

AI-generated documentation FTW

Disclaimer: I still write my blog posts without AI. The post might not be optimized for engagement, but these are still my words. I hate nothing more than AI generated shitposts and articles filled with em-dashes, emojis and hyper-enthusiasm. Ok, what’s maybe worse is those kids who forward their shitty request to AI, let it do some magic computation, and copy the answer verbatim over to Discord or GitHub, without checking anything: „here’s how you can do it, it works 100%, just needs testing“.

Dashboard security? Nah, thanks …

We skipped talking about the dashboard and BLE module for a very specific reason: it’s mostly just a relay for UART commands.

NAVEE V40 has same BLE chip as all new Xiaomi scooters

I didn’t tear down the dashboard this time, but FCC documents reveal all we need to know: we’re dealing with a XMB1R / RTL8762C chip, presumably packaged in the MHCB05PB module (which is also a Brightway product). This module has been used across all new Xiaomi models and, due to a secure chip, encrypted BLE channel and firmware signing, made BLE based firmware flashing virtually impossible (*).

AI is great for memes tho

None of those security features can be found in this NAVEE branded scooter: BLE communication is unencrypted and firmware isn’t signed. Since the module is used across all of the Brightway-made NAVEE models, this applies to a large number of scooters. This leads to one question: If both Xiaomi and NAVEE scooter use the same hardware, why is one secure and the other not? My theory is that the security was designed and licensed by Xiaomi exclusively (and isn’t available to other vendors), since at the core of it the Xiaomi MJ1A secure chip is used.

Anyway, there’s not much to explore here. A simple BLE sniff is enough to completely reverse the auth / handshake, DFU and command protocol and create a fully functioning flasher.

(*) Whoever claims otherwise is full of shit. If you come across any videos that demonstrate phone based flashing it’s 100% fake. Point of reference: flashing takes at last half a minute.

BLE auth and NAVEE Cloud API

One piece of the puzzle remains: before the dash keeps a long-lived BLE session open, the phone has to complete a handshake. That handshake uses a shared key table and an id the dash checks before it will even issue a challenge.

The key side of things is straightforward. Phone and dash each hold the same key table and at the start they agree on which entry to use. The chosen key is used to transform a challenge, such that the dash can verify the response. But the catch is that you only get a challenge after you supply an id the dash accepts, as visualized in this high-level sequence diagram:

Vehicle bind, handshake and key storage

I spent an hour or two chasing where that id comes from, expecting a device-specific derivation or some extra algorithm. There isn’t one (**), which fits the design philosophy perfectly: “Security? Nah, thanks…”. Anyway, the more interesting question is what the dash does with it: when does it store that id and how does it decide later requests are allowed?

The answer is the bind flow, when a user first pairs the scooter with the app. During bind, the dash writes this id into BLE NVM. After
that, opening a session is mostly routine: pick a key index, complete the challenge–response, and the BLE link becomes a UART relay, forwarding traffic between the phone and the ESC MCU. Does that last part sound familiar? That’s exactly what BLE did on early Ninebot and „Xiaomi made by Ninebot“ scooters, before encryption showed up.

(**) Without naming the exact format: the id is tied to your NAVEE account, not baked into the hardware. So a successful wireless flash path assumes you can sign into that account, at least once, to establish bind.

Bottom-line

AI gave everyone the means to nuke anything. If you want to make a secure system, you have to have secure components! There’s longer any way around it. Implement firmware signing (server side), store keys on secure chips, encrypt traffic. One doesn’t have to lock everything down, but these steps alone are enough to prevent abuse.

To my surprise, NAVEE not only kept the dashboard communication and firmware unencrypted, but also the API traffic: we can follow the process of binding and unbinding devices (and everything else) in clear text. And the mechanism supposed to secure the BLE session, involving keys and an id, turned out to be hot air.

Kategorien
Brewing Hardware

Ultimate De’Longhi Dedica EC680/685 Tuning Guide

With a price of €150 the De’Longhi Dedica EC685 is by far the cheapest portafilter espresso machine one can get. It is the successor to the EC680 model with minor differences in frother and tray.

Out of the box the EC680/685, despite the overwhelmingly positive reviews, delivers horribly tasting espresso: Sour, bitter and lifeless. If you ask why there is such a discrepancy between reviews and results, I guess it’s because many reviewers simply don’t know what to expect.

With the right modifications you can get espresso shots tasting equally as good or better than in most cafe’s. The modifications come at a price: at first your espresso will taste far worse than before! But: You’ll receive the ability to tune the extraction process and hence the taste and flavor.

Necessary modifications

It’s actually very simple: Replace the basket, get a bottomless portafilter and strip the frother.

The biggest issue comes from the original pressurized baskets. Baskets found in gastronomical espresso machines have plenty of laser cut holes. The EC680/685 has exactly one hole. Because this machine uses a vibratory pump, pressure is build up by blockage of the pathway. To deliver somewhat constant pressure the basket is designed such that it forces the water through a tiny hole, this is why it’s called a pressurized basket.

So how do you achieve constant pressure without a pressurized basket? The answer is simple: By grinding your beans extremely fine, so fine, that the ground beans act as a natural counterpart for the vibratory pump. This of course comes with a plethora of new issues, but none which a true barista would mind learning to deal with.

A bottomless portafilter

DIY bottomless portafilter

This is a MUST have if you want to learn anything remotely about your coffee extraction. By opening up the portafilter you’ll get a clear glimpse at the shape and color of the extraction stream and also potential flaws in your coffee tamp.

For my project I ordered an original DeLonghi portafilter and cut down both the portafilter holder and the included basket with a Dremel tool:

Graef filter baskets

A standard recommendation for the EC680/685 are these Graef filter baskets, comparable to VST baskets on the German market. I have tested them and I do not recommend them for this machine!

One important metric for sieves is the nominal open area of the basket, i.e. the ratio between open and closed surface. If you have more or bigger holes you have more open area than with a few tiny holes. Now there are two problems with the Graef sieves: 1) The nominal open area is too large and 2) The 14g basket is missing the conic shape necessary for building up the required pressure!

So overall, you’ll not be able to reduce the extraction flow and hit the correct extraction times and yields using these baskets. The modified original basket on the other hand, both though its conic shape and smaller holes, is able to hit almost perfect extraction parameters.

Fundamentals of espresso

No matter what machine you have, without quality roasted beans you’re not going anywhere. Even though it’s temping to buy cheap beans for learning I wouldn’t recommend doing so: Uneven roasts, bean sizes and fragments all lead to an unpredictable extraction and varying results.

Now, given you have the right beans you’ll have to make sure that you understand the coffee extraction process. We have the following parameters to play with, ordered by importance:

  1. Grind size, from coarse to very fine
  2. Brew ratio
  3. Water temperature

Grind size

We’ve already learned that the grind size controls the pressure in this machine. For espresso, the finer you grind, the more area is created for the water to extract. Generally, you’ll want to go as fine as possible. We’ll get into the physics another time, for now this rule of thumb are enough to find the perfect grind setting:

  1. Grind so fine that you choke your machine (nothing comes out, machine aborts process)
  2. Set the grinder one step coarser at a time until you see a very slow but constant flow

Many people like me bought the Graef CM800 grinder together with their DeLonghi machine. This grinder has one flaw: It’s not specifically designed for espresso-grade grinds. It can, however, be „fine-tuned“, by removing the outer shell, removing the screw on the inner grinder and rotating the inner piece three steps in FINE direction (inner piece clock-wise). The effect of this is that the outer scale (the one you normally look at) gets shifted to the left: What was before the grind setting „5“ now becomes „15“. This gives you more room to work with finer grind settings. Another thing is that pressing down on the hopper while grinding helps getting a more even grind.

CM800: Move screw three steps in FINE direction to get finer grinds

If your grind and tamp are not even enough you’ll get what’s called channeling: Water under pressure seeks the path with lowest resistance, creating channels. The presence of channels the bottomless portafilter is noticeable through coffee spurts in random directions. Because the contact time of this channeled water with the coffee is almost non-existent, this water will taste sour and body-less if it makes way into the cup.

Chances are that this is what you’ve been drinking before, because with the normal portafilter defects in the tamp are invisible. Once you get a constant, single stream your tamp is free of channeling and your coffee is guaranteed to taste well.

Brew ratio

The next thing you want to set up is the brew ratio, i.e. the weight of the ground coffee beans vs. the weight of extracted coffee (including water). Don’t rely on the specs of the basket, measure the weight of the portafilter with and without the ground coffee and you have your input weight. Stay constant with your input weight, learn to always dose in the same amount without gauge.

Then, measure the weight of the cup without coffee and with coffee to get the output weight (the yield). Now divide the output weight by the input weight and you have your brew ratio. If your output weight is around two times as much as the input weight (brew ratio 1:2), voila! If not: press and hold the start button on the machine for one or two cups to program the extraction time. If you need more coffee in the cup, you need more time, if it’s too much coffee in the cup, you need less time. Adjust the time by releasing the cup button sooner (less time) or later (more time). You’re done once you hit your brew ratio for consecutive trials.

See how extraction time is not really a parameter you set. You only set up the grind size and brew ratio, extraction time is just a result. If the time, given the correct grind setting and brew ratio, is around 20 seconds, good, if not, ignore.

Water temperature

Many guides recommend 92 degrees as the extraction temperature for espresso. With the EC680/685 we have no direct control over the temperature and the temperature itself is very instable: Depending on whether it’s the first, second or third coffee in a row the temperature changes, but also across the extraction the temperature drops quickly.

The EC680/685 has the option to change the temperature from low, middle to high. After testing all settings (and doing tricks like „temperature surfing“) I recommend leaving the temperature setting untouched! While not perfect, the machine is able to produce temperatures high enough to deliver good extraction. Only one thing is extremely important: Preheating the brewing group! This is easily done by removing the portafilter and then making one cup of coffee without coffee.

There have been some studies on the importance of temperature in coffee extraction. Up to a certain point, gradually more coffee practicals get dissolved as the temperature increases. But we’re talking about minor varieties, bean/roast quality and grind size are far, far more important!

http://blog.beanbuddies.eu/wordpress/wp-content/uploads/2015/06/Coffee-in-Australia.png
Source: http://blog.beanbuddies.eu/wordpress/wp-content/uploads/2015/06/Coffee-in-Australia.png
Kategorien
Brewing

Homebrew: 2. Läutern

For the „Läutern“ (or „Abläutern“) step a „Läuterbottich“, a tub / bucket with a sieve inlay and outlet tap, is commonly used. The wort („Würze“) is transferred into the Läuterbottich and left for a defined resting time, the „Läuterruhe“. During this time the draff („Treber“) sets down onto the sieve and acts as an additional, finer natural sieve.

The wort is then cleared in two steps: 1. „Hauptguss“ (main pour) 2. „Nachgüsse“ (post pours).

  1. In the Hauptguss the first wort („Vorderwürze“) is progressively tapped off poured over the draff cake. This is repeated until the wort is clear and free of any trub, where the wort is ultimately transferred back into the brewing kettle.
  2. In the Nachguss additional water, matching the temperature of the wort, is progressively poured over the draff cake to extract the remainder of wort. The amount of water needed for the Nachguss is determined by the type of malt and target original extract of the wort („Stammwürze“). Once the draff is dry the newly won wort joins the brewing kettle.

In my first brew I wasn’t equipped with a Läuterbottich and had to rely on different containers for filtration. This has a huge downside: because the draff is exposed to air it quickly cools down – now, when the Nachguss is poured over the draff the water temperature could drop sharply, which in order would lead to a incomplete / uneven extraction.

Kategorien
Brewing

Homebrew: 1. Maischen

The first step consists of extracting the wort out of the malt. This is done under controlled temperature setpoints and defined resting times.

To control the temperature I have bought an inexpensive PID controller + solid state array and hooked it up to a hotplate (bridging the internal knob).

Four temperatures are important to hold for a certain period of time for the conversion process:

  1. 47-53°C: „Eiweißrast“ – protein gets broken up by special enzymes. Today, this step is not always necessary since in processed malts very little protein is left to begin with. And a little amount of protein is needed for good foam on the final beer!
  2. 62-65°C: „Maltoserast“ – beta-amylase enzymes get re-activated at this temperature and begin converting starch to maltose (sugar). Later on, the yeast converts this sugar to ethanol.
  3. 70-73°C: „Verzuckerungsrast“ – alpha-amylase enzymes get re-activated at this temperature and being converting starch to dextrin. The yeast can only marginally process dextrin. Dextrin leads to a sweet and full-bodied taste in the final beer.
  4. 76-78°C: „Abmaischen“ – force remaining alpha-amylase to get re-activated to convert the remainder of the starch to dextrin. Having any starch left in the wort is highly undesired since this will lead to a fatty and unpleasant taste in the final beer.

A longer Maltoserast means more maltose and therefore ethanol gets produced, leading to a stronger beer. On the other hand, a shorter Maltoserast means more starch is left for dextrin production which leads to a fuller taste. In conclusion, temperature control and timing is crucial for achieving the correct balance between maltose and dextrin, which determine the final strength and taste of the beer.

Kategorien
Brewing

Homebrew: An introduction to beer brewing

I got into beer brewing after receiving my first starter kit. Beer has a long tradition in Germany and hence the brewing process is very well understood both empirically and technically. In this post I’m going to give you a general introduction to the ingredients and process of brewing your own beer.

For brewing beer four ingredients are required:

  1. Malt: grains that have been germinated and temperature treated (germination produces enzymes which at the end get deactivated by hot temperature)
  2. Water: quality and mineral composition of the brewing water has impact on the taste (since beer consists mainly of water)
  3. Hops: plant belonging to the Cannabaceae family (the other member being Cannabis), brings the unique and bitter flavor to the beer
  4. Yeast: microorganism belonging to the Fungus kingdom, responsible for the fermentation process that converts carbohydrates / sugar to ethanol

And just like that, the brewing process can be divided into four main steps:

  1. „Maischen“: Add malt to water under a controlled temperature curve with defined resting times
  2. „Läutern“: Filter out residual malt particles, the so called draff („Treber“), from the raw yield and so called wort („Würze“)
  3. „Würzekochen“: Boil the wort and add the hop
  4. „Anstellen“: Add yeast to the wort to start the fermentation process

(Some intermediate and finish steps have been omitted, but will be explained later).