Skip to content

add CVSS 3.1 temporalMetrics and environmentalMetrics#322

Open
dancewithheart wants to merge 9 commits intohaskell:mainfrom
dancewithheart:temporal-env-cvss31
Open

add CVSS 3.1 temporalMetrics and environmentalMetrics#322
dancewithheart wants to merge 9 commits intohaskell:mainfrom
dancewithheart:temporal-env-cvss31

Conversation

@dancewithheart
Copy link
Copy Markdown
Contributor

Fix #226

  • adds missing CVSS 3.1 temporal and environmental metrics
  • property test for round trip between CVSS.parseCVSS and CVSS.cvssVectorString
  • computing cvssScore is not changed

Many environmental metrics are modified base metrics - I reused code - hence lots of changes.

Advisory

  • It's not duplicated
  • All fields are filled
  • It is validated by hsec-tools

hsec-tools

  • Previous advisories are still valid

Copy link
Copy Markdown
Collaborator

@blackheaven blackheaven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution.

Two small adjustments, and I think I have spotted a bug, can you have a look please?

Comment thread code/cvss/test/Spec.hs Outdated
, ("AV:N/AC:M/Au:N/C:P/I:N/A:N", 4.3, CVSS.Medium)
, ("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:X/RL:X/RC:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MPR:X/MUI:X/MS:X/MC:X/MI:X/MA:X"
, 9.8, CVSS.Critical)
, ("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:F/RL:O/RC:R", 9.8, CVSS.Critical)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
, ("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:F/RL:O/RC:R", 9.8, CVSS.Critical)
, ("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:F/RL:O/RC:R", 8.7, CVSS.Critical)

Using https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator

Actually the formula should be Roundup(9.8 x 0.97 x 0.95 x 0.96) = 8.7 (High)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, what you describe is the formula for temporal score:

Roundup(BaseScore × ExploitCodeMaturity × RemediationLevel × ReportConfidence)

and it gives 8.7.

Current value 9.8 is a correct calculation of base score. I wanted to show example of current behavior and
I was not sure if I should add temporalScore, envionmentalScore and modify cvssScore in this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked around - it looks like overall score not base score is used:

  1. https://app.opencve.io/cve/CVE-2024-48886
cvssV3_1 {'score': 8, 'vector': 'CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H/E:F/RL:O/RC:R'}
Score: 8 High

computations:

CVSS Base Score: 9.0
Impact Subscore: 6.0
Exploitability Subscore: 2.2
CVSS Temporal Score: 8.0
CVSS Environmental Score: NA
Modified Impact Subscore: NA
Overall CVSS Score: 8.0
  1. https://www.cve.org/CVERecord?id=CVE-2023-40718
SCORE 6.7
SEVERITY	MEDIUM
VECTOR CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N/E:F/RL:O/RC:R

computations:

CVSS Base Score: 7.5
Impact Subscore: 3.6
Exploitability Subscore: 3.9
CVSS Temporal Score: 6.7
CVSS Environmental Score: NA
Modified Impact Subscore: NA
Overall CVSS Score: 6.7

I think the design should be:

cvss31baseScore :: [Metric] -> (Rating, Float) -- current cvss31score
cvss31temporalScore  :: [Metric] -> (Rating, Float)
cvss31environmentalScore :: [Metric] -> (Rating, Float)

Then cvss31score could be computed as
cvss31environmentalScore if present otherwise
cvss31temporalScore if present otherwise
cvss31baseScore.

And then the tests will be expect (8.7, High)

Comment thread code/cvss/src/Security/CVSS.hs Outdated

gm :: Text -> Float
gm = getMetricValue cvss31 metrics scope

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


-- FUTUREWORK: The 'scope' parameter is always the base Scope metric. Once                                                                                                                                                             
-- environmental scoring is implemented, Modified Privileges Required (MPR)                                                                                                                                                            
-- use Modified Scope (MS) instead of base Scope per spec Section 4.2:                                                                                                                                                            
-- "if Scope / Modified Scope is Changed". The caller (or this function) will                                                                                                                                                          
-- need to resolve MS when looking up scope-dependent values for MPR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this comment.

@dancewithheart
Copy link
Copy Markdown
Contributor Author

Added computing EnvironmentalScore and TemporalScore

@dancewithheart dancewithheart requested a review from blackheaven May 4, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CVSS3.1 isn't fully supported

2 participants