REGEXVAULTv2.0
Security/Network Security
Verified Safe

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

/^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 Go. 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 Go project — whether you're validating in a Gin handler, a gRPC service, or a command-line tool.

Go Implementation

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

package validation

import "regexp"

var cvssScoreV31VectorStringRe = regexp.MustCompile(`^CVSS:3\.[01]/AV:[NALP]/AC:[LH]/PR:[NLH]/UI:[NR]/S:[UC]/C:[NLH]/I:[NLH]/A:[NLH]$`)

func ValidateCvssScoreV31VectorString(s string) bool {
    return cvssScoreV31VectorStringRe.MatchString(s)
}

// Example
// fmt.Println(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 Go developers because Go's RE2 engine is inherently safe from catastrophic backtracking, but this pattern has been additionally verified for correctness. 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