Multiple vulnerabilities in RT-Thread RTOS

“Security is in the mind of the programmer and in the mind of the designer.
Not so much in the code.”
— Alisa Esage

Summary

Welcome to another episode in my journey as a glorified static analysis tool for real-time operating systems!

This time, our target of choice is RT-Thread, an open-source, community-based real-time operating system (RTOS). RT-Thread can be used in sensing nodes, wireless connection chips, and many other resource-constrained scenarios. It is also widely applied in gateways, IPC, smart speakers, and other high-performance IoT applications.

I reviewed RT-Thread’s source code hosted on GitHub and identified multiple security vulnerabilities that may cause memory corruption and security feature bypass. Their impacts range from denial of service to potential arbitrary code execution.

During the source code review I also audited the lwIP and TinyDir codebases on which some RT-Thread functionalities depend, and found some additional vulnerabilities that were subsequently fixed by the respective maintainers.

My detailed advisories are available here:

Background

After my recent vulnerability disclosures, I decided to keep assisting open-source projects in the IoT space in finding and fixing security vulnerabilities by reviewing their source code. RT-Thread was selected as a target of interest. Other RTOSes will be featured in future advisories and writeups. So, stay tuned.

During this review, I made use of my Semgrep C/C++ ruleset to identify hotspots in code on which to focus my attention. I also took advantage of this opportunity to improve and update the ruleset.

Vulnerabilities

The vulnerabilities resulting from my source code review are:

For additional information about these vulnerabilities and their fixes, please refer to the detailed advisory.

Since a few months, I’ve started to consistently keep track of my research efforts using the excellent Be Focused pomodoro timer app. Therefore, I know that it took me about 32 hours to complete this project (not including the time spent for the disclosure process).

A nice graph that shows I was busy dealing with other stuff between September and October

Disclosure and fixes

I reported the vulnerabilities discussed in this article to RT-Thread in November 2023, by opening issues on GitHub as directed by the maintainers. Following my request, MITRE assigned CVE IDs to all vulnerabilities in February 2024.

RT-Thread developers have fixed some of the vulnerabilities discussed in this advisory. However, some of the reported vulnerabilities are still open. Even though not all vulnerabilities were fixed, I decided to go ahead with public disclosure after about 90 days since the initial reports. This decision was taken mainly based on the fact that the vulnerability reports were already publicly accessible as GitHub issues.

The detailed coordinated disclosure timeline follows:

  • 2023-11-12: Asked on GitHub how to report potential security issues.
  • 2023-11-13: RT-Thread founder replied to open issues directly on GitHub.
  • 2023-11-20: Opened the first issue on GitHub.
  • 2023-11-24: First vulnerability fixed; reported some other vulnerabilities.
  • 2023-11-28: Second (and third) vulnerability fixed.
  • 2023-12-24: Asked maintainers for updates.
  • 2024-01-17: Requested the first batch of CVE IDs from MITRE.
  • 2024-01-26: Informed maintainers of plan to publish advisory in February.
  • 2024-02-02: Requested the second batch of CVE IDs from MITRE.
  • 2024-02-07: CVE IDs for all reported vulnerabilities assigned by MITRE.
  • 2024-02-08: Communicated CVE IDs and new 2024-03-05 publication date.
  • 2024-02-18: Maintainers acknowledge publication date and inform about new fixes.
  • 2024-03-05: Published advisory and writeup.

Please check the official RT-Thread channels for further information about fixes.

Acknowledgments

I would like to thank RT-Thread, lwIP, and TinyDir developers for the time dedicated to triaging the reported vulnerabilities. I would also like to thank MITRE for assigning CVE IDs upon my request.

Plug

You should submit an article to Phrack! Clicky-clicky 🧑‍💻