GHSA-v97j-w9m6-c4h3: Buffer overflows in RIOT
RIOT is a real-time multi-threading operating system that supports a range of devices that are typically 8-bit, 16-bit and 32-bit microcontrollers. The size check in the gcoapdnsserverproxyget() function contains a small typo that may lead to a buffer overflow in the subsequent strcpy(). In detail, the length of the uri string is checked instead of the length of the proxy string. The gcoapforwardproxycopyoptions() function does not implement an explicit size check before copying data to the cep->reqetag buffer that is COAPETAGLENGTHMAX bytes long. If an attacker can craft input so that optlen becomes larger than COAPETAGLENGTHMAX, they can cause a buffer overflow. If the input above is attacker-controlled and crosses a security boundary, the impact of the buffer overflow vulnerabilities could range from denial of service to arbitrary code execution. This issue has yet to be patched. Users are advised to add manual bounds checking.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
Add manual bounds checking in `_gcoap_forward_proxy_copy_options()` before copying data to the `cep->req_etag` buffer, ensuring the input length does not exceed `COAP_ETAG_LENGTH_MAX`; also correct the length check in `gcoap_dns_server_proxy_get()` to validate the `_proxy` string before the subsequent `strcpy()`.