Skip to content

Bluetooth: classic: avdtp: missing buffer length check

High
ceolin published GHSA-r7pm-f93f-f7fp Dec 15, 2024

Package

zephyr (zephyr)

Affected versions

<=3.7

Patched versions

None

Description

Summary

No proper validation of the length of user input in bt_avdtp_l2cap_recv in zephyr/subsys/bluetooth/host/classic/avdtp.c.

Details

There is no length check before pulling data from net_buf.

bt_avdtp_l2cap_recv:

int bt_avdtp_l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
{
	struct bt_avdtp_single_sig_hdr *hdr;
	struct bt_avdtp *session = AVDTP_CHAN(chan);
	uint8_t i, msgtype, pack_type, sigid, tid;

	/* Check the buffer length is not smaller than hdr */
	if (buf->len < sizeof(*hdr)) {
		LOG_ERR("Recvd Wrong AVDTP Header");
		return 0;
	}

	hdr = net_buf_pull_mem(buf, sizeof(*hdr));
	pack_type = AVDTP_GET_PKT_TYPE(hdr->hdr);
	msgtype = AVDTP_GET_MSG_TYPE(hdr->hdr);
	sigid = AVDTP_GET_SIG_ID(hdr->signal_id);
	tid = AVDTP_GET_TR_ID(hdr->hdr);

	LOG_DBG("pack_type[0x%02x] msg_type[0x%02x] sig_id[0x%02x] tid[0x%02x]",
		pack_type, msgtype, sigid, tid);

	/* TODO: only support single packet now */
	if (pack_type != BT_AVDTP_PACKET_TYPE_SINGLE) {
		if (pack_type == BT_AVDTP_PACKET_TYPE_START) {
			struct net_buf *rsp_buf;
			int err;

			sigid = net_buf_pull_u8(buf);  // <-- Pulling the buf without size check

There should be a length check before retrieving the remaining body.

Impact

Result of exploitation could lead to instability (i.e., crash) or denial of service attacks.

Patches

main: #77969

For more information

If you have any questions or comments about this advisory:

embargo: 2024-11-22

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
None
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:N/I:N/A:H

CVE ID

CVE-2024-8798

Weaknesses

Improper Input Validation

The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. Learn more on MITRE.

Heap-based Buffer Overflow

A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). Learn more on MITRE.

Credits