Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3713

FP in S5852 (ReDoS) involving possessive quantifiers

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.14
    • Component/s: Rules
    • Labels:

      Description

      Currently S5852 assumes that a possessive quantifier in a sequence can always lead to catastrophic backtracking. However, there is an issue only when a non-possessive quantifier is followed by a possessive one, leading to backtracking and a quadratic runtime. Therefore, we should ignore previous possessive quantifiers when considering a repetition in the overlapping repetition check.

      Note that this also applies to the implicit reluctant quantifier present in regexes used for partial matches.

      As an example str.split("\\s*,") will cause quadratic runtime on a string consisting solely of spaces. The rule correctly identifies this. A user might be tempted to fix this by making the quantifier possessive, changing the code to str.split("\\s*+,"). This will not actually fix the problem, but it will cause us to not report the issue anymore, suggesting the fix worked when it didn't.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                quentin.jaquier Quentin Jaquier
                Reporter:
                sebastian.hungerecker Sebastian Hungerecker
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: