Lab 1 - Scan Chain Attacks

2026-01-12  |  Hackster , Labs , Scan Chain , Side Channel , Cryptography

Introduction

Scan chains are a crucial part of modern integrated circuit (IC) testing and debugging. They are used in Design-for-Testability (DfT) techniques to facilitate easier testing of digital circuits, particularly complex System-on-Chip (SoC) designs. A scan chain is essentially a series of flip-flops connected in a shift register-like configuration, allowing for internal circuit states to be accessed externally. This helps in diagnosing manufacturing defects by shifting test patterns (test vectors) into the circuit and reading out responses.

However, while scan chains are valuable for testing, they can also introduce a security vulnerability. Scan chain attacks exploit these test mechanisms to extract sensitive information from chips, such as cryptographic keys. Since scan chains expose internal states, an attacker with access to scan-out data can reconstruct secret information by analyzing the circuit’s responses to controlled inputs. In this lab, you will learn about scan chains and try attacking one implemented for you on the Hackster platform.

Goals:

  1. Understand the basics of a scan chain attack on cryptographic hardware a. Interact with the scan chain in the custom hardware provided for you b. Identify basic data elements within the target scan chain (e.g. input register, SPI register, control registers, encryption round registers).
  2. Perform a complete scan chain attack on an AES IP block to steal intermedia values from the encryption rounds.
  3. Use the intermediate values obtained from the scan chain attack to perform a simple key recovery attack on the AES implementation.
  4. Implement a defense of your choice to mitigate the basic scan chain attack and demonstrate its effectiveness.

Getting Started

  1. Do a git pull to get the latest version of the lab materials.
  2. Open up the examples/spi_aes_scan/ project
  3. Load the example bitstream onto the fpga with make run_fpga, this contains a bitstream with a known AES key (0x2b7e151628aed2a6abf7976676151301).
  4. Using the provided spi_aes_scanchain.py MicroPython script for the AppMicro, encrypt and then decrypt some data.
  5. Now, modify that script. After loading the value to encrypt using NORM_CS_N as before, add new code to use the SCAN_CS_N pin to put the core into scan mode and then shift out the values in the scan chain. You should be able to see the value you’ve just loaded to the SPI, as well as some other registers.
  6. Modify your code again to shift in and out the values of the scan chain at every clock cycle during the IP’s operation. This will allow you to see the intermediate values of the encryption rounds, which are the most useful for the attack.
  7. This IP does not have a randomised scan chain, so you could now follow the instructions from the “scan chain attack” section of the paper by Bo Yang et al. to perform a key recovery attack using the intermediate values you obtained from the scan chain.
  8. When you are ready to proceed, download lab01_scan_files.zip from Moodle and extract it. This zip file contains the unique AES IP file for you to attack, as well as a template for the csv file you need to fill out for the attack. You’ll just be attacking your own [zID].bin file, so make sure to use the correct one for your zID.
  9. You will now need to identify the scan chain order in your unique AES IP file and fill out the csv file, before writing your attack code to extract the intermediate values and perform the key recovery attack.
  10. Once you have completed your attack, you can start working on your defense. You can choose any defense mechanism you like (preferably one we taught in class), but it should be effective against the basic scan chain attack you performed in this lab. Build it into the code provided.
  11. Finally, write up your summary and submit all your files in a zip file on Moodle according to the instructions below.

Deliverables and Weightings:

This lab is worth 10% of your final grade for this course.

Resources

Grading Rubric

Attack (6%)

Defense (4%)