As of August 2020 the site you are on (wiki.newae.com) is deprecated, and content is now at rtfm.newae.com.

Changes

Jump to: navigation, search

Tutorial A7 Glitch Buffer Attacks

2,674 bytes removed, 13:38, 29 July 2019
no edit summary
{{Warningbox|This tutorial discusses a specific type of glitch attackhas been updated for ChipWhisperer 5 release. It shows how a simple printing loop can be abused, causing a target to print some otherwise private informationIf you are using 4. This attack will be used to recover a plaintext without any knowledge of x.x or 3.x.x see the "V4" or "V3" link in the encryption scheme being usedsidebar.}}
{{Infobox tutorial|name = Background A7: Glitch Buffer Attacks|image =This section introduces the attack concept by showing some real world examples of vulnerable firmware. Then, it describes the victim firmware that will be used in this tutorial. |caption = |software versions =|capture hardware = CW-Lite|Target Device = |Target Architecture = XMEGA/Arm|Hardware Crypto = No|Purchase Hardware = }}
== Real Firmware ==Typically, one of the slowest parts of an embedded system is its communication lines. It's pretty common to see a processor running in the MHz range with a serial connection of 96k baud. <!-- To make these two different speeds work togetheredit this, embedded firmware usually fills up a buffer with data and lets a serial driver print on its own time. This setup means we can expect to see code like<preedit Template:Tutorial_boilerplate -->for(int i = 0; i < number_of_bytes_to_print; i++){ print_one_byte_to_serial(buffer[i]);{Tutorial boilerplate}}</pre>
This is a pretty vulnerable piece of C. Imagine that we could sneak into the source code and change it to<pre>for(int i = 0; i < really_big_number; i++){ print_one_byte_to_serial(buffer[i]);}</pre>C compilers don* Jupyter file: 't care that <code>buffer[]</code> has a limited size - this loop will happily print every byte it comes across, which could include other variables, registers, and even source code. Although we probably don't have a good way of changing the source code on the fly, we do have glitches: a well'Fault_3-timed clock or power glitch could let us skip the <code>i < number_of_bytes_to_print</code> check, which would have the same resultGlitch_Buffer_Attacks.ipynb'''
How could this be applied? Imagine that we have an encrypted firmware image that we're going to transmit to a bootloader. A typical communication process might look like:
# We send the encrypted image ciphertexts over a serial connection
# The bootloader decrypts the ciphertexts and stores the result somewhere in memory
# The bootloader sends back a response over the serial port
We have a pretty straightforward attack for this type of bootloader. During the last step, we'll apply a glitch at precisely the right time, causing the bootloader to print all kinds of things to the serial connection. With some luck, we'll be able to find the decrypted plaintext somewhere in this memory dump.
== Bootloader Setup XMEGA Target ==For this tutorial, a very simple bootloader using the SimpleSerial protocol has been set up. The source for this bootloader can be found in <code>chipwhisperer/hardware/victims/firmware/bootloader-glitch</code>. The following commands are used:* <code>pABCD\n</code>: Send an encrypted ciphertext to the bootloader. For example, this message is made up of the two bytes <code>AB</code> and <code>CD</code>.* <code>r0\n</code>: The reply from the bootloader. Acknowledges that a message was received. No other responses are used.* <code>x</code>: Clear the bootloader's received buffer. * <code>k</code>: See <code>x</code>.
The bootloader uses triple-ROT-13 encryption to encrypt/decrypt the messages. To help you send messages to the target, the script <code>private/encrypt.py</code> prints See the SimpleSerial command following for a given fixed string. For example, the ciphertext for the string <code>Don't forget to buy milk!</code> is using:<pre>* ChipWhisperer-Lite Classic (XMEGA)p516261276720736265747267206762206f686c207a76797821\n* ChipWhisperer-Lite Capture + XMEGA Target on UFO Board (including NAE-SCAPACK-L1/L2 users)</pre>* ChipWhisperer-Pro + XMEGA Target on UFO Board
This folder also contains a Makefile to create a hex file for use with the ChipWhisperer hardwarehttps://chipwhisperer. The build process is the same as the previous readthedocs.io/en/latest/tutorials: run <code>make</code> from the command line and make sure that everything built properly. If all goes well, the Makefile should print something like <pre>fault_3-openadc-cwlitexmega.html#tutorial-fault-3-openadc-----------Device: atxmega128d3cwlitexmega
Program: 1706 bytes (1.2% Full)(.text + .data + .bootloader)== ChipWhisperer-Lite ARM / STM32F3 Target ==
DataSee the following for using: 248 bytes * ChipWhisperer-Lite 32-bit (3.0% FullSTM32F3 Target)(.data * ChipWhisperer-Lite Capture + .bss + .noinitSTM32F3 Target on UFO Board (including NAE-SCAPACK-L1/L2 users)* ChipWhisperer-Pro + STM32F3 Target on UFO Board
https://chipwhisperer.readthedocs.io/en/latest/tutorials/fault_3-openadc-cwlitearm.html#tutorial-fault-3-openadc-cwlitearm
Built for platform CW-Lite XMEGA== ChipWhisperer Nano Target ==
-------- end --------</pre> = The Attack Plan === The Sensitive Code == == Disassembly == = Attack Script & Results = = Ideas =* Change hex file to use BRLT* Use volatile loop variables {{Template:Tutorials}}[[Category:Tutorials]]This tutorial is not available for the ChipWhisperer Nano.
Approved_users, administrator
366
edits

Navigation menu