UTF-8 soundness: from_utf8_unchecked on unvalidated bytes in parse_str()
## Summary
simd-json's parse_str function in all 6 SIMD backends calls from_utf8_unchecked on byte sequences that have NOT been validated as valid UTF-8.
Affected: ALL versions 0.1.0 through 0.17.0 (latest).
## Affected call sites (v0.17.0, 12 total across 6 SIMD backends)
The fast path iterates looking for "quote" terminators but does NOT validate UTF-8. Invalid bytes (0x80-0xBF, lone surrogates, overlong encodings) pass through and get wrapped in &str.
The crate already has a utf8check module with SIMD-accelerated UTF-8 validation, but it is never called on the string parsing path.
## Impact
- Violates Rust's &str UTF-8 invariant (UB in safe Rust code)
- Downstream UB from any safe operation on the invalid &str
- Attack surface: parses untrusted JSON from network
## Suggested fix
Call the existing utf8check::validate() before from_utf8_unchecked. The module already exists - it was likely intended to be called here but was accidentally omitted.
## References
- RUSTSEC-2019-0008 (previous simd-json vuln)
- RUSTSEC-2023-0074 (zerocopy, similar &str violation)
- RUSTSEC-2024-0344 (zerovec invalid UTF-8)
0 条评论