CVE-2021-26955
JSON

9.8critical

Out of bounds read in xcb

Severity
9.8critical CVSS:3.1 by NVD
Exploit likelihood
1.75% (higher than 78% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
mitre
Also known as
GHSA-2xpg-3hx4-fm9rGHSA-3288-cwgw-ch86GHSA-3cj3-jrrp-9rxfGHSA-mp6r-fgw2-rxfxRUSTSEC-2021-0019

Description

An issue was discovered in the xcb crate through 2021-02-04 for Rust. It has a soundness violation because xcb::xproto::GetAtomNameReply::name() calls std::str::from_utf8_unchecked() on unvalidated bytes from an X server.

Affected

Product or packageVersionsReported by
Unspecified productn/aCVE List
xcb (crates.io)before 1.0.0, from 0.0.0-0 before 1.0.0GitHub Advisory Database, RustSec Advisory Database
xcb_project xcbup to 2021-02-04NVD

All scores

GitHub9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
GitHub8.8high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
NVD9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
NVD7.5high CVSS:2.0AV:N/AC:L/Au:N/C:P/I:P/A:P

Classification

What each source says

CVE List

An issue was discovered in the xcb crate through 2021-02-04 for Rust. It has a soundness violation because xcb::xproto::GetAtomNameReply::name() calls std::str::from_utf8_unchecked() on unvalidated bytes from an X server.

GitHub Advisory Database

An issue was discovered in the xcb crate through 2021-02-04 for Rust. It has a soundness violation because there is an out-of-bounds read in xcb::xproto::change_property(), as demonstrated by a format=32 T=u8 situation where out-of-bounds bytes are sent to an X server.

GitHub Advisory Database

An issue was discovered in the xcb crate through 2021-02-04 for Rust. It has a soundness violation because transmutation to the wrong type can happen after xcb::base::cast_event uses std::mem::transmute to return a reference to an arbitrary type.

GitHub Advisory Database

The function xcb::xproto::GetPropertyReply::value() returns a slice of type T where T is an unconstrained type parameter. The raw bytes received from the X11 server are interpreted as the requested type. The users of the xcb crate are advised to only call this function with the intended types. These are u8, u16, and u32.

This issue is tracked here: https://github.com/rust-x-bindings/rust-xcb/issues/95

RustSec Advisory Database

Calls std::str::from_utf8_unchecked() without any checks

The function xcb::xproto::GetAtomNameReply::name() calls std::str::from_utf8_unchecked() on the raw bytes that were received from the X11 server without any validity checks. The X11 server only prevents interior null bytes, but otherwise allows any X11 client to create an atom for arbitrary bytes.

This issue is tracked here: https://github.com/rust-x-bindings/rust-xcb/issues/96

xcb::xproto::GetPropertyReply::value() allows arbitrary return types

The function xcb::xproto::GetPropertyReply::value() returns a slice of type T where T is an unconstrained type parameter. The raw bytes received from the X11 server are interpreted as the requested type.

The users of the xcb crate are advised to only call this function with the intended types. These are u8, u16, and u32.

This issue is tracked here: https://github.com/rust-x-bindings/rust-xcb/issues/95

Out of bounds read in xcb::xproto::change_property()

xcb::xproto::change_property has (among others) the arguments format: u8 and data: &[T]. The intended use is one of the following cases:

  • format = 8 and T = u8
  • format = 16 and T = u16
  • format = 32 and T = u32 However, this constraint is not enforced. For example, it is possible to call the function with format = 32 and T = u8. In this case, a read beyond the end of the data slice is performed and the bytes are sent to the X11 server.

The users of the xcb crate are advised to only call this function with one of the intended argument combinations.

This issue is tracked here: https://github.com/rust-x-bindings/rust-xcb/issues/94

'Safe' wrapper around std::mem::transmute()

The function xcb::base::cast_event() takes a reference to a xcb::base::GenericEvent and returns a reference to an arbitrary type, as requested by the caller (or found via type interference). The function is implemented as a direct call to std::mem::transmute(). Since the return type is not constrained, this allows transmution to an incorrect type or a type that is larger than the X11 event that was passed in.

X11 events are mostly always 32 bytes large and this function works as intended.

Users are advised to only cast to the event structs provided by the xcb crate (and hope for the best).

This issue is tracked here: https://github.com/rust-x-bindings/rust-xcb/issues/78

NVD (es)

Se detectó un problema en la crate xcb versiones hasta el 4 de Febrero de 2021 para Rust. Presenta una violación de solidez porque la función xcb::xproto::GetAtomNameReply::name() llama a la función std::str::from_utf8_unchecked() en bytes no validados de un servidor X

References

Related

Sources

SourceRecordLicence
CVE ListCVE-2021-26955 changed 2024-08-03CVE Terms of Use
GitHub Advisory DatabaseGHSA-2xpg-3hx4-fm9r changed 2024-03-15CC-BY-4.0
GitHub Advisory DatabaseGHSA-3288-cwgw-ch86 changed 2024-03-15CC-BY-4.0
GitHub Advisory DatabaseGHSA-3cj3-jrrp-9rxf changed 2024-03-15CC-BY-4.0
GitHub Advisory DatabaseGHSA-mp6r-fgw2-rxfx changed 2024-03-15CC-BY-4.0
RustSec Advisory DatabaseRUSTSEC-2021-0019 changed 2024-03-15CC0-1.0
NVDCVE-2021-26955 changed 2026-06-17Public domain