Logo
-

Byte Open Security

(ByteOS Network)

Log In

Sign Up

ByteOS

Security
Vulnerability Details
Registries
Custom Views
Weaknesses
Attack Patterns
Filters & Tools
CWE-407:Inefficient Algorithmic Complexity
Weakness ID:407
Version:v4.17
Weakness Name:Inefficient Algorithmic Complexity
Vulnerability Mapping:Allowed-with-Review
Abstraction:Class
Structure:Simple
Status:Incomplete
Likelihood of Exploit:Low
DetailsContent HistoryObserved CVE ExamplesReports
▼Description

An algorithm in a product has an inefficient worst-case computational complexity that may be detrimental to system performance and can be triggered by an attacker, typically using crafted manipulations that ensure that the worst case is being reached.

▼Extended Description

▼Alternate Terms
Quadratic Complexity

Used when the algorithmic complexity is related to the square of the number of inputs (N^2)

▼Relationships
Relevant to the view"Research Concepts - (1000)"
NatureMappingTypeIDName
ChildOfAllowed-with-ReviewC405Asymmetric Resource Consumption (Amplification)
ParentOfAllowedB1333Inefficient Regular Expression Complexity
Nature: ChildOf
Mapping: Allowed-with-Review
Type: Class
ID: 405
Name: Asymmetric Resource Consumption (Amplification)
Nature: ParentOf
Mapping: Allowed
Type: Base
ID: 1333
Name: Inefficient Regular Expression Complexity
▼Memberships
NatureMappingTypeIDName
MemberOfProhibitedV884CWE Cross-section
MemberOfProhibitedC977SFP Secondary Cluster: Design
MemberOfProhibitedV1003Weaknesses for Simplified Mapping of Published Vulnerabilities
MemberOfProhibitedC1307CISQ Quality Measures - Maintainability
MemberOfProhibitedC1416Comprehensive Categorization: Resource Lifecycle Management
Nature: MemberOf
Mapping: Prohibited
Type:View
ID: 884
Name: CWE Cross-section
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 977
Name: SFP Secondary Cluster: Design
Nature: MemberOf
Mapping: Prohibited
Type:View
ID: 1003
Name: Weaknesses for Simplified Mapping of Published Vulnerabilities
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 1307
Name: CISQ Quality Measures - Maintainability
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 1416
Name: Comprehensive Categorization: Resource Lifecycle Management
▼Tags
NatureMappingTypeIDName
MemberOfProhibitedBSBOSS-275Low likelihood of exploit
MemberOfProhibitedBSBOSS-294Not Language-Specific Weaknesses
MemberOfProhibitedBSBOSS-314DoS: Resource Consumption (CPU) (impact)
MemberOfProhibitedBSBOSS-327DoS: Resource Consumption (Memory) (impact)
MemberOfProhibitedBSBOSS-333DoS: Resource Consumption (Other) (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-275
Name: Low likelihood of exploit
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-294
Name: Not Language-Specific Weaknesses
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-314
Name: DoS: Resource Consumption (CPU) (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-327
Name: DoS: Resource Consumption (Memory) (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-333
Name: DoS: Resource Consumption (Other) (impact)
▼Relevant To View
Relevant to the view"CISQ Quality Measures (2020) - (1305)"
NatureMappingTypeIDName
MemberOfProhibitedC1307CISQ Quality Measures - Maintainability
Nature: MemberOf
Mapping: Prohibited
Type: Category
ID: 1307
Name: CISQ Quality Measures - Maintainability
Relevant to the view"Software Fault Pattern (SFP) Clusters - (888)"
NatureMappingTypeIDName
MemberOfProhibitedC977SFP Secondary Cluster: Design
Nature: MemberOf
Mapping: Prohibited
Type: Category
ID: 977
Name: SFP Secondary Cluster: Design
▼Background Detail

▼Common Consequences
ScopeLikelihoodImpactNote
AvailabilityN/ADoS: Resource Consumption (CPU)DoS: Resource Consumption (Memory)DoS: Resource Consumption (Other)

The typical consequence is CPU consumption, but memory consumption and consumption of other resources can also occur.

Scope: Availability
Likelihood: N/A
Impact: DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory), DoS: Resource Consumption (Other)
Note:

The typical consequence is CPU consumption, but memory consumption and consumption of other resources can also occur.

▼Potential Mitigations
▼Modes Of Introduction
Phase: Architecture and Design
Note:

N/A

Phase: Implementation
Note:

N/A

▼Applicable Platforms
Languages
Class: Not Language-Specific(Undetermined Prevalence)
▼Demonstrative Examples
Example 1

This example attempts to check if an input string is a "sentence" [REF-1164].

Language: ( code)
N/A

Language: JavaScript(Bad code)
var test_string = "Bad characters: $@#"; var bad_pattern = /^(\w+\s?)*$/i; var result = test_string.search(bad_pattern);

Language: ( code)
N/A

The regular expression has a vulnerable backtracking clause inside (\w+\s?)*$ which can be triggered to cause a Denial of Service by processing particular phrases.

To fix the backtracking problem, backtracking is removed with the ?= portion of the expression which changes it to a lookahead and the \2 which prevents the backtracking. The modified example is:

Language: JavaScript(Good code)
var test_string = "Bad characters: $@#"; var good_pattern = /^((?=(\w+))\2\s?)*$/i; var result = test_string.search(good_pattern);

Language: ( code)
N/A

Note that [REF-1164] has a more thorough (and lengthy) explanation of everything going on within the RegEx.

▼Observed Examples
ReferenceDescription
CVE-2021-32617
C++ library for image metadata has "quadratic complexity" issue with unnecessarily repetitive parsing each time an invalid character is encountered
CVE-2020-10735
Python has "quadratic complexity" issue when converting string to int with many digits in unexpected bases
CVE-2020-5243
server allows ReDOS with crafted User-Agent strings, due to overlapping capture groups that cause excessive backtracking.
CVE-2014-1474
Perl-based email address parser has "quadratic complexity" issue via a string that does not contain a valid address
CVE-2003-0244
CPU consumption via inputs that cause many hash table collisions.
CVE-2003-0364
CPU consumption via inputs that cause many hash table collisions.
CVE-2002-1203
Product performs unnecessary processing before dropping an invalid packet.
CVE-2001-1501
CPU and memory consumption using many wildcards.
CVE-2004-2527
Product allows attackers to cause multiple copies of a program to be loaded more quickly than the program can detect that other copies are running, then exit. This type of error should probably have its own category, where teardown takes more time than initialization.
CVE-2006-6931
Network monitoring system allows remote attackers to cause a denial of service (CPU consumption and detection outage) via crafted network traffic, aka a "backtracking attack."
CVE-2006-3380
Wiki allows remote attackers to cause a denial of service (CPU consumption) by performing a diff between large, crafted pages that trigger the worst case algorithmic complexity.
CVE-2006-3379
Wiki allows remote attackers to cause a denial of service (CPU consumption) by performing a diff between large, crafted pages that trigger the worst case algorithmic complexity.
CVE-2005-2506
OS allows attackers to cause a denial of service (CPU consumption) via crafted Gregorian dates.
CVE-2005-1792
Memory leak by performing actions faster than the software can clear them.
Reference: CVE-2021-32617
Description:
C++ library for image metadata has "quadratic complexity" issue with unnecessarily repetitive parsing each time an invalid character is encountered
Reference: CVE-2020-10735
Description:
Python has "quadratic complexity" issue when converting string to int with many digits in unexpected bases
Reference: CVE-2020-5243
Description:
server allows ReDOS with crafted User-Agent strings, due to overlapping capture groups that cause excessive backtracking.
Reference: CVE-2014-1474
Description:
Perl-based email address parser has "quadratic complexity" issue via a string that does not contain a valid address
Reference: CVE-2003-0244
Description:
CPU consumption via inputs that cause many hash table collisions.
Reference: CVE-2003-0364
Description:
CPU consumption via inputs that cause many hash table collisions.
Reference: CVE-2002-1203
Description:
Product performs unnecessary processing before dropping an invalid packet.
Reference: CVE-2001-1501
Description:
CPU and memory consumption using many wildcards.
Reference: CVE-2004-2527
Description:
Product allows attackers to cause multiple copies of a program to be loaded more quickly than the program can detect that other copies are running, then exit. This type of error should probably have its own category, where teardown takes more time than initialization.
Reference: CVE-2006-6931
Description:
Network monitoring system allows remote attackers to cause a denial of service (CPU consumption and detection outage) via crafted network traffic, aka a "backtracking attack."
Reference: CVE-2006-3380
Description:
Wiki allows remote attackers to cause a denial of service (CPU consumption) by performing a diff between large, crafted pages that trigger the worst case algorithmic complexity.
Reference: CVE-2006-3379
Description:
Wiki allows remote attackers to cause a denial of service (CPU consumption) by performing a diff between large, crafted pages that trigger the worst case algorithmic complexity.
Reference: CVE-2005-2506
Description:
OS allows attackers to cause a denial of service (CPU consumption) via crafted Gregorian dates.
Reference: CVE-2005-1792
Description:
Memory leak by performing actions faster than the software can clear them.
▼Affected Resources
    ▼Functional Areas
    • Cryptography
    ▼Weakness Ordinalities
    OrdinalityDescription
    ▼Detection Methods
    ▼Vulnerability Mapping Notes
    Usage:Allowed-with-Review
    Reason:Abstraction
    Rationale:

    This CWE entry is a Class and might have Base-level children that would be more appropriate

    Comments:

    Examine children of this entry to see if there is a better fit

    Suggestions:
    ▼Notes
    ▼Taxonomy Mappings
    Taxonomy NameEntry IDFitEntry Name
    PLOVERN/AN/AAlgorithmic Complexity
    Taxonomy Name: PLOVER
    Entry ID: N/A
    Fit: N/A
    Entry Name: Algorithmic Complexity
    ▼Related Attack Patterns
    IDName
    ▼References
    Reference ID: REF-395
    Title: Algorithmic Complexity Attacks
    Author: Scott A. Crosby, Dan S. Wallach
    Section:
    Publication:
    Proceedings of the 12th USENIX Security Symposium
    Publisher:
    Edition:
    URL:https://www.usenix.org/legacy/events/sec03/tech/full_papers/crosby/crosby.pdf
    URL Date:
    Day:N/A
    Month:08
    Year:2003
    Reference ID: REF-1164
    Title: Catastrophic backtracking
    Author: Ilya Kantor
    Section:
    Publication:
    Publisher:
    Edition:
    URL:https://javascript.info/regexp-catastrophic-backtracking
    URL Date:
    Day:13
    Month:12
    Year:2020
    Details not found