Skip to content

Commit

Permalink
Guard against polynomial regular expression used on uncontrolled data in
Browse files Browse the repository at this point in the history
IMAPReply.UNTAGGED_RESPONSE
  • Loading branch information
garydgregory committed Feb 23, 2024
1 parent 1745292 commit 895efa1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regular expression in UnixFTPEntryParser.preParse(List&lt;String&gt;).</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Guard against polynomial regular expression used on uncontrolled data in VMSVersioningFTPEntryParser.REGEX.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Guard against polynomial regular expression used on uncontrolled data in IMAPReply.TAGGED_RESPONSE.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Guard against polynomial regular expression used on uncontrolled data in IMAPReply.UNTAGGED_RESPONSE.</action>
<!-- ADD -->
<action type="add" issue="NET-726" dev="ggregory" due-to="PJ Fanning, Gary Gregory">Add protected getters to FTPSClient #204.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add SubnetUtils.toString().</action>
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/org/apache/commons/net/imap/IMAPReply.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ public final class IMAPReply {
*/
private static final Pattern TAGGED_PATTERN = Pattern.compile(TAGGED_RESPONSE);

private static final String UNTAGGED_RESPONSE = "^\\* (\\S+).*";
/**
* Guard against Polynomial regular expression used on uncontrolled data.
*
* Don't look for more than 80 backslashes.
* Don't look for more than 80 character.
*/
private static final String UNTAGGED_RESPONSE = "^\\* (\\S{1,80}).{0,80}";

private static final Pattern UNTAGGED_PATTERN = Pattern.compile(UNTAGGED_RESPONSE);
private static final Pattern LITERAL_PATTERN = Pattern.compile("\\{(\\d+)\\}$"); // {dd}
Expand Down

0 comments on commit 895efa1

Please sign in to comment.