Skip to content

Regex times out and crashes Apache when pcre.jit is enabled #57

@JackJohansson

Description

@JackJohansson

Recently I've installed PHP8.1.0RC6 and Laravel 9 to try out some of the new features. I was unable to load any pages using Laravel, as Apache would crash and I would get a connection reset message.

I've posted a bug report on Laravel's repository here. We've tracked down the issue to a regex. I was suggested to post the bug on php.net, which I did submit. After further investigation, it appears that the issue is related to a recent patch to this repository.

The detailed bug description can be found in the links below, but just as a short explanation, the following piece of code will crash Apache ( using 2.4.51 ) when pcre.jit = 1 but does not cause a problem when it's executed via CLI:

var_dump(
	preg_match(
		'(([\\r\\n]{1,1000})|([^\\S\\r\\n]{1,1000})|(\\\\)|(\')|(")|(\\#)|(\\$)|(([^(\\s\\\\\'"\\#\\$)]|\\(|\\)){1,1000}))A',
		'Laravel',
		$matches
	)
);

Bug report on Laravel repository:
laravel/framework#39716

Bug report on bugs.php.net:
https://bugs.php.net/bug.php?id=81647

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions