ShieldX Toolly
Open a tool Donate
Home Home
Blog Blog
FAQ FAQ
Open a tool Donate
Back to cheatsheets
Web Security

CVSS v3.1 Scoring

Calculate CVSS v3.1 base scores with vector string generation and severity ratings.

2 snippets Intermediate cvss-calculator
CVSSvulnerabilityscoringvector string

What you'll learn

  • CVSS base score calculation
  • Vector string format

How to use these snippets

  1. Click the Copy button next to any snippet to copy it to your clipboard.
  2. Paste the code into your project, IDE, or terminal.
  3. Replace placeholder values (like example.com or your-secret) with your actual data.
  4. Review the code comments for important security notes and caveats.
  5. Try the interactive related tool to see the concept in action.
Code Snippets

Copy-paste code snippets

2 ready-to-use snippets for cvss v3.1 scoring. Click copy and paste into your project.

CVSS base score calculation
                // CVSS v3.1 Base Score
function cvssBaseScore(metrics) {
  const { AV, AC, PR, UI, S, C, I, A } = metrics;

  // Impact
  const iss = 1 - ((1 - C) * (1 - I) * (1 - A));
  const impact = S === 1 ?
    7.52 * (iss - 0.029) - 3.25 * Math.pow(iss - 0.02, 15) :
    6.42 * iss;

  // Exploitability
  const avWeight = { N: 0.85, A: 0.62, L: 0.55, P: 0.2 };
  const acWeight = { L: 0.77, H: 0.44 };
  const prWeight = S === 1 ?
    { N: 0.85, L: 0.68, H: 0.5 } :
    { N: 0.85, L: 0.62, H: 0.27 };
  const uiWeight = { N: 0.85, R: 0.62 };

  const exploitability = 8.22 *
    avWeight[AV] * acWeight[AC] *
    prWeight[PR] * uiWeight[UI];

  if (impact <= 0) return 0;
  return S === 1 ?
    Math.min(10, 1.08 * (impact + exploitability)) :
    Math.min(10, impact + exploitability);
}
              
Vector string format
                // CVSS v3.1 Vector String
// CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
//
// AV: Attack Vector (N=Network, A=Adjacent, L=Local, P=Physical)
// AC: Attack Complexity (L=Low, H=High)
// PR: Privileges Required (N=None, L=Low, H=High)
// UI: User Interaction (N=None, R=Required)
// S:  Scope (U=Unchanged, C=Changed)
// C:  Confidentiality (H=High, L=Low, N=None)
// I:  Integrity (H=High, L=Low, N=None)
// A:  Availability (H=High, L=Low, N=None)
//
// Severity: 0.0=None, 0.1-3.9=Low, 4.0-6.9=Medium,
//           7.0-8.9=High, 9.0-10.0=Critical
              
Tool

Try this concept hands-on with the interactive tool.

100% Free · No signup · No cost

Generate something unguessable right now

148 bits of entropy, a crack-time estimate you can trust, and a clipboard that clears itself after 30 seconds.

Open the toolkit

Part of the Toolly ecosystem · secure.toolly.site