Repository navigation
Closed
Labels
A:parserIssues related to parsingcategory:bugSomething isn't workingpanicstatus:investigatethis requires investigation
Description
Describe the bug
I found two crash cases with fuzzing
I guess both of them have the same cause.
These crashes were found by libafl_libfuzzer fuzzer.
I can submit a fuzzer later, if it is ok.
How to reproduce
For both crash1, crash2
toka@toka:/tmp/nushell/crates/nu-parser/fuzz/crashes$ nu crash1.txt
thread 'main' panicked at 'slice index starts at 7 but ends at 6', /home/toka/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nu-protocol-0.81.0/src/engine/engine_state.rs:1424:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtraceand
toka@toka:/tmp/nushell/crates/nu-parser/fuzz/crashes$ nu crash2.txt
thread 'main' panicked at 'slice index starts at 118 but ends at 117', /home/toka/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nu-protocol-0.81.0/src/engine/engine_state.rs:1424:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtraceExpected behavior
it shouldn't panic
Screenshots
No response
Configuration
/tmp/nushell/crates/nu-parser/fuzz/crashes> version | transpose key value | to md --pretty 06/12/2023 07:21:44 PM
| key | value |
|---|---|
| version | 0.81.0 |
| branch | |
| commit_hash | |
| build_os | linux-x86_64 |
| build_target | x86_64-unknown-linux-gnu |
| rust_version | rustc 1.72.0-nightly (a97c36dd2 2023-06-07) |
| rust_channel | nightly-x86_64-unknown-linux-gnu |
| cargo_version | cargo 1.72.0-nightly (b0fa79679 2023-06-03) |
| build_time | 2023-06-12 17:35:19 +02:00 |
| build_rust_channel | release |
| features | default, sqlite, trash, which, zip |
| installed_plugins | |
| /tmp/nushell/crates/nu-parser/fuzz/crashes> |
Additional context
No response
Reacted by Stefan Holderbach
Metadata
Metadata
Assignees
Labels
A:parserIssues related to parsingcategory:bugSomething isn't workingpanicstatus:investigatethis requires investigation
Activity
amtoine commentedon Jun 13, 2023
these are quite strange files 😅
but yeah it shouldn't crash, for sure 👍
tokatoka commentedon Jun 13, 2023
yeah it's generated by the fuzzer.
I think the shortest crashing case is "..=.."
sholderbach commentedon Jun 13, 2023
Thank you very much for those failure cases and your fuzzing effort. This looks very much like a parser bug that transfers invalid spans that later cause a failure.
Would you mind sharing how you set up your fuzzing, if other folks want to dedicate some compute to target nushell?
tokatoka commentedon Jun 14, 2023
Yes ofc.I mean yes of course I can share the fuzzer
tokatoka commentedon Jun 14, 2023
I will commit back the fuzzer I used later once I have set it up
tokatoka commentedon Jun 14, 2023
crash-ba5b0bd650e29124.txt
I have another crash that seems to crash at a different location, and is not an off-by-one bug.
i don't know if this has the same root-cause as the first two crash files.
sholderbach commentedon Jun 14, 2023
This is probably a different beast as it is crashing in the parser already. I suspect we have more than one parser bug that chokes on arbitrary input.
Feels a bit scary to execute whatever code the fuzzer can cook up :D
^rm -rf --no-preserve-root /and send it :Paddisoncrump commentedon Jun 14, 2023
The fuzzer is thankfully quite unlikely to issue such a command -- and we can merely hook the execve function if this is a major concern 😉
tokatoka commentedon Jun 14, 2023
Yes I know 😄
We don't fuzz by sending random bytes to
nueither.For you to reproduce, Here's the rust code to reproduce the same bug.
you can compile it into
pocand thensholderbach commentedon Jun 14, 2023
Phew, that looks much safer :D shouldn't be able to do any intentional or direct damage.
(I was initially unsure why the panics were popping up in the engine part but yeah that is just the engine state holding any created definitions)
@addisoncrump as nushell does a bunch of direct syscalls to file system etc. without shelling out to another program just locking down
execvewouldn't suffice to properly sandbox it.addisoncrump commentedon Jun 14, 2023
Interesting; I didn't see those syscalls, just wrappers for e.g. std's Command and such. I will investigate further 🙂
Add 2 fuzzers for nu-path, nu-parser (#10376)
Add 2 fuzzers for nu-path, nu-parser (nushell#10376)
kronberger-droid commentedon Nov 14, 2026
The fuzzer inputs attached here and the related
1..=1..and..=..cases parse without a panic on 0.117.