REGEXVAULTv2.0
Security/Network Security
Verified Safe

CVSS Score (v3.1 Vector String) Regex for JavaScript

/^CVSS:3\.[01]/AV:[NALP]/AC:[LH]/PR:[NLH]/UI:[NR]/S:[UC]/C:[NLH]/I:[NLH]/A:[NLH]$/

What this pattern does

This page provides a well-structured, multi-part regular expression for matching cvss score (v3.1 vector string), ported and verified for JavaScript. 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 JavaScript project — whether you're validating in an Express middleware, a Next.js API route, or a client-side form.

Javascript Implementation

Javascript
// CVSS Score (v3.1 Vector String)
// ReDoS-safe | RegexVault — Security > Network Security

const cvssScoreV31VectorStringRegex = /^CVSS:3\.[01]\/AV:[NALP]\/AC:[LH]\/PR:[NLH]\/UI:[NR]\/S:[UC]\/C:[NLH]\/I:[NLH]\/A:[NLH]$/;

function validateCvssScoreV31VectorString(input: string): boolean {
  return cvssScoreV31VectorStringRegex.test(input);
}

// Example
console.log(validateCvssScoreV31VectorString("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H")); // true

Test Cases

Matches (Valid)
Rejects (Invalid)
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:HCVSS:2.0/AV:N/AC:L/Au:N/C:C/I:C/A:C
CVSS:3.0/AV:L/AC:H/PR:L/UI:R/S:U/C:L/I:N/A:LCVSS:3.1/AV:X/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H

When to use this pattern

This pattern is drawn from the Security > Network Security category and carries a ReDoS-safe certification. That matters for JavaScript developers because especially critical in long-running Node.js event loops where a ReDoS vulnerability can block the entire process. 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

CVSS scores without temporal and environmental adjustments are theoretical. A 9.8 Critical in the NVD may be 3.0 Low in your environment if not internet-facing or if mitigating controls are in place.

Technical Notes

CVSS v3.1 base metrics: AV (Attack Vector: N/A/L/P), AC (Attack Complexity: L/H), PR (Privileges Required: N/L/H), UI (User Interaction: N/R), S (Scope: U/C), C/I/A (Impact: N/L/H). Log4Shell = CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H = 10.0 Critical.

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