Skip to content

xcb connect_to_fd* constructors unsound #2355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions crates/xcb/RUSTSEC-0000-0000.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
```toml
[advisory]
id = "RUSTSEC-0000-0000"
package = "xcb"
date = "2025-08-05"
url = "https://github.com/rust-x-bindings/rust-xcb/issues/282"
references = ["https://github.com/rust-x-bindings/rust-xcb/issues/167"]
informational = "unsound"

[versions]
patched = []

[affected.functions]
"xcb::Connection::connect_to_fd" = [">= 1.0.0-beta.0"]
"xcb::Connection::connect_to_fd_with_extensions" = [">= 1.0.0-beta.0"]
```

# Unsoundness in `xcb::Connection::connect_to_fd*` functions

The API of `xcb::Connection` has constructors which allow an arbitrary `RawFd`
to be used as a socket connection. On either failure of these constructors or
on the drop of `Connection`, it closes the associated file descriptor. Thus, a
program which uses an `OwnedFd` (such as a `UnixStream`) as the file descriptor
can close the file descriptor and continue to attempt using it or close an
already-closed file descriptor.

The functions not being safe was previously documented, although with no
specifics (https://github.com/rust-x-bindings/rust-xcb/issues/167). No action
was taken.