Skip to content

Conversation

@richkadel
Copy link
Contributor

@richkadel richkadel commented Dec 23, 2021

Limit nesting to prevent program stack overflow, and catch bad brace

This PR addresses two more classes of oss-fuzz failures.

  1. A document with many open braces, without closing braces, can
    eventually cause program stack overflow. I've added function variations
    to set a specific limit, and the existing functions set this value to a
    default limit.

  2. A document that ends with an extra closing brace could crash the
    parser. This is now caught, and a parser error is emitted. This may have
    also contributed to an "out-of-memory" error, as the reproducer test
    (included with this PR) no longer fails.

I also added better testing support for debugging the parser on sample
documents (such as oss-fuzz reproducers).

Fixes: #22
Fixes: #23
Fixes: #24

@richkadel
Copy link
Contributor Author

CIFuzz highlighted some issues. I downloaded the corpus used by CIFuzz (over 4000 input files) and fixed one of the most obvious issues (misaligned byte indexes slicing unicode strings in the new error formatting code), but there is still a logic bug in here somewhere.

So I marked this draft will I look into it.

@richkadel richkadel force-pushed the more-fuzz-fixes branch 4 times, most recently from 9833b29 to 550cc3f Compare December 24, 2021 07:01
@richkadel richkadel marked this pull request as ready for review December 24, 2021 07:16
@richkadel
Copy link
Contributor Author

@erickt - No rush of course! Have a great holiday break.

This is ready for review now.

This PR addresses two more classes of oss-fuzz failures.

1. A document with many open braces, without closing braces, can
eventually cause program stack overflow. I've added function variations
to set a specific limit, and the existing functions set this value to a
default limit.

2. A document that ends with an extra closing brace could crash the
parser. This is now caught, and a parser error is emitted. This may have
also contributed to an "out-of-memory" error, as the reproducer test
(included with this PR) no longer fails.

I also added better testing support for debugging the parser on sample
documents (such as oss-fuzz reproducers).

Fixes: google#22
Fixes: google#23
Fixes: google#24
@richkadel richkadel merged commit de97692 into google:master Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants