OWASP Top 10 Reference Regex for Java
/^A(?:0[1-9]|10):2021$/iWhat this pattern does
This page provides a lightweight, single-purpose regular expression for matching owasp top 10 reference, ported and verified for Java. In security-sensitive code, using an unverified regex can open the door to both false positives and denial-of-service attacks. The snippet below is ready to drop into your Java project — whether you're validating in a Spring Boot controller, a Jakarta EE service, or a standalone utility class.
Java Implementation
// OWASP Top 10 Reference
// ReDoS-safe | RegexVault — Security > Audit & Compliance
import java.util.regex.Pattern;
public class OwaspTop10ReferenceValidator {
private static final Pattern PATTERN =
Pattern.compile("^A(?:0[1-9]|10):2021$");
public static boolean validate(String input) {
return PATTERN.matcher(input).matches();
}
// Example
public static void main(String[] args) {
System.out.println(validate("A01:2021")); // true
}
}Test Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
A01:2021 | A00:2021 |
A03:2021 | A11:2021 |
A10:2021 | A01:2023 |
| — | A1:2021 |
| — | A01-2021 |
When to use this pattern
This pattern is drawn from the Security > Audit & Compliance category and carries a ReDoS-safe certification. That matters for Java developers because critical in Java applications since the JVM regex engine uses backtracking and is susceptible to ReDoS without careful pattern design. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.
Common Pitfalls
OWASP Top 10 editions (2013, 2017, 2021) have different category numbering and content. Specify the year edition when referencing. The 2021 list elevated A04 Insecure Design as a new category.
Technical Notes
OWASP Top 10 2021: A01=Broken Access Control, A02=Cryptographic Failures, A03=Injection, A04=Insecure Design, A05=Security Misconfiguration, A06=Vulnerable/Outdated Components, A07=Identification/Authentication Failures, A08=Software/Data Integrity Failures, A09=Security Logging/Monitoring Failures, A10=Server-Side Request Forgery.
Have a pattern that belongs in the vault?
Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.
Submit a Pattern