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

Missing anchors in validation regular expression #241

Open
nharraud opened this issue Jul 31, 2021 · 1 comment
Open

Missing anchors in validation regular expression #241

nharraud opened this issue Jul 31, 2021 · 1 comment

Comments

@nharraud
Copy link

nharraud commented Jul 31, 2021

Hi,
The ReDos example uses two regular expressions which are missing start and end anchors:

// const regexPattern = /([0-9]+)\#/;
const regexPattern = /([0-9]+)+\#/;

These regular expressions accept values such as evil123#evil.

How about:
1/ fixing these two regular expressions like this:

        // const regexPattern = /^[0-9]+\#$/;
        const regexPattern = /^([0-9]+)+\#$/;

2/ adding another regular expression somewhere which creates a vulnerability due to the missing anchors. This would be a good opportunity to explain CWE-777: Regular Expression without Anchors, which is quite easy to miss in Javascript.

@CaduRoriz
Copy link

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants