Skip to content

Out of bounds read in dns_copy_qname

High
ceolin published GHSA-2m84-5hfw-m8v4 Feb 25, 2025

Package

zephyr (zephyr)

Affected versions

<= 4.0

Patched versions

None

Description

Summary

The function dns_copy_qname in dns_pack.c performs performs a memcpy operation with an
untrusted field and does not check if the source buffer is large enough to contain the copied
data.

Details

The dns_copy_qname function contains a memcpy operation in line 403. The lb_size argument is read from the packet in line 377.
The function only validates the destination buffer in line 397 to ensure the buffer is large enough to contain the expected data. However, there is no validation for the source buffer.

Impact

For embedded devices with memory protection, this out-of-bound read can cause a crash and a
denial of service. For devices without memory protection, this can lead to incorrect and unexpected behaviors.

Fix Recommendation

In the target function, we can correct the size check condition (line 397) to prevent these reads from occurring. We can change the condition in line 397 to:

DNS_LABEL_LEN_SIZE + lb_size > MIN(size - *len, msg_size - pos)

Patches

main: #82072

v4.0.0: #82289
v3.7.0: #82288

For more information

If you have any questions or comments about this advisory:

embargo: 2025-02-13

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
None
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:H

CVE ID

CVE-2025-1675

Weaknesses

Credits