CVE-2021-43523
Description
In uClibc and uClibc-ng before 1.0.39, incorrect handling of special characters in domain names returned by DNS servers via gethostbyname, getaddrinfo, gethostbyaddr, and getnameinfo can lead to output of wrong hostnames (leading to domain hijacking) or injection into applications (leading to remote code execution, XSS, applications crashes, etc.). In other words, a validation step, which is expected in any stub resolver, does not occur.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Affected products
3- uClibc/uClibc-ngdescription
Patches
Vulnerability mechanics
Root cause
"Missing validation of special characters in domain names returned by DNS servers in the uClibc-ng stub resolver."
Attack vector
An attacker who controls a DNS server (e.g., through man-in-the-middle, compromised upstream resolver, or malicious network) can return crafted DNS responses containing domain names with invalid characters such as control characters, non-printable bytes, or labels that violate hostname rules. Because the stub resolver did not validate these names, the malformed hostnames would be passed to the application, potentially leading to domain hijacking, injection attacks (XSS, RCE), or application crashes [ref_id=1]. The attack requires no authentication beyond the ability to influence DNS responses seen by the victim.
Affected code
The vulnerability resides in uClibc-ng's DNS stub resolver in `libc/inet/resolv.c`. The functions `__dns_lookup`, `gethostbyaddr_r`, and related resolver functions (`gethostbyname`, `getaddrinfo`, `gethostbyaddr`, `getnameinfo`) lacked validation of special characters in domain names returned by DNS servers. The patch introduces a new validation function `__hnbad` and adds checks at multiple points in the answer processing path.
What the fix does
The patch adds a new function `__hnbad` that validates a dotted DNS name against strict character and label rules: each character must be printable ASCII (0x21–0x7E), each label must be ≤63 octets and contain only `[0-9a-zA-Z_-]`, and the first label must not begin with `-`. This function is called after decoding each answer in `__dns_lookup` and after decoding CNAME/PTR records in `gethostbyaddr_r`. If any answer fails validation, the resolver breaks out of the answer loop and, if no valid answers remain, returns `NO_RECOVERY` instead of passing the malformed name to the application [ref_id=1].
Preconditions
- networkAttacker must be able to supply or influence DNS responses seen by the victim (e.g., MITM, compromised resolver, malicious network).
- configVictim application must use uClibc or uClibc-ng before 1.0.39 and call gethostbyname, getaddrinfo, gethostbyaddr, or getnameinfo.
Generated on Jun 11, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
3- github.com/wbx-github/uclibc-ng/commit/0f822af0445e5348ce7b7bd8ce1204244f31d174mitrex_refsource_MISC
- uclibc-ng.orgmitrex_refsource_MISC
- www.openwall.com/lists/oss-security/2021/11/09/1mitrex_refsource_MISC
News mentions
0No linked articles in our index yet.