|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var CVSS = function (id, options) { |
|
this.options = options; |
|
this.wId = id; |
|
var e = function (tag) { |
|
return document.createElement(tag); |
|
}; |
|
|
|
|
|
this.bg = { |
|
AV: 'Attack Vector', |
|
AC: 'Attack Complexity', |
|
PR: 'Privileges Required', |
|
UI: 'User Interaction', |
|
S: 'Scope', |
|
C: 'Confidentiality', |
|
I: 'Integrity', |
|
A: 'Availability' |
|
}; |
|
|
|
|
|
this.bm = { |
|
AV: { |
|
N: { |
|
l: 'Network', |
|
d: "<b>Worst:</b> The vulnerable component is bound to the network stack and the set of possible attackers extends beyond the other options listed below, up to and including the entire Internet. Such a vulnerability is often termed “remotely exploitable” and can be thought of as an attack being exploitable at the protocol level one or more network hops away (e.g., across one or more routers)." |
|
}, |
|
A: { |
|
l: 'Adjacent', |
|
d: "<b>Worse:</b> The vulnerable component is bound to the network stack, but the attack is limited at the protocol level to a logically adjacent topology. This can mean an attack must be launched from the same shared physical (e.g., Bluetooth or IEEE 802.11) or logical (e.g., local IP subnet) network, or from within a secure or otherwise limited administrative domain (e.g., MPLS, secure VPN to an administrative network zone). One example of an Adjacent attack would be an ARP (IPv4) or neighbor discovery (IPv6) flood leading to a denial of service on the local LAN segment." |
|
}, |
|
L: { |
|
l: 'Local', |
|
d: "<b>Bad:</b> The vulnerable component is not bound to the network stack and the attacker’s path is via read/write/execute capabilities. Either: <ul><li>the attacker exploits the vulnerability by accessing the target system locally (e.g., keyboard, console), or remotely (e.g., SSH);</li><li>or the attacker relies on User Interaction by another person to perform actions required to exploit the vulnerability (e.g., using social engineering techniques to trick a legitimate user into opening a malicious document).</li></ul>" |
|
}, |
|
P: { |
|
l: 'Physical', |
|
d: "<b>Bad:</b> The attack requires the attacker to physically touch or manipulate the vulnerable component. Physical interaction may be brief (e.g., evil maid attack) or persistent. An example of such an attack is a cold boot attack in which an attacker gains access to disk encryption keys after physically accessing the target system. Other examples include peripheral attacks via FireWire/USB Direct Memory Access (DMA)." |
|
} |
|
}, |
|
AC: { |
|
L: { |
|
l: 'Low', |
|
d: "<b>Worst:</b> Specialized access conditions or extenuating circumstances do not exist. An attacker can expect repeatable success when attacking the vulnerable component." |
|
}, |
|
H: { |
|
l: 'High', |
|
d: "<b>Bad:</b> A successful attack depends on conditions beyond the attacker's control. That is, a successful attack cannot be accomplished at will, but requires the attacker to invest in some measurable amount of effort in preparation or execution against the vulnerable component before a successful attack can be expected." |
|
} |
|
}, |
|
PR: { |
|
N: { |
|
l: 'None', |
|
d: "<b>Worst:</b> The attacker is unauthorized prior to attack, and therefore does not require any access to settings or files of the the vulnerable system to carry out an attack." |
|
}, |
|
L: { |
|
l: 'Low', |
|
d: "<b>Worse</b> The attacker requires privileges that provide basic user capabilities that could normally affect only settings and files owned by a user. Alternatively, an attacker with Low privileges has the ability to access only non-sensitive resources." |
|
}, |
|
H: { |
|
l: 'High', |
|
d: "<b>Bad:</b> The attacker requires privileges that provide significant (e.g., administrative) control over the vulnerable component allowing access to component-wide settings and files." |
|
} |
|
}, |
|
UI: { |
|
N: { |
|
l: 'None', |
|
d: "<b>Worst:</b> The vulnerable system can be exploited without interaction from any user." |
|
}, |
|
R: { |
|
l: 'Required', |
|
d: "<b>Bad:</b> Successful exploitation of this vulnerability requires a user to take some action before the vulnerability can be exploited. For example, a successful exploit may only be possible during the installation of an application by a system administrator." |
|
} |
|
}, |
|
|
|
S: { |
|
C: { |
|
l: 'Changed', |
|
d: "<b>Worst:</b> An exploited vulnerability can affect resources beyond the security scope managed by the security authority of the vulnerable component. In this case, the vulnerable component and the impacted component are different and managed by different security authorities." |
|
}, |
|
U: { |
|
l: 'Unchanged', |
|
d: "<b>Bad:</b> An exploited vulnerability can only affect resources managed by the same security authority. In this case, the vulnerable component and the impacted component are either the same, or both are managed by the same security authority." |
|
} |
|
}, |
|
C: { |
|
H: { |
|
l: 'High', |
|
d: "<b>Worst:</b> There is a total loss of confidentiality, resulting in all resources within the impacted component being divulged to the attacker. Alternatively, access to only some restricted information is obtained, but the disclosed information presents a direct, serious impact. For example, an attacker steals the administrator's password, or private encryption keys of a web server." |
|
}, |
|
L: { |
|
l: 'Low', |
|
d: "<b>Bad:</b> There is some loss of confidentiality. Access to some restricted information is obtained, but the attacker does not have control over what information is obtained, or the amount or kind of loss is limited. The information disclosure does not cause a direct, serious loss to the impacted component." |
|
}, |
|
N: { |
|
l: 'None', |
|
d: "<b>Good:</b> There is no loss of confidentiality within the impacted component." |
|
} |
|
}, |
|
I: { |
|
H: { |
|
l: 'High', |
|
d: "<b>Worst:</b> There is a total loss of integrity, or a complete loss of protection. For example, the attacker is able to modify any/all files protected by the impacted component. Alternatively, only some files can be modified, but malicious modification would present a direct, serious consequence to the impacted component." |
|
}, |
|
L: { |
|
l: 'Low', |
|
d: "<b>Bad:</b> Modification of data is possible, but the attacker does not have control over the consequence of a modification, or the amount of modification is limited. The data modification does not have a direct, serious impact on the impacted component." |
|
}, |
|
N: { |
|
l: 'None', |
|
d: "<b>Good:</b> There is no loss of integrity within the impacted component." |
|
} |
|
}, |
|
A: { |
|
H: { |
|
l: 'High', |
|
d: "<b>Worst:</b> There is a total loss of availability, resulting in the attacker being able to fully deny access to resources in the impacted component; this loss is either sustained (while the attacker continues to deliver the attack) or persistent (the condition persists even after the attack has completed). Alternatively, the attacker has the ability to deny some availability, but the loss of availability presents a direct, serious consequence to the impacted component (e.g., the attacker cannot disrupt existing connections, but can prevent new connections; the attacker can repeatedly exploit a vulnerability that, in each instance of a successful attack, leaks a only small amount of memory, but after repeated exploitation causes a service to become completely unavailable)." |
|
}, |
|
L: { |
|
l: 'Low', |
|
d: "<b>Bad:</b> Performance is reduced or there are interruptions in resource availability. Even if repeated exploitation of the vulnerability is possible, the attacker does not have the ability to completely deny service to legitimate users. The resources in the impacted component are either partially available all of the time, or fully available only some of the time, but overall there is no direct, serious consequence to the impacted component." |
|
}, |
|
N: { |
|
l: 'None', |
|
d: "<b>Good:</b> There is no impact to availability within the impacted component." |
|
} |
|
} |
|
}; |
|
|
|
this.bme = {}; |
|
this.bmgReg = { |
|
AV: 'NALP', |
|
AC: 'LH', |
|
PR: 'NLH', |
|
UI: 'NR', |
|
S: 'CU', |
|
C: 'HLN', |
|
I: 'HLN', |
|
A: 'HLN' |
|
}; |
|
this.bmoReg = { |
|
AV: 'NALP', |
|
AC: 'LH', |
|
C: 'C', |
|
I: 'C', |
|
A: 'C' |
|
}; |
|
var s, f, dl, g, dd, l; |
|
this.el = document.getElementById(id); |
|
this.el.appendChild(s = e('style')); |
|
s.innerHTML = ''; |
|
this.el.appendChild(f = e('form')); |
|
f.className = 'cvssjs'; |
|
this.calc = f; |
|
for (g in this.bg) { |
|
f.appendChild(dl = e('dl')); |
|
dl.setAttribute('class', g); |
|
var dt = e('dt'); |
|
dt.innerHTML = this.bg[g]; |
|
dl.appendChild(dt); |
|
for (s in this.bm[g]) { |
|
dd = e('dd'); |
|
dl.appendChild(dd); |
|
var inp = e('input'); |
|
inp.setAttribute('name', g); |
|
inp.setAttribute('value', s); |
|
inp.setAttribute('id', id + g + s); |
|
inp.setAttribute('class', g + s); |
|
|
|
inp.setAttribute('type', 'radio'); |
|
this.bme[g + s] = inp; |
|
var me = this; |
|
inp.onchange = function () { |
|
me.setMetric(this); |
|
}; |
|
dd.appendChild(inp); |
|
l = e('label'); |
|
dd.appendChild(l); |
|
l.setAttribute('for', id + g + s); |
|
l.appendChild(e('i')).setAttribute('class', g + s); |
|
l.appendChild(document.createTextNode(this.bm[g][s].l + ' ')); |
|
dd.appendChild(e('small')).innerHTML = this.bm[g][s].d; |
|
} |
|
} |
|
|
|
f.appendChild(dl = e('dl')); |
|
dl.innerHTML = '<dt>Severity⋅Score⋅Vector</dt>'; |
|
dd = e('dd'); |
|
dl.appendChild(dd); |
|
l = dd.appendChild(e('label')); |
|
l.className = 'results'; |
|
l.appendChild(this.severity = e('span')); |
|
this.severity.className = 'severity'; |
|
l.appendChild(this.score = e('span')); |
|
this.score.className = 'score'; |
|
l.appendChild(document.createTextNode(' ')); |
|
l.appendChild(this.vector = e('a')); |
|
this.vector.className = 'vector'; |
|
this.vector.innerHTML = 'CVSS:3.1/AV:_/AC:_/PR:_/UI:_/S:_/C:_/I:_/A:_'; |
|
|
|
if (options.onsubmit) { |
|
f.appendChild(e('hr')); |
|
this.submitButton = f.appendChild(e('input')); |
|
this.submitButton.setAttribute('type', 'submit'); |
|
this.submitButton.onclick = options.onsubmit; |
|
} |
|
}; |
|
|
|
CVSS.prototype.severityRatings = [{ |
|
name: "None", |
|
bottom: 0.0, |
|
top: 0.0 |
|
}, { |
|
name: "Low", |
|
bottom: 0.1, |
|
top: 3.9 |
|
}, { |
|
name: "Medium", |
|
bottom: 4.0, |
|
top: 6.9 |
|
}, { |
|
name: "High", |
|
bottom: 7.0, |
|
top: 8.9 |
|
}, { |
|
name: "Critical", |
|
bottom: 9.0, |
|
top: 10.0 |
|
}]; |
|
|
|
CVSS.prototype.severityRating = function (score) { |
|
var i; |
|
var severityRatingLength = this.severityRatings.length; |
|
for (i = 0; i < severityRatingLength; i++) { |
|
if (score >= this.severityRatings[i].bottom && score <= this.severityRatings[i].top) { |
|
return this.severityRatings[i]; |
|
} |
|
} |
|
return { |
|
name: "?", |
|
bottom: 'Not', |
|
top: 'defined' |
|
}; |
|
}; |
|
|
|
CVSS.prototype.valueofradio = function(e) { |
|
for(var i = 0; i < e.length; i++) { |
|
if (e[i].checked) { |
|
return e[i].value; |
|
} |
|
} |
|
return null; |
|
}; |
|
|
|
CVSS.prototype.calculate = function () { |
|
var cvssVersion = "3.1"; |
|
var exploitabilityCoefficient = 8.22; |
|
var scopeCoefficient = 1.08; |
|
|
|
|
|
var Weight = { |
|
AV: { |
|
N: 0.85, |
|
A: 0.62, |
|
L: 0.55, |
|
P: 0.2 |
|
}, |
|
AC: { |
|
H: 0.44, |
|
L: 0.77 |
|
}, |
|
PR: { |
|
U: { |
|
N: 0.85, |
|
L: 0.62, |
|
H: 0.27 |
|
}, |
|
|
|
C: { |
|
N: 0.85, |
|
L: 0.68, |
|
H: 0.5 |
|
} |
|
}, |
|
|
|
UI: { |
|
N: 0.85, |
|
R: 0.62 |
|
}, |
|
S: { |
|
U: 6.42, |
|
C: 7.52 |
|
}, |
|
C: { |
|
N: 0, |
|
L: 0.22, |
|
H: 0.56 |
|
}, |
|
I: { |
|
N: 0, |
|
L: 0.22, |
|
H: 0.56 |
|
}, |
|
A: { |
|
N: 0, |
|
L: 0.22, |
|
H: 0.56 |
|
} |
|
|
|
|
|
}; |
|
|
|
var p; |
|
var val = {}, metricWeight = {}; |
|
try { |
|
for (p in this.bg) { |
|
val[p] = this.valueofradio(this.calc.elements[p]); |
|
if (typeof val[p] === "undefined" || val[p] === null) { |
|
return "?"; |
|
} |
|
metricWeight[p] = Weight[p][val[p]]; |
|
} |
|
} catch (err) { |
|
return err; |
|
} |
|
metricWeight.PR = Weight.PR[val.S][val.PR]; |
|
|
|
|
|
|
|
var roundUp1 = function Roundup(input) { |
|
var int_input = Math.round(input * 100000); |
|
if (int_input % 10000 === 0) { |
|
return int_input / 100000 |
|
} else { |
|
return (Math.floor(int_input / 10000) + 1) / 10 |
|
} |
|
}; |
|
try { |
|
var baseScore, impactSubScore, impact, exploitability; |
|
var impactSubScoreMultiplier = (1 - ((1 - metricWeight.C) * (1 - metricWeight.I) * (1 - metricWeight.A))); |
|
if (val.S === 'U') { |
|
impactSubScore = metricWeight.S * impactSubScoreMultiplier; |
|
} else { |
|
impactSubScore = metricWeight.S * (impactSubScoreMultiplier - 0.029) - 3.25 * Math.pow(impactSubScoreMultiplier - 0.02, 15); |
|
} |
|
var exploitabalitySubScore = exploitabilityCoefficient * metricWeight.AV * metricWeight.AC * metricWeight.PR * metricWeight.UI; |
|
if (impactSubScore <= 0) { |
|
baseScore = 0; |
|
} else { |
|
if (val.S === 'U') { |
|
baseScore = roundUp1(Math.min((exploitabalitySubScore + impactSubScore), 10)); |
|
} else { |
|
baseScore = roundUp1(Math.min((exploitabalitySubScore + impactSubScore) * scopeCoefficient, 10)); |
|
} |
|
} |
|
|
|
return baseScore.toFixed(1); |
|
} catch (err) { |
|
return err; |
|
} |
|
}; |
|
|
|
CVSS.prototype.get = function() { |
|
return { |
|
score: this.score.innerHTML, |
|
vector: this.vector.innerHTML |
|
}; |
|
}; |
|
|
|
CVSS.prototype.setMetric = function(a) { |
|
var vectorString = this.vector.innerHTML; |
|
if (/AV:.\/AC:.\/PR:.\/UI:.\/S:.\/C:.\/I:.\/A:./.test(vectorString)) {} else { |
|
vectorString = 'AV:_/AC:_/PR:_/UI:_/S:_/C:_/I:_/A:_'; |
|
} |
|
|
|
var newVec = vectorString.replace(new RegExp('\\b' + a.name + ':.'), a.name + ':' + a.value); |
|
this.set(newVec); |
|
}; |
|
|
|
CVSS.prototype.set = function(vec) { |
|
var newVec = 'CVSS:3.1/'; |
|
var sep = ''; |
|
for (var m in this.bm) { |
|
var match = (new RegExp('\\b(' + m + ':[' + this.bmgReg[m] + '])')).exec(vec); |
|
if (match !== null) { |
|
var check = match[0].replace(':', ''); |
|
this.bme[check].checked = true; |
|
newVec = newVec + sep + match[0]; |
|
} else if ((m in {C:'', I:'', A:''}) && (match = (new RegExp('\\b(' + m + ':C)')).exec(vec)) !== null) { |
|
|
|
this.bme[m + 'H'].checked = true; |
|
newVec = newVec + sep + m + ':H'; |
|
} else { |
|
newVec = newVec + sep + m + ':_'; |
|
for (var j in this.bm[m]) { |
|
this.bme[m + j].checked = false; |
|
} |
|
} |
|
sep = '/'; |
|
} |
|
this.update(newVec); |
|
}; |
|
|
|
CVSS.prototype.update = function(newVec) { |
|
this.vector.innerHTML = newVec; |
|
var s = this.calculate(); |
|
this.score.innerHTML = s; |
|
var rating = this.severityRating(s); |
|
this.severity.className = rating.name + ' severity'; |
|
this.severity.innerHTML = rating.name + '<sub>' + rating.bottom + ' - ' + rating.top + '</sub>'; |
|
this.severity.title = rating.bottom + ' - ' + rating.top; |
|
if (this.options !== undefined && this.options.onchange !== undefined) { |
|
this.options.onchange(); |
|
} |
|
}; |