Skip to content

integer overflow on a particular regex #995

Closed
@finnbear

Description

@finnbear

What version of regex are you using?

1.8.1 (latest)

Describe the bug at a high level.

The following code causes an integer-overflow panic in debug mode:

fn main() {
    regex::Regex::new("  {2147483516}{2147483416}{5}").unwrap();
}

What are the steps to reproduce the behavior?

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=0f0b53f5c300a71ce6098e767d13cbc2

What is the actual behavior?

  • integer overflow
    • panic in debug mode
    • seemingly returns the right answer (Err(CompiledTooBig(10485760))) anyway in release mode

What is the expected behavior?

Return the right answer (Err(CompiledTooBig(10485760))) without integer overflow.

Acknowledgement

The fuzzing infrastructure that found this bug was provided to and integrated into surrealdb by Google OSS Fuzz and @silvergasp, respectively.

The consensus from reporting this as a security issue was that it shouldn't be treated as one as users can avoid panics using catch_unwind. The security policy and/or documentation may be updated to reflect this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions