Skip to content

Bluetooth: ASCS Unchecked tailroom of the response buffer

Moderate
ceolin published GHSA-m22j-ccg7-4v4h Oct 4, 2024

Package

zephyr (zephyr)

Affected versions

<=3.6

Patched versions

None

Description

Summary

In ascs_cp_rsp_add in /subsys/bluetooth/audio/ascs.c, an unchecked tailroom could lead to a global buffer overflow.

Details

The function ascs_cp_rsp_add is invoked by multiple operations such as ascs_config, ascs_qos, etc.

The maximum number of ASEs can be up to the value of uint8_t, and this is iterated over in a for loop:

	...
	req = net_buf_simple_pull_mem(buf, sizeof(*req));

	LOG_DBG("num_ases %u", req->num_ases);

	for (uint8_t i = 0; i < req->num_ases; i++) {
	...

As the loop iterates, ascs_cp_rsp_add may be called multiple times.

Within ascs_cp_rsp_add, the function net_buf_simple_add is used to add data to rsp_buf:

	ase_rsp = net_buf_simple_add(&rsp_buf, sizeof(*ase_rsp));
	ase_rsp->id = id;
	ase_rsp->code = code;
	ase_rsp->reason = reason;

The buffer rsp_buf is defined statically using a macro with size CONFIG_BT_L2CAP_TX_MTU:

NET_BUF_SIMPLE_DEFINE_STATIC(rsp_buf, CONFIG_BT_L2CAP_TX_MTU);

Each time ascs_cp_rsp_add is called, sizeof(*ase_rsp), which is 3 bytes, is added to the buffer.

However, there is a missing check for available tailroom before adding data to the buffer.

If ascs_cp_rsp_add is called multiple times by a large num_ases, it could lead to a global buffer overflow in subsequent code:

	ase_rsp = net_buf_simple_add(&rsp_buf, sizeof(*ase_rsp));
	ase_rsp->id = id;
	ase_rsp->code = code;
	ase_rsp->reason = reason;

PoC

Set the CONFIG_BT_L2CAP_TX_MTU parameter to 253, which is the default value as defined in autoconf.h.

Set the num_ases in the req to a value greater than 85, ensuring that the resulting size exceeds the capacity of rsp_buf, since 85×3>253.

Impact

An out-of-bounds write in a global variable can result in system instability, potentially leading to crashes or denial of service (DoS) attacks.

Patches

main: #74976
v3.6: #77958

For more information

If you have any questions or comments about this advisory:

embargo: 2024-09-22

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
None
User interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
Low
Availability
Low

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:N/UI:N/S:U/C:L/I:L/A:L

CVE ID

CVE-2024-6442

Weaknesses

Credits