RedHatProductSecurity / cvss-v4-calculator

CVSS v4.0 calculator
https://redhatproductsecurity.github.io/cvss-v4-calculator/
BSD 2-Clause "Simplified" License
32 stars 22 forks source link

Bug/compliance: metrics could be defined more than once #24

Closed pandatix closed 10 months ago

pandatix commented 1 year ago

Hello, according to the currently published specification section "Vector String" it is stated that "A vector string must not include the same metric more than once".

Nevertheless, after #1 you could provide the vector string from the URL as the previous FIRST calculators does (great feature btw 👍 ). Using this, you could provide, for instance, the vector CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:N/SI:N/SA:N/AV:A with AV metric defined twice (head and tail) through the URL https://redhatproductsecurity.github.io/cvss-v4-calculator/#CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:N/SI:N/SA:N/AV:A, which is then parsed and supposed valid.

Due to the current parsing the last time a metric is specified in input, the corresponding value is set. This could be considered part of CWE-20.

Such bug/compliance issue is common in CVSS implementations as I observed through many others, and you should consider ensuring each metric is defined at most once (maybe using a map by checking it has not been already processed).