tursodatabase / tursodatabase/libsql
Potentail unsound issue in libsql-sqlite3-parser
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17.2k
- Forks
- 531
- Avg merge
- 1h 12m
- Merged PRs (30d)
- 1
Description
Hi, thanks for your time to read this issue. We cannot find a repo for this crate, so we report the issue here. If it's not the correct place, plet let us know.
Our static analyzer find a potential unsound issue in the utf-8 parsing, where it doesn't provide enough check to ensure the soundness.
A potentail PoC code is like:
use libsql_sqlite3_parser::lexer::sql::{Parser, Tokenizer};
use fallible_iterator::FallibleIterator;
fn main() {
let invalid_utf8: &[u8] = &[0xC0, 0x80];
let sql = "SELECT ? ";
let mut v = Vec::new();
v.extend_from_slice(sql.as_bytes());
v.extend_from_slice(invalid_utf8);
let mut parser = Parser::new(&*v);
let mut cmd = parser.next().unwrap();
println!("{:?}", cmd)
}
Thanks again for your time.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with vendored/sqlite3-parser/src/dialect/mod.rs at lines 60-62 and inspect the UTF-8 parsing path. Reproduce the reported behavior with the provided Rust PoC using invalid UTF-8 bytes, then verify that parsing rejects or safely handles the input and add regression coverage for the case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sqlite
- Domain
- databases, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100