CVSS Scoring System
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The CVSS (Common Vulnerability Scoring System) Scoring System in 2ms is a quantitative framework used to prioritize the remediation of discovered secrets. It assigns a numerical score to each finding based on the severity of the exposed credential and its current validity status. This system ensures that security teams can focus on high-risk exposures, such as valid administrative tokens, before addressing low-risk items like invalid or low-impact credentials.
The scoring logic integrates directly with the scanning engine, utilizing metadata from defined rules and optional real-time validity checks. By combining a base risk score (derived from the credential category) with a validity modifier, the system produces a standardized score that reflects the actual threat level of a secret finding. Sources: README.md:16-18, engine/score/score.go:49-53
Architecture and Logic
The scoring system operates by evaluating two primary inputs: the rule's inherent risk and the secret's validation status.
Scoring Components
- Base Risk Score: A combination of the rule's category and the rule type. Categories represent the service type (e.g., Cloud Platform, Social Media), while Rule Type typically distinguishes between public identifiers (Type 1) and private secrets (Type 4). Sources: engine/rules/rules.go:94-200, engine/score/score.go:44-47
- Validity Modifier: An adjustment made to the score based on whether the secret is confirmed as
Valid,Invalid, orUnknown. Sources: engine/score/score.go:35-42
Scoring Calculation Flow
The calculation follows a specific mathematical formula to arrive at the final CVSS score, which is rounded to one decimal place.
The diagram shows how rule metadata and secret discovery results converge to produce the final risk score. Sources: engine/score/score.go:44-53
Data Structures and Functions
Key Functions
| Function | Description | File Path |
|---|---|---|
GetBaseRiskScore | Calculates initial risk based on category (60% weight) and rule type (40% weight). | engine/score/score.go:44-47 |
getCategoryScore | Maps RuleCategory to a predefined integer value (1-4). | engine/score/score.go:9-42 |
getValidityScore | Determines the score modifier based on ValidationResult. | engine/score/score.go:35-42 |
GetCvssScore | The main formula: ((BaseRisk + ValidityMod - 1) * 3) + 1. | engine/score/score.go:49-53 |
Category Weights
Categories are assigned values based on the sensitivity of the service:
- Level 4 (Critical): Authentication, Financial Services, Payment Processing, Security.
- Level 3 (High): Cloud Platforms, Databases, CI/CD, Source Code Management.
- Level 2 (Medium): Content Management, SaaS, Networking, File Storage.
- Level 1 (Low): Social Media, Marketing Automation, Project Management.
Sources: engine/score/score.go:10-41
Integration with Scanning Workers
The scoring system is executed within the scanning pipeline. If the --validate flag is enabled, the system waits for the validator to return a status before finalizing the score.
Sources: engine/engine.go:121-129, cmd/workers.go:56-66
Scoring Examples
Based on the test suite, the following scores are expected for common rule types:
| Rule ID | Valid Status | Invalid Status | Unknown Status |
|---|---|---|---|
aws | 10.0 | 7.0 | 10.0 |
github-pat | 10.0 | 5.2 | 8.2 |
discord-client-id | 4.0 | 1.0 | 1.0 |
google-cloud-api-key | 10.0 | 5.2 | 8.2 |
Sources: engine/score/score_test.go:31-155
Formula Snippet
func GetCvssScore(baseRiskScore float64, validationStatus secrets.ValidationResult) float64 {
validityScore := getValidityScore(baseRiskScore, validationStatus)
cvssScore := (baseRiskScore+validityScore-1)*3 + 1
return math.Round(cvssScore*10) / 10
}
Sources: engine/score/score.go:49-53
Summary
The CVSS Scoring System provides 2ms with a technical and objective method for risk assessment. By weighing the service category and applying modifiers for verified validity, the system generates actionable intelligence for developers. This allows for an automated triage process where the most dangerous exposures (Valid Level 4 credentials) are immediately identifiable by their maximum score of 10.0. Sources: engine/score/score.go:1-53, engine/engine.go:121-129