VariantIncomplete

CWE-777Regular Expression without Anchors

Category: other

Description

The product uses a regular expression to perform neutralization, but the regular expression is not anchored and may allow malicious or malformed data to slip through. When performing tasks such as validating against a set of allowed inputs (allowlist), data is examined and possibly modified to ensure that it is well-formed and adheres to a list of safe values. If the regular expression is not anchored, malicious or malformed data may be included before or after any string matching the regular expression. The type of malicious data that is allowed will depend on the context of the application and which anchors are omitted from the regular expression.

Common consequences· 1

  • Availability / Confidentiality / Access Control — Bypass Protection Mechanism
    An unanchored regular expression in the context of an allowlist will possibly result in a protection mechanism failure, allowing malicious or malformed data to enter trusted regions of the program. The specific consequences will depend on what functionality the allowlist was protecting.

Potential mitigations· 1

  • [Implementation]Be sure to understand both what will be matched and what will not be matched by a regular expression. Anchoring the ends of the expression will allow the programmer to define an allowlist strictly limited to what is matched by the text in the regular expression. If you are using a package that only matches one line by default, ensure that you can match multi-line inputs if necessary.

References

  1. https://cwe.mitre.org/data/definitions/777.html

Related by meaning· 6

Nearest entities by semantic similarity across the cs-graph corpus.

CWE
Incorrect Regular Expression
CWE
Improper Neutralization of Alternate XSS Syntax
CWE
Improper Neutralization of Data within XPath Expressions ('XPath Injection')
CWE
Improper Neutralization of Wildcards or Matching Symbols
CWE
Improper Neutralization of Data within XQuery Expressions ('XQuery Injection')
CWE
Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)
Sourced from MITRE CWE 4.20. Curated for EU compliance use cases by Adam Lundqvist, Founder at SQUR.