Skip to content
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

Add unsound const-cstr #1613

Merged
merged 4 commits into from
Mar 12, 2023
Merged
Changes from 3 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
40 changes: 40 additions & 0 deletions crates/const-cstr/RUSTSEC-0000-0000.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
```toml
[advisory]
id = "RUSTSEC-0000-0000"
package = "const-cstr"
date = "2023-03-12"
url = "https://github.com/abonander/const-cstr"
informational = "unsound"

[versions]
patched = []
```

# const-cstr is Unmaintained

Last release was about five years ago.

The maintainer(s) have been unreachable to respond to any issues that may or may not include security issues.

The repository is now archived and there is no security policy in place to contact the maintainer(s) otherwise.

No direct fork exist.

# const-cstr is Unsound

The crate violates the safety contract of [ffi::CStr::from_bytes_with_nul_unchecked](https://doc.rust-lang.org/std/ffi/struct.CStr.html#method.from_bytes_with_nul_unchecked) used in `ConstCStr::as_cstr`

No interior nul bytes checking is done either by the constructor or the canonical macro to create the `ConstCStr`

# const-cstr Panic

Additionally the crate may cause runtime panics if statically compiled and ran with any untrusted data that is not nul-terminated.

This is however unlikely but the the crate should not be used for untrusted data in context where panic may create a DoS vector.

## Possible Alternatives

The below may or may not provide alternative(s)

- [const_cstr::cstr!](https://docs.rs/const-str/latest/const_str/macro.cstr.html)
pinkforest marked this conversation as resolved.
Show resolved Hide resolved
- [cstr::cstr!](https://docs.rs/cstr/latest/cstr)