Skip to content

Missing length checks of net_buf in rfcomm_handle_data

Moderate
ceolin published GHSA-7833-fcpm-3ggm Sep 13, 2024

Package

zephyr (zephyr)

Affected versions

<=3.6

Patched versions

None

Description

Summary

In rfcomm_handle_data in subsys/bluetooth/host/rfcomm.c, the buf->len is not verified, leading to undefined behavior in the subsequent net_buf_pull_u8(buf) operation.

Details

The function rfcomm_handle_data is called from rfcomm_recv.

Although there is an initial check to ensure buf->len is larger than sizeof(*hdr) + 1:

	if (buf->len < (sizeof(*hdr) + 1)) {
		BT_ERR("Too small RFCOMM Frame");
		return 0;
	}

there are no additional checks on the remaining size of buf.

If buf is exactly sizeof(*hdr) + 1, it will cause a crash in executing net_buf_pull_u8(buf) in the following code within rfcomm_handle_data:

	if (pf == BT_RFCOMM_PF_UIH_CREDIT) {
		rfcomm_dlc_tx_give_credits(dlc, net_buf_pull_u8(buf));
	}

I believe there should be proper length check of buf.

PoC

buf given to rfcomm_recv could be like ff ff 0a 30.

Impact

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

Patches

main: #74640

For more information

If you have any questions or comments about this advisory:

embargo: 2024-09-05

Severity

Moderate

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
Adjacent
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
Low
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:A/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H

CVE ID

CVE-2024-6258

Credits