Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace is_header() check pattern #34

Merged
merged 1 commit into from Jul 8, 2020

Conversation

javierguerragiraldez
Copy link
Contributor

the original pattern exhibits can take indeterminate time on long
input strings. The semantics of:

'(%S+):%s*(%S+)'

can be described as: "at least one non-space, followed by a colon,
optional whitespace and at least one non-space".

but the captures are not used in the code, and the match isn't
anchored at either end, so the pattern:

'%S:%s*%S'

matches and rejects the same sets of strings and executes in
linear time. The time to reject the text reported in #26 (200000
chars in length) drops from 150secs to 2msec.

the original pattern exhibits can take indeterminate time on long
input strings.  The semantics of:

    '(%S+):%s*(%S+)'

can be described as: "at least one non-space, followed by a colon,
optional whitespace and at least one non-space".

but the captures are not used in the code, and the match isn't
anchored at either end, so the pattern:

    '%S:%s*%S'

matches and rejects the same sets of strings and executes in
linear time.  The time to reject the text reported in #26 (200000
chars in length) drops from 150secs to 2msec.
@javierguerragiraldez javierguerragiraldez merged commit d632e5d into master Jul 8, 2020
@javierguerragiraldez javierguerragiraldez deleted the fix/vulnerable-pattern branch July 8, 2020 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants