Due to the combination of the command injection in the imagebuilder image and the truncated SHA-256 hash included in the build request hash, an attacker can pollute the legitimate image by providing a package list that causes the hash collision. The issue consists of two main components:
1. Command Injection in Imagebuilder: During image builds, user-supplied package names are incorporated into make commands without proper sanitization. This allows malicious users to inject arbitrary commands into the build process, resulting in the production of malicious firmware images signed with the legitimate build key.
2. Truncated SHA-256 Hash Collisions: The request hashing mechanism truncates SHA-256 hashes to only 12 characters. This significantly reduces entropy, making it feasible for an attacker to generate collisions. By exploiting this, a previously built malicious image can be served in place of a legitimate one, allowing the attacker to “poison” the artifact cache and deliver compromised images to unsuspecting users.
Combined, these vulnerabilities enable an attacker to serve compromised firmware images through the attended.sysupgrade service, affecting the integrity of the delivered builds.
The issue got assigned CVE-2024-54143.
An attacker needs the ability to submit build requests containing crafted package lists. No authentication is required to exploit the vulnerabilities. By injecting commands and causing hash collisions, the attacker can force legitimate build requests to receive a previously generated malicious image.
An attacker can compromise the build artifact delivered from the sysupgrade.openwrt.org, allowing the malicious firmware image to be installed to the OpenWrt installation that uses the attended firmware upgrade, firmware-selector.openwrt.org, or attended.sysupgrade CLI upgrade.
Fixed in following commits:
All versions of the attended.sysupgrade server that rely on truncated hashes and do not sanitize package input in the imagebuilder step are affected. Specifically this means versions between rewrite to fastapi and chore: cleanups and OpenWrt One as default.
This issue was identified and responsibly disclosed by security researcher RyotaK, Flatt Security Inc.