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

Regular Expression DoS vulnerability #14859

Open
core-ai-bot opened this issue Aug 31, 2021 · 1 comment
Open

Regular Expression DoS vulnerability #14859

core-ai-bot opened this issue Aug 31, 2021 · 1 comment

Comments

@core-ai-bot
Copy link
Member

Issue by linci8210
Tuesday Apr 13, 2021 at 10:34 GMT
Originally opened as adobe/brackets#15341


We are working on the ReDoS problem and detected 4 vulnerable regex(es) from your repository.

1: :((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))? in brackets/src/extensions/default/JavaScriptQuickEdit/unittest-files/jquery-ui/tests/jquery-1.7.js
2: ((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*) in brackets/src/extensions/default/JavaScriptQuickEdit/unittest-files/jquery-ui/tests/jquery-1.6.js
3: <(\w+?)\s+(?:[^<]*?\s)*?data-brackets-id='(\S+?)' in brackets/test/spec/HTMLInstrumentation-test.js
4: -webkit-gradient\((?:[^\(]*?(?:\((?:[^\(]*?(?:\([^\)]*?\))*?)*?\))*?)*?\)|(?:(?:-moz-|-ms-|-o-|-webkit-|:|\s)((repeating-)?linear-gradient)|(?:-moz-|-ms-|-o-|-webkit-|:|\s)((repeating-)?radial-gradient))(\((?:[^\)]*?(?:\([^\)]*?\))*?)*?\)) in brackets/src/extensions/default/QuickView/main.js

Please try the following:

var pattern = ":((?:[\\w\\u00c0-\\uFFFF\\-]|\\\\.)+)(?:\\((['\"]?)((?:\\([^\\)]+\\)|[^\\(\\)]*)+)\\2\\))?";
var input = ":\\\b(\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
var re = new RegExp(pattern);
var matched = input.match(re);

var pattern = "((?:\\((?:\\([^()]+\\)|[^()]+)+\\)|\\[(?:\\[[^\\[\\]]*\\]|['\"][^'\"]*['\"]|[^\\[\\]'\"]+)+\\]|\\\\.|[^ >+~,(\\[\\\\]+)+|[>+~])(\\s*,\\s*)?((?:.|\\r|\\n)*)";
var input = "[\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
var re = new RegExp(pattern);
var matched = input.match(re);

var pattern = "<(\\w+?)\\s+(?:[^<]*?\\s)*?data-brackets-id='(\\S+?)'";
var input = "<0 \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t <";
var re = new RegExp(pattern);
var matched = input.match(re);

var pattern = "-webkit-gradient\\((?:[^\\(]*?(?:\\((?:[^\\(]*?(?:\\([^\\)]*?\\))*?)*?\\))*?)*?\\)|(?:(?:-moz-|-ms-|-o-|-webkit-|:|\\s)((repeating-)?linear-gradient)|(?:-moz-|-ms-|-o-|-webkit-|:|\\s)((repeating-)?radial-gradient))(\\((?:[^\\)]*?(?:\\([^\\)]*?\\))*?)*?\\))";
var input = "-webkit-gradient(\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
var re = new RegExp(pattern);
var matched = input.match(re);

We didn’t create a pull request because we're not sure if these cases are possible to take place in your program, we also do not understand the functionality of these regexes as you do. Thank you for your understanding.

@core-ai-bot
Copy link
Member Author

Comment by KwasiEvans
Thursday Apr 15, 2021 at 08:50 GMT


https://www.studocu.com/en-ie/document/university-college-cork/advanced-database-management-systems/practice-materials/exam-questions-and-answers-sql-exam/1764490/view

On Tue, 13 Apr 2021, 10:35 123, @.***> wrote:

We are working on the ReDoS
https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
problem and detected 4 vulnerable regex(es) from your repository.

1:
:((?:[\w\u00c0-\uFFFF-]|\.)+)(?:((['"]?)((?:([^\)]+)|[^\(\)])+)\2))?
in
brackets/src/extensions/default/JavaScriptQuickEdit/unittest-files/jquery-ui/tests/jquery-1.7.js
2: ((?:((?:([^()]+)|[^()]+)+)|[(?:[[^\[\]]
]|['"][^'"]*['"]|[^\[\]'"]+)+]|\.|[^

+,([\]+)+|[>+])(\s*,\s*)?((?:.|\r|\n)) in
brackets/src/extensions/default/JavaScriptQuickEdit/unittest-files/jquery-ui/tests/jquery-1.6.js
3: <(\w+?)\s+(?:[^<]
?\s)?data-brackets-id='(\S+?)' in
brackets/test/spec/HTMLInstrumentation-test.js
4:
-webkit-gradient((?:[^\(]
?(?:((?:[^\(]?(?:([^\)]?))?)?))?)?)|(?:(?:-moz-|-ms-|-o-|-webkit-|:|\s)((repeating-)?linear-gradient)|(?:-moz-|-ms-|-o-|-webkit-|:|\s)((repeating-)?radial-gradient))(((?:[^\)]?(?:([^\)]?))?)?))
in brackets/src/extensions/default/QuickView/main.js

Please try the following:

var pattern = ":((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\\)]+\)|[^\\(\\)]*)+)\2\))?";

var input = ":\\b(\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";

var re = new RegExp(pattern);

var matched = input.match(re);

var pattern = "((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\\[\\]]\]|['"][^'\"]['"]|[^\\[\\]'\"]+)+\]|\\.|[^ >+,(\[\\]+)+|[>+])(\s*,\s*)?((?:.|\r|\n)*)";

var input = "[\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";

var re = new RegExp(pattern);

var matched = input.match(re);

var pattern = "<(\w+?)\s+(?:[^<]?\s)?data-brackets-id='(\S+?)'";

var input = "<0 \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t <";

var re = new RegExp(pattern);

var matched = input.match(re);

var pattern = "-webkit-gradient\((?:[^\\(]?(?:\((?:[^\\(]?(?:\([^\\)]?\))?)?\))?)?\)|(?:(?:-moz-|-ms-|-o-|-webkit-|:|\s)((repeating-)?linear-gradient)|(?:-moz-|-ms-|-o-|-webkit-|:|\s)((repeating-)?radial-gradient))(\((?:[^\\)]?(?:\([^\\)]?\))?)*?\))";

var input = "-webkit-gradient(\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";

var re = new RegExp(pattern);

var matched = input.match(re);

We didn’t create a pull request because we're not sure if these cases are
possible to take place in your program, we also do not understand the
functionality of these regexes as you do. Thank you for your understanding.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
adobe/brackets#15341, or unsubscribe
https://github.com/notifications/unsubscribe-auth/ART7KPQTK6YJAQVWRUHXVA3TIQM6PANCNFSM423CHLEA
.

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