Skip to content

Out of Bounds write in routing with SRH

High
miri64 published GHSA-xjgw-7638-29g5 May 30, 2023

Package

RIOT-OS

Affected versions

<= 2022.10

Patched versions

2023.04

Description

Impact

RIOT-OS contains a network stack with the ability to process 6LoWPAN frames. An attacker can send a crafted frame to the device resulting in an integer underflow and out of bounds access in the packet buffer. Triggering the access at the right time will corrupt other packets or the allocator metadata. Corrupting a pointer will lead to denial of service.

Patches

No public patches are available.

Workarounds

  • Disabling SRH in the network stack

For more information

If you have any questions or comments about this advisory:

Bug Details

If RPL with SRH is used the next hop is read from an array of addresses.
The index calculation is susceptible to an integer underflow (source):

    num_addr = (((rh->len * 8) - GNRC_RPL_SRH_PADDING(rh->pad_resv) -
                 (16 - GNRC_RPL_SRH_COMPRE(rh->compr))) /
                (16 - GNRC_RPL_SRH_COMPRI(rh->compr))) + 1;

If rh->len is zero the bug can be triggered and later cause an out of bounds access while the next routing address is fetched.
The next address to use is calculated based one current_pos without any additional bounds checks (source):

    current_address = &addr_vec[(current_pos - 1) * compri_addr_len];
    memcpy(&addr.u8[pref_elided], current_address, addr_len);

The out of bounds access manifests as follows:

  1. Calculate current_address which is out of bounds from addr_vec
  2. memcpy from current_address to addr
  3. Some checks are preformed with addr
  4. memcpy from addr to current_address

During step 3 a interrupt can occur and change the content of current_address.
Then step 4 overwrites current_address again destroying the new contents.
This can lead to corrupted pointers, resulting in a crash.

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-2023-24817

Weaknesses

Improper Restriction of Operations within the Bounds of a Memory Buffer

The product performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer. Learn more on MITRE.

Integer Underflow (Wrap or Wraparound)

The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result. Learn more on MITRE.

Credits