This lecture, delivered by Roland, explores the often-overlooked security aspects of NAND Flash memory in embedded systems, challenging the common assumption that physical access to a device means compromised data.
The first part demystifies Flash technology, explaining its fundamental cell structure, evolution from Single Level Cell (SLC) to Multi-Level Cell (MLC, TLC, QLC) for increased density, and the aging processes that affect data retention and endurance. Key concepts like the Flash Translation Layer (FTL), wear leveling, garbage collection, and write amplification are detailed, highlighting their impact on performance and longevity. The second part delves into embedded security, using the Raspberry Pi as a prime example to demonstrate how easily sensitive data can be extracted or manipulated via physical access to standard SD/eMMC cards. Roland then introduces advanced security features available in specialized Flash memory, such as challenge-response authentication, crypto-based deletion, and granular access control for partitions. He illustrates how these features enable "Defense in Depth" for embedded systems, providing robust protection against physical attacks, ensuring data confidentiality and integrity even when the storage medium is removed from the device.
Exploring Flash Memory Security in Embedded Systems
0:39 Introduction to Flash Security: Roland introduces the topic of securing embedded systems using NAND Flash memory, highlighting capabilities unknown to many, including himself until recently, and aims to dispel misconceptions about data security when memory cards are physically accessible.
1:22 Understanding Flash Basics: The presentation is structured into three parts:
What is Flash? Details foundational concepts like pages, blocks, wear leveling, and overprovisioning, and explains why flash memory degrades over time.
Embedded Security: Discusses attack vectors and assets that need protection in systems like the Raspberry Pi.
Security Features: Explores how security-enabled Flash memory can counter these attacks with practical examples.
2:45 Ideal Flash Memory Characteristics: Roland outlines desirable traits for perfect flash memory, including low cost per gigabyte, high density, fast read/write speeds, low power consumption, wide temperature range operation, eternal endurance, and for industrial/security applications: authenticity verification, restricted access, and secure data deletion.
5:04 Flash Cell Physics: A flash cell stores information persistently using a "floating gate" surrounded by an insulator. Applying voltage allows charge carriers (electrons/holes) to be trapped or removed, changing the channel's conductivity for reading.
8:35 Evolution of Flash Memory: Flash has evolved from 2D Single Level Cell (SLC) storing 1 bit per cell to Multi-Level Cell (MLC), Triple Level Cell (TLC), and Quad Level Cell (QLC) storing 2, 3, or 4 bits per cell, respectively, and from 2D to 3D stacking (over 200 layers) to increase density. This miniaturization reduces charge differences, making cells more prone to errors and aging.
13:46 Challenges of Multi-Level Cells: Storing multiple bits per cell leads to smaller voltage differences between states, making reading more difficult and requiring extensive error correction code (ECC) bits, which increases read/write times (though compensated by faster controllers).
14:35 Flash Aging and Data Retention: Flash memory ages due to insulator breakdown and charge leakage, blurring the distinct states required for reading. This is critical as few electrons (e.g., 4-5 for MLC) might differentiate states. Regular powering up and data refresh (e.g., using dd command) can help maintain data integrity in stored SSDs.
17:05 Industrial Needs vs. Consumer Flash: Industrial applications demand long-term availability (10-30 years) and high endurance, which traditional SLC provided but is now scarce and expensive. Pseudo-SLC (PSLC) mode on MLC/TLC flash uses redundancy to mimic SLC's robustness, offering better data retention and endurance at a higher cost than standard consumer flash.
Pages: The smallest writable unit (e.g., 4KB). Pages can be "invalidated" (marked as old data) but not individually deleted.
Blocks: Pages are organized into blocks, which are the smallest erasable unit. Erasing blocks causes aging.
Flash Translation Layer (FTL): A crucial component (software in the controller) that maps logical addresses from the operating system to physical blocks and pages, manages wear leveling, and garbage collection.
26:59 Write Amplification Factor (WAF): Writing to flash is complex. Modifying even a single bit often requires copying a full page to a new location, invalidating the old one. This leads to a Write Amplification Factor (WAF > 1), meaning more data is physically written to the flash than requested by the host. Sequential writes (e.g., video recording) have a WAF near 1, while random, small writes (e.g., OS logging on a Raspberry Pi) result in a very high WAF (10-100x), accelerating flash aging and necessitating wear leveling and garbage collection.
33:55 Flash Communication with Host Systems: Standard SD/eMMC cards use physical interfaces (SPI, 4/8-bit parallel bus). USB card readers often abstract these commands into SCSI, limiting access to advanced card features (e.g., card ID, security functions). Direct communication (e.g., via Raspberry Pi's internal SD slot or dedicated hardware) is needed for full control.
38:00 Embedded System Vulnerabilities: Roland focuses on physical attacks, where an attacker has direct access to the device. Common embedded systems like the Raspberry Pi, using standard SD cards, are highly vulnerable.
38:48 Raspberry Pi Password Hacking Example: An attacker can easily remove the SD card, mount it on another Linux system, and overwrite the hashed password in etc/shadow. This grants full access, allowing the attacker to install malicious services, read sensitive data (e.g., VPN credentials, cloud identifiers, privacy data), or compromise connected backend systems.
45:39 Countermeasures: Flash Security Features: "Defense in Depth" is proposed, extending security to the lowest hardware level.
Protection Goals:
Confidentiality: Prevent unauthorized data readout.
Integrity: Prevent unauthorized data modification.
Authenticity: Verify the legitimacy of the storage medium itself and its data.
Limitations of Physical Switches: The physical write-protect switch on SD cards is often ineffective as it's only a reader-side feature, easily bypassed.
Advanced Features: Secure Flash cards offer features like Replay Protected Monotonic Counters (RPNB), Card ID (CID) registers, crypto-based deletion (by deleting the encryption key), integrated Secure Elements for hardware-hardened cryptographic functions (e.g., True Random Number Generators), and sophisticated Access Control mechanisms.
Raspberry Pi (Confidentiality & Integrity): A secure SD card can be configured so the boot partition is read-only and public, while other sensitive partitions are private and require authentication (e.g., via a bootloader-level PIN) to become visible and writable. This prevents external data readout or modification.
Arduino/ESP Cam (Confidentiality or Integrity): For data logging or image capture, a secure card can have a data partition set to "flexible write-only" (writable by the system after login, otherwise read-only) or "private write" (invisible until authenticated). This significantly increases the difficulty of data exfiltration or manipulation compared to standard cards.
Long-term data retention on standard flash requires regular power-ups/refreshes.
Specialized flash memory offers significant security features often unknown to users.
Flash security is a critical layer in a "Defense in Depth" strategy for embedded systems.
Generic USB readers limit access to advanced flash features.
Cybersecurity demands for embedded systems can be met by leveraging these secure flash solutions, often without major hardware redesigns.
58:40 Availability and Cost: Secure SD cards are available but are typically priced higher than consumer-grade cards due to their advanced features and industrial-grade reliability. Some security features (like locking/unlocking) are standardized but not universally supported by all cards.