eCos Offensive Security Research Logbook
Quentin Kaiser (Security Researcher · IoT Inspector Research Lab)
BruCON 0x0D · Day 1
Overview
This talk, "eCos Offensive Security Research Logbook," presented by Quentin Kaiser, delves into a comprehensive year-long journey of offensive security research targeting eCos, a widely deployed, free, and open-source real-time operating system (RTOS). Kaiser shares the tools, techniques, and methodologies he developed to analyze, exploit, and gain persistence on embedded devices running custom branches of eCos, primarily focusing on Broadcom-based cable modems. The presentation serves as a detailed guide for other researchers to reproduce and extend this work on new targets.

Key moments
- 0:00 Introduction to eCos & Research Plan
- 2:00 eCos: What it is & Security Research History
- 11:30 Automated Firmware Extraction Techniques
- 22:30 Understanding eCos Runtime Memory Map
- 23:15 Memory Corruption Vulnerabilities Found
- 28:00 Live Demo: Gaining a Reverse Shell
- 37:00 Persistence Demo: Booting Implanted Firmware
- 44:00 Q&A: Future Research on OT Devices
eCos Offensive Security Research Logbook
Speakers: Quentin Kaiser, Security Researcher, IoT Inspector Research Lab
Conference: BruCON
YouTube: https://www.youtube.com/watch?v=K1FVf2xta-4
Overview
This talk, "eCos Offensive Security Research Logbook," presented by Quentin Kaiser, delves into a comprehensive year-long journey of offensive security research targeting eCos, a widely deployed, free, and open-source real-time operating system (RTOS). Kaiser shares the tools, techniques, and methodologies he developed to analyze, exploit, and gain persistence on embedded devices running custom branches of eCos, primarily focusing on Broadcom-based cable modems. The presentation serves as a detailed guide for other researchers to reproduce and extend this work on new targets.
The significance of this research cannot be overstated. Despite being a decade old since its last public release, eCos powers an astonishing array of devices, from consumer electronics like PlayStation wireless chipsets and networking gear (routers, switches) to critical industrial control systems (PLCs), payment terminals, and even satellite and missile launcher controllers. The pervasive nature and often critical functions of these devices, combined with eCos's inherent lack of modern security mitigations, make it a high-value target for offensive research. Kaiser's work moves beyond mere denial-of-service (DoS) attacks, demonstrating full remote code execution (RCE) and long-term persistence, highlighting severe risks for infrastructure relying on eCos.
Quentin Kaiser, a security researcher at IoT Inspector Research Lab, brings a wealth of experience in binary analysis and embedded device exploitation to this topic. His prior work on FreeLtech SDK, Broadcom SDK, and Cisco advisories underscores his expertise in uncovering deep-seated vulnerabilities in low-level systems. This talk condenses his extensive eCos research, providing a battle-tested framework for extracting, analyzing, and exploiting eCos firmware, ultimately aiming to improve the security posture of these often-overlooked devices.
Background
▶ Watch: Introduction to eCos & Research Plan (0:00)
eCos, short for "embedded configurable operating system," is a free and open-source Real-Time Operating System (RTOS) primarily implemented in C and C++, with some components in pure assembly. Its architecture is based on a single process with multiple threads, providing a lightweight and efficient environment suitable for resource-constrained embedded systems. eCos boasts broad architectural support, including ARM, MIPS, SuperH, and SPARC, contributing to its widespread adoption across diverse device categories. Its deployment footprint is vast, encompassing consumer electronics (e.g., wireless chipsets in PlayStations), networking equipment (routers, switches), industrial devices (PLCs), payment systems (smart card readers), and even high-stakes applications like satellites and missile launcher controllers. The last public release of eCos was nearly 10 years ago, yet its legacy continues, with many existing devices remaining in service, often with outdated or custom firmware.
The history of eCos security research, as depicted by Kaiser, can be divided into distinct eras. The "early days" (1998-2009) coincided with successive eCos releases but saw little public security scrutiny. Starting around 2010, reports of stack overflows affecting cable modems running Broadcom's eCos version 2 began to surface. These early findings, however, typically only demonstrated the risk of denial of service (DoS), with proof-of-concepts merely crashing devices rather than achieving full control. This period roughly aligns with Broadcom's introduction of cable modem packages based on eCos v2 in 2009.
A significant turning point came in 2016 with the publication of dedicated reversing tools: one for extracting firmware from eCos-based Broadcom devices and another for extracting file systems from firmware images. However, eCos-focused offensive security research truly gained momentum with the release of the "Cable Haunt" paper in 2020 by Liao Board. This seminal work demonstrated remote command execution (RCE) on eCos devices, specifically Technicolor and Sagemcom cable modems, marking a shift from DoS to full system compromise. Inspired by Cable Haunt, Quentin Kaiser subsequently released his own research papers in 2021, targeting Netgear devices deployed by VOO in Belgium and ASKEY devices deployed by Orange Belgium, further expanding the scope of known eCos vulnerabilities and exploitation techniques. The continued relevance of eCos in critical infrastructure, coupled with its age and the absence of modern security features like Address Space Layout Randomization (ASLR) or Data Execution Prevention (DEP), makes it a fertile ground for offensive security research.
Key Findings
▶ Watch: Automated Firmware Extraction Techniques (11:30)
Quentin Kaiser's research yielded several key findings and methodologies for tackling the security of eCos-based embedded systems:
- Advanced Firmware Extraction Techniques: Kaiser developed and refined methods for extracting custom eCos firmware from devices where downloads are unavailable. He utilized
bcm2utools, specificallybcm2dump, which leverages a hidden memory command over the CLI or, more robustly, patches bootloader instructions at runtime. The latter technique, while more complex, drastically reduces extraction time from 7 hours (via console commands) to just 30 minutes, enabling faster iteration. This involves crashing the bootloader to identify its RAM mapping, disassembling it to find critical read functions (spi_flash_read,non_flash_read), and crafting device profiles forbcm2dump.
- Comprehensive Firmware Analysis Toolkit: Addressing the challenge of analyzing eCos binaries without symbols or memory mappings, Kaiser created a suite of tools and techniques:
- Function ID Databases (FIDB): By compiling the GPL-licensed eCos source code with debug symbols, he generated FIDBs for tools like Ghidra, allowing the automatic identification of over 1200 standard library functions across 26 libraries.
- Automated Function Renaming: Leveraging the abundance of logging and tracing calls within firmware that often include function names (e.g.,
non-flash read: blah blah), he developed scripts to extract these names and rename the corresponding functions in the disassembler. - C++ VTable Identification: For C++ heavy firmware, he identified and renamed C++ virtual tables (vtables), inferring class names and setting appropriate calling conventions (e.g.,
thiscall), which significantly aids in understanding object-oriented structures and inheritance. - Automated Memory Mapping Reconstruction: He devised methods to precisely map runtime memory regions (text, data, BSS, stack, heap) by analyzing program store headers, identifying unique string patterns (
BCM0), disassembling key eCos functions (rc_zero_bss), and tracing thread creation calls (cyg_thread_create).
- Prevalence of Memory Corruption Vulnerabilities: Kaiser confirmed that eCos devices are highly susceptible to classical memory corruption bugs, primarily stack overflows and heap overflows. He demonstrated several instances, including
strcpyvulnerabilities in web administration interfaces (parental control pages of Netgear and ASKEY devices) and unsafe copies of HTTP header values into heap-allocated structures. Crucially, the absence of modern exploit mitigations like ASLR, DEP, or even memory page permissions (all memory regions are RWE – Read, Write, Execute) makes these vulnerabilities trivially exploitable for arbitrary code execution.
- Robust Shellcode Development Framework: Given the lack of traditional
system()orexecve()syscalls in eCos, Kaiser developed a method for building custom shellcode using the GCC linker. This approach, inspired by previous research, involves creating platform-specific linker definitions that map known eCos POSIX-like API functions (e.g.,bind,connect,malloc,memcpy) to their runtime addresses. This enables the creation of fully functional reverse and bind shells that interact directly with the eCos console via a singleton object (BroadcomConsole).
- Achieving Long-Term Persistence: The research demonstrated that long-term persistence is readily achievable on eCos devices due to the absence of secure boot implementations or firmware signature checking. By identifying non-essential functions called during boot (e.g., an unused IPsec handler) and overwriting their code segments with custom shellcode, Kaiser successfully created firmware implants. These implants could then be uploaded via built-in TFTP update commands, ensuring the shellcode executes on every boot, providing a persistent backdoor. The same principles apply to creating bootkits by modifying the bootloader.
Technical Deep Dive
▶ Watch: Memory Corruption Vulnerabilities Found (23:15)
The technical depth of Kaiser's research is evident in his methodical approach to each stage of offensive security.
Firmware Extraction and Analysis
Extracting firmware from target devices, often managed by ISPs, presents the initial hurdle as images are not publicly available. Kaiser leverages bcm2utools, specifically the bcm2dump utility, designed for Broadcom cable modems. This tool can operate in two modes. The simpler method relies on an exposed CLI mem command, using show under the flash menu to gather memory maps (offsets, sizes) for SPI flash (bootloaders, NVRAM) and NAND flash (Image 1, Image 2). This information is then compiled into a device-specific profile.
When CLI access is restricted, a more advanced technique is employed: patching bootloader instructions at runtime. This requires first acquiring the bootloader dump. Kaiser achieves this by intentionally crashing the device (e.g., writing a dummy instruction to an arbitrary address and jumping to it) and observing the return address on the serial console, which reveals the bootloader's RAM mapping. The raw dump is then cleaned (removing null bytes before and 0xffs after). With the clean bootloader loaded into Ghidra (MIPS 32-bit big-endian), Kaiser uses debug strings (e.g., "non-flash read") to identify critical functions like non_flash_read and spi_flash_read. A r2pipe script automates the extraction of these function offsets, which are then integrated into the bcm2dump profile. This patching method, while more involved, reduces firmware dumping time from 7 hours to approximately 30 minutes.
Once extracted, firmware images are often packed in a Program Store (PS) image format, a custom Broadcom wrapper. The PS header contains crucial information, including the program load address (essential for Ghidra) and a CRC. The actual binary content is typically LZMA compressed. Broadcom conveniently released the source code for its PS utility as part of its Zephyr RTOS initiative, which Kaiser utilizes to unpack and repack firmware images.
Loading the unpacked binary into Ghidra as a MIPS 32-bit big-endian image with the correct load address is only the first step. The lack of symbols is a major impediment. Kaiser addresses this by generating Function ID Databases (FIDB). He compiles the GPL-licensed eCos source code (often requiring specific, decade-old GCC versions and patches, run in a CentOS VM) with debug symbols. These FIDBs, containing over 1200 function signatures from 26 standard libraries, are then applied to the target firmware in Ghidra, automatically identifying a large portion of standard library functions.
Further symbol recovery is achieved by exploiting common firmware development practices. Many firmware images include function tracing and logging calls that embed the function's name as a parameter. Kaiser identified four distinct logging function types and developed scripts to extract these names and rename the calling functions. For C++ heavy firmware, these extracted names often follow the ClassName::FunctionName convention, which allows him to infer class structures, set the thiscall calling convention (making the this pointer point to the vtable), and rename vtables (e.g., ptr_fun_something becomes ClassName::Vtable). Collectively, these methods identify approximately 10% of functions in a typical Broadcom eCos firmware, significantly improving readability.
Memory Mapping and Vulnerabilities
Understanding the runtime memory map is critical for exploitation. Kaiser’s automated approach precisely identifies key segments:
- Text Segment: Always mapped at the program load address, extracted from the PS header.
- Data Segment: Starts with a characteristic string,
BCM0(the first network interface name), and ends with thousands of null bytes, making it easily identifiable via string matching. - BSS Segment: Zeroed out on boot by the
rc_zero_bssfunction. In MIPS assembly (vectors.s), this function loads the start address into registera0and the end address intoa1. Crucially, Kaiser found that the BSS segment is consistently located at the same offset across all Broadcom eCos firmware images, regardless of vendor. Disassemblingrc_zero_bssat this fixed offset reveals the exact BSS start and end addresses (e.g., Netgear:0x816168c8to0x81b52570). - Stack: The base address of the system stack is the base address of the first thread launched,
t_startup. This thread is created usingcyg_thread_create, which takes the thread name and stack base address as parameters. By cross-referencing thet_startupstring, the stack base address can be extracted. The stack grows upwards. - Heap: Immediately follows the BSS segment. The heap grows downwards.
A critical finding is that all these memory regions are Read, Write, Execute (RWE). There are no permission flags on memory pages, no execute bits, no ASLR, and no DEP. This lack of modern memory protections makes classical memory corruption vulnerabilities highly exploitable.
Kaiser demonstrated several such vulnerabilities:
- Stack Overflow (Netgear): A classic
strcpyinto a fixed-size buffer on the stack, triggered via the parental control page of the web administration interface by sending a longtext_blockparameter. - Stack Overflow (ASKEY TCG 300): Another
strcpyvulnerability, also in the parental controls page, where the length of untrusted user input was incorrectly computed, leading to overflow. Requires authentication. - Heap Overflow: Parsing HTTP requests line-by-line, an unsafe copy of a header value (e.g.,
Host) into a heap-allocated structure. Easily triggered by sending a longHostheader.
When these bugs are triggered, the custom crash handler dumps register values (including the program counter, which shows 0x41414141 in case of AAAA overflow), program context, and thread details over the serial connection, aiding exploit development.
Exploitation and Persistence
Given the limited debugging capabilities (only register dumps on segfaults), Kaiser advocates for a two-stage ROP chain approach, inspired by Liao Board's Cable Haunt. A small "stage one" ROP chain takes control of the program counter, establishes a network connection to a remote server, pulls a larger "stage two" payload, writes it to memory, and jumps to it. The key innovation is reusing the same socket file descriptor for both payload delivery and the subsequent reverse shell, achieved by saving the socket FD integer value to a fixed, known memory address (sock_fd_addr).
Building the actual shellcode is complex due to the absence of system() or execve(). Kaiser outlines two methods: manual function hooking (prone to errors) or, preferably, using the GCC linker. This linker-based approach involves creating a custom Makefile and linker definition file for each platform (e.g., Netgear, ASKEY). The linker definition provides the exact runtime addresses of necessary eCos POSIX-like APIs (e.g., bind, connect, select, malloc, memcpy), allowing GCC to link the shellcode correctly. The shellcode is compiled to a specific memory offset, ensuring correct jump calculations.
The reverse shell implementation involves opening a socket, connecting to the C2, allocating a buffer, and then redirecting standard I/O. This is done by interacting with a BroadcomConsole singleton object, calling methods like set_io to point to the socket's file descriptor and execute_current_command to process commands received from the C2. An exit call reassigns I/O to the original handler. Kaiser also demonstrated a more complex threaded shellcode, leveraging eCos APIs (cyg_thread_create) to manage separate threads and heap allocations within the shellcode.
For long-term persistence, eCos devices offer significant opportunities due to the complete lack of secure boot or firmware signature checking. As long as the firmware's CRC matches, the platform will execute it. Built-in download and save commands (e.g., ipl over LAN, docsis_ctl over coaxial) facilitate firmware updates via TFTP. Kaiser's approach to firmware implants involves identifying a non-essential function called on boot that launches a thread (e.g., an unused IPsec handler). He then overwrites this function's code segment within the firmware with his custom shellcode, repacks the firmware, and uploads it. This ensures the implant executes on every boot. A bootkit approach, modifying the bootloader itself, is also entirely feasible under these conditions.
Demo / Proof of Concept
▶ Watch: Live Demo: Gaining a Reverse Shell (28:00)
Kaiser provided compelling live demonstrations of both remote code execution and long-term persistence on a Netgear cable modem.
In the RCE demonstration, he connected to a Netgear device over LAN. With a successful exploit, he established a reverse shell on the device. The demo showed interaction with the device's console menu, highlighting access to various features such as editing routing rules, retrieving credentials, performing monitoring, and even injecting custom shellcode at runtime using built-in memory read/write commands. This effectively demonstrated full control over the device, akin to gaining root access on a Linux server. He noted that while the exploit is public, the specific payload was not, preventing direct reproduction of the full shell functionality.
For persistence, Kaiser showcased a device rebooting from a specially crafted firmware image. He connected to the device via a serial connection to observe the boot process. The device was configured to boot from "Image 2," which he had previously implanted with his shellcode, naming it implant.oh. During the boot sequence, the device loaded Image 2. Although the debug output for the bind listener was too fast to fully observe, upon successful boot, he demonstrated connecting to the device over LAN and obtaining a bind shell. This confirmed that the implanted shellcode was executing automatically and persistently, providing continuous access to the device without re-exploitation.
These demonstrations underscored the practical impact of his research, moving from theoretical vulnerabilities to tangible, exploitable outcomes with lasting implications.
Defensive Implications
▶ Watch: Q&A: Future Research on OT Devices (44:00)
Quentin Kaiser concluded his talk with crucial recommendations for various stakeholders to mitigate the risks posed by eCos vulnerabilities:
For ISP Customers:
- Disable Guest Wi-Fi: Existing research (including Kaiser's own on Netgear and ASKEY devices) shows that heap overflows can be exploited by unauthenticated users connected to guest Wi-Fi networks. Disabling this feature removes a significant attack vector.
- Use Non-Default Settings for PSK and SSIDs: Default Pre-Shared Keys (PSKs) and Service Set Identifiers (SSIDs) can be derivable or used as oracles in certain exploitation scenarios, particularly on Netgear devices. Customizing these settings enhances security.
For Internet Service Providers (ISPs):
- Conduct Complete and In-depth Penetration Tests: The cost of a large-scale breach or widespread exploitation far outweighs the cost of thorough security testing. Kaiser cited an example where vulnerability remediation for VOO took nine months of dedicated effort and significantly impacted their helpdesk operations.
- Consider Device Manufacturer Support: ISPs must evaluate the long-term support provided by device manufacturers, especially regarding end-of-life (EOL) policies and the ability to fix critical bugs in code. Many eCos devices are old, and patches may be impossible to deploy or even develop.
For Manufacturers (Netgear, ASKEY, etc.):
- Disable the Crash Handler: The current crash handler provides valuable debug information (register dumps, program counter) to exploit writers. Disabling or obfuscating this output would significantly increase the difficulty of crafting reliable exploits, forcing attackers to rely on "pen and paper" ROP chain development.
- Conduct Source Code Reviews (SCA): Static Code Analysis (SCA) tools are increasingly affordable and effective. Regular reviews can identify common memory corruption vulnerabilities before devices are deployed.
- Use Strong Default Passwords, Protocols, and Ciphers: Hardening default configurations reduces the attack surface and prevents easy compromise.
- Provide Long-Term Support or Explicit Agreements: Manufacturers should be transparent about device support lifecycles and commit to fixing security vulnerabilities, or at least clearly communicate when devices will no longer receive security updates.
- Cryptographically Sign Firmware: While acknowledged as unlikely for this platform, implementing cryptographic signing for firmware updates would prevent unauthorized modifications and block the deployment of malicious implants.
For Broadcom:
- Conduct Source Code Review: As a foundational provider of eCos-based chipsets, Broadcom should conduct rigorous source code reviews for its eCos implementations.
- Harden IP Manager: (A humorous but pointed suggestion) The internal IP management processes should be more robust.
- Investigate Secure Boot for Newer RTOS: Broadcom is already reportedly working on secure boot for newer RTOS like Zephyr, and this focus should be maintained and extended where possible to legacy platforms if feasible.
Key Takeaways
- eCos is a Pervasive and Insecure RTOS: Despite its age (last public release nearly a decade ago), eCos is widely deployed in critical infrastructure, consumer electronics, and industrial systems, often lacking modern security mitigations like ASLR, DEP, and memory page permissions.
- Comprehensive Reverse Engineering is Essential: Due to the absence of symbols and memory mappings, advanced techniques for firmware extraction, function ID database generation, automated renaming via logging calls, C++ vtable identification, and precise memory mapping reconstruction are crucial for effective analysis.
- Memory Corruption Leads to RCE: Classical vulnerabilities like stack and heap overflows are prevalent in eCos-based firmware. The complete lack of exploit mitigations makes these bugs trivially exploitable for arbitrary code execution and full device compromise.
- Custom Shellcode Development is Achievable: Standard syscalls for command execution are absent, but custom shellcode can be effectively developed using the GCC linker, leveraging platform-specific API addresses to create functional reverse and bind shells that interact with the eCos console.
- Persistence is Easily Gained: The absence of secure boot and firmware signature verification allows attackers to achieve long-term persistence through firmware implants or bootkits by overwriting non-essential functions or the bootloader itself with malicious code.
- Immediate Action is Required: Customers, ISPs, and manufacturers must take proactive steps—from disabling guest Wi-Fi and conducting thorough penetration tests to implementing source code reviews and hardening default configurations—to address the widespread insecurity of eCos-powered devices.
About the Speaker(s)
Quentin Kaiser is a security researcher at IoT Inspector Research Lab. Prior to this role, he spent six years working as a consulting penetration tester, gaining extensive experience in offensive security. His career path took a turn during a sabbatical, where he developed a passion for binary analysis, leading him to his current specialization. At IoT Inspector Research Lab, Kaiser focuses on the binary exploitation of embedded devices and the automation of bug findings within large firmware blobs. His notable research contributions include work on the FreeLtech SDK, Broadcom SDK, and a Cisco advisory. His expertise lies in uncovering deep-seated vulnerabilities in low-level systems and developing practical exploitation techniques.
Reviews
- Dr. Zero (Offensive Security Researcher) — MUST SEE ★★★★★