REGEXVAULTv2.0
Security/Audit & Compliance
Verified Safe

OWASP Top 10 Reference Regex for PHP

/^A(?:0[1-9]|10):2021$/i

What this pattern does

This page provides a lightweight, single-purpose regular expression for matching owasp top 10 reference, ported and verified for PHP. 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 PHP project — whether you're validating in a Laravel validator, a WordPress plugin, or a standalone PHP script.

Php Implementation

Php
<?php
// OWASP Top 10 Reference
// ReDoS-safe | RegexVault — Security > Audit & Compliance

define('OWASP_TOP_10_REFERENCE_PATTERN', '/^A(?:0[1-9]|10):2021$/');

function validate_owasp_top_10_reference(string $input): bool {
    return (bool) preg_match(OWASP_TOP_10_REFERENCE_PATTERN, $input);
}

// Example
var_dump(validate_owasp_top_10_reference("A01:2021")); // bool(true)

Test Cases

Matches (Valid)
Rejects (Invalid)
A01:2021A00:2021
A03:2021A11:2021
A10:2021A01: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 PHP developers because especially relevant in PHP where PCRE backtracking limits can trigger silent failures on malicious input. 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