Skip to content

Fixed Safari cve false positives - #38903

Merged
ksykulev merged 2 commits into
mainfrom
35194-safari-cve
Jan 29, 2026
Merged

Fixed Safari cve false positives#38903
ksykulev merged 2 commits into
mainfrom
35194-safari-cve

Conversation

@ksykulev

@ksykulev ksykulev commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

Related issue: Resolves #35194

The NVD database for CVE-2023-28205 contains two broad CPE match rules:
Safari: Any version < 16.4.1 is vulnerable
macOS: Any version < 13.3.1 is vulnerable

The problem is Safari versions 13.x, 14.x, and 15.x were never actually vulnerable to this CVE and macOS versions 10.x, 11.x, and 12.x never received a system-level fix for this CVE.

Apple fixed the cve in two ways

  1. Safari 16.4.1 standalone update
  2. macOS Ventura 13.3.1 system update fix at the OS level

This is why there is such a complicated IgnoreIf for the CPEMatchingRule.

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information.

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved accuracy of Safari CVE-2023-28205 vulnerability detection with version-specific filtering for Safari 16.0-16.4.0 and macOS Ventura.
  • Tests

    • Added comprehensive test coverage for CVE-2023-28205 across multiple Safari versions and macOS releases.

✏️ Tip: You can customize this high-level summary in your review settings.

@ksykulev
ksykulev requested a review from a team as a code owner January 28, 2026 01:03
@codecov

codecov Bot commented Jan 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.10%. Comparing base (5c11a9f) to head (80911d5).
⚠️ Report is 60 commits behind head on main.

Files with missing lines Patch % Lines
server/vulnerabilities/nvd/cpe_matching_rules.go 83.33% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #38903   +/-   ##
=======================================
  Coverage   66.10%   66.10%           
=======================================
  Files        2420     2420           
  Lines      193439   193457   +18     
  Branches     8434     8434           
=======================================
+ Hits       127865   127878   +13     
- Misses      53970    53977    +7     
+ Partials    11604    11602    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@getvictor getvictor self-assigned this Jan 28, 2026
@ksykulev

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jan 28, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

@coderabbitai

coderabbitai Bot commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR reduces false positives for Safari CVE-2023-28205 by adding a new CPEMatchingRule that filters matches to Apple Safari 16.0–16.4.0 on macOS Ventura 13.3.1+, paired with comprehensive test coverage across multiple macOS and Safari versions.

Changes

Cohort / File(s) Summary
Manifest Updates
go.mod
Dependency manifest updated to support new vulnerability matching logic.
CVE Matching Rules
server/vulnerabilities/nvd/cpe_matching_rules.go
Added new CPEMatchingRule for CVE-2023-28205 with IgnoreIf function implementing version-specific filtering: narrows matches to Safari 16.0–16.4.0 and macOS Ventura with minimum version 13.3.1 to reduce false positives. Introduces imports for strconv and strings to support version comparison logic.
Test Coverage
server/vulnerabilities/nvd/cve_test.go
Expanded TestTranslateCPEToCVE with 73 new lines of test cases covering Safari versions (16.2, 15.6.1, 14.1.2, 13.1.3) and macOS platform scenarios (Ventura 13.2/13.3.1, Monterey 12.7.6/12.6.5, Big Sur 11.7.10/11.7.6, Catalina 10.15.7) to validate CVE-2023-28205 inclusion/exclusion behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • getvictor
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fixed Safari cve false positives' directly relates to the main objective of the PR, which is to reduce false positives for Safari CVE-2023-28205 by implementing refined CPE matching rules.
Description check ✅ Passed The description covers the related issue, explains the problem and solution, and includes completed checklist items. However, manual QA is marked as not done, which may be acceptable depending on project standards.
Linked Issues check ✅ Passed The PR successfully addresses issue #35194 by implementing refined CPE matching logic for CVE-2023-28205 that excludes Safari 13.x-15.x and macOS 10.x-12.x from false positive reporting, aligning with Apple's actual fix distribution.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing CVE-2023-28205 false positives: the changes file, CPE matching rule implementation, and comprehensive test cases are all within scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 35194-safari-cve

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@server/vulnerabilities/nvd/cpe_matching_rules.go`:
- Around line 349-372: The current macOS Ventura version check only compares
patch when parts length >= 3, causing versions like "13.4" to be treated as
vulnerable; update the logic in the block that inspects cpeMeta (after calling
wfn.StripSlashes and splitting into parts) to parse the minor version when
len(parts) >= 2 and treat a missing patch as 0 (i.e., set patchVer = 0 if parts
has only 2 elements), handle Atoi errors consistently, then perform the
comparison (if minorVer > 3 || (minorVer == 3 && patchVer >= 1) return true) so
versions like 13.4 correctly count as >= 13.3.1.
- Around line 332-346: The Safari CPE check in cpe_matching_rules.go currently
only checks major version and misses 16.4.1+; update the block that uses
cpeMeta.Vendor/Product and wfn.StripSlashes to parse version parts (major,
minor, patch) with strconv.Atoi (treat major parse errors as non-match/ignore)
and then: if major != 16 return true (ignore), if minor > 4 return true, if
minor == 4 and patch > 0 return true; otherwise allow the match — ensure
minor/patch parse errors default to 0 so versions like "16.4" are handled
correctly.
🧹 Nitpick comments (2)
server/vulnerabilities/nvd/cve_test.go (2)

371-394: Add a boundary test for Safari 16.4.1 (fixed).
Current cases verify 16.2 (vulnerable) and <16 (not), but don’t assert the fixed build. This would prevent regressions in the ignore logic.

🧪 Suggested test addition
 		"cpe:2.3:a:apple:safari:16.2:*:*:*:*:macos:*:*": {
 			includedCVEs: []cve{
 				{ID: "CVE-2023-28205", resolvedInVersion: "16.4.1"},
 			},
 			continuesToUpdate: true,
 		},
+		"cpe:2.3:a:apple:safari:16.4.1:*:*:*:*:macos:*:*": {
+			excludedCVEs: []string{
+				"CVE-2023-28205",
+			},
+			continuesToUpdate: true,
+		},
 		"cpe:2.3:a:apple:safari:15.6.1:*:*:*:*:macos:*:*": {
 			excludedCVEs: []string{
 				"CVE-2023-28205",
 			},

718-766: Add a Ventura 13.4 boundary test (no patch segment).
This validates that versions >= 13.3.1 are excluded even when only major/minor are present.

🧪 Suggested test addition
 		{
 			platform: "darwin",
 			version:  "13.3.1",
 			osID:     5,
 			// macOS Ventura 13.3.1 includes system-level WebKit patch for CVE-2023-28205
 			excludedCVEs: []string{"CVE-2023-28205"},
 		},
+		{
+			platform: "darwin",
+			version:  "13.4",
+			osID:     11,
+			// macOS Ventura 13.4 includes system-level WebKit patch for CVE-2023-28205
+			excludedCVEs: []string{"CVE-2023-28205"},
+		},

Comment on lines +332 to +346
// For Safari CPE matches, only match versions 16.0-16.4.0
if cpeMeta.Vendor == "apple" && cpeMeta.Product == "safari" {
version := wfn.StripSlashes(cpeMeta.Version)
parts := strings.Split(version, ".")

if len(parts) > 0 {
if majorVer, err := strconv.Atoi(parts[0]); err == nil {
if majorVer < 16 {
return true
}
if majorVer > 16 {
return true
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Safari ignore logic doesn’t exclude fixed versions (16.4.1+).
Only the major version is checked, so 16.4.1 and 16.5+ will still match and be reported vulnerable, which undermines the false‑positive fix.

🛠️ Suggested fix
-					if len(parts) > 0 {
-						if majorVer, err := strconv.Atoi(parts[0]); err == nil {
-							if majorVer < 16 {
-								return true
-							}
-							if majorVer > 16 {
-								return true
-							}
-						}
-					}
+					if len(parts) > 0 {
+						majorVer, err := strconv.Atoi(parts[0])
+						if err != nil {
+							return false
+						}
+						minorVer, patchVer := 0, 0
+						if len(parts) > 1 {
+							if v, err := strconv.Atoi(parts[1]); err == nil {
+								minorVer = v
+							} else {
+								return false
+							}
+						}
+						if len(parts) > 2 {
+							if v, err := strconv.Atoi(parts[2]); err == nil {
+								patchVer = v
+							} else {
+								return false
+							}
+						}
+						if majorVer < 16 || majorVer > 16 ||
+							minorVer > 4 || (minorVer == 4 && patchVer >= 1) {
+							return true
+						}
+					}
🤖 Prompt for AI Agents
In `@server/vulnerabilities/nvd/cpe_matching_rules.go` around lines 332 - 346, The
Safari CPE check in cpe_matching_rules.go currently only checks major version
and misses 16.4.1+; update the block that uses cpeMeta.Vendor/Product and
wfn.StripSlashes to parse version parts (major, minor, patch) with strconv.Atoi
(treat major parse errors as non-match/ignore) and then: if major != 16 return
true (ignore), if minor > 4 return true, if minor == 4 and patch > 0 return
true; otherwise allow the match — ensure minor/patch parse errors default to 0
so versions like "16.4" are handled correctly.

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.

this sounds accurate. I'll make the changes for this.

Comment on lines +349 to +372
// For macOS CPE matches, only match Ventura < 13.3.1
if cpeMeta.Vendor == "apple" && cpeMeta.Product == "macos" {
version := wfn.StripSlashes(cpeMeta.Version)
parts := strings.Split(version, ".")

if len(parts) > 0 {
majorVer, err := strconv.Atoi(parts[0])
if err != nil {
return false
}

// Ignore non-Ventura
if majorVer != 13 {
return true
}

// For Ventura, check if >= 13.3.1
if len(parts) >= 3 {
minorVer, _ := strconv.Atoi(parts[1])
patchVer, _ := strconv.Atoi(parts[2])
if minorVer > 3 || (minorVer == 3 && patchVer >= 1) {
return true
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Ventura >=13.3.1 isn’t ignored when the patch segment is missing (e.g., 13.4).
The check only runs when len(parts) >= 3, so 13.4/13.5 are treated as vulnerable even though they’re >= 13.3.1.

🛠️ Suggested fix
-						// For Ventura, check if >= 13.3.1
-						if len(parts) >= 3 {
-							minorVer, _ := strconv.Atoi(parts[1])
-							patchVer, _ := strconv.Atoi(parts[2])
-							if minorVer > 3 || (minorVer == 3 && patchVer >= 1) {
-								return true
-							}
-						}
+						// For Ventura, check if >= 13.3.1 (treat missing patch as 0)
+						if len(parts) >= 2 {
+							minorVer, err := strconv.Atoi(parts[1])
+							if err != nil {
+								return false
+							}
+							patchVer := 0
+							if len(parts) >= 3 {
+								if v, err := strconv.Atoi(parts[2]); err == nil {
+									patchVer = v
+								} else {
+									return false
+								}
+							}
+							if minorVer > 3 || (minorVer == 3 && patchVer >= 1) {
+								return true
+							}
+						}
🤖 Prompt for AI Agents
In `@server/vulnerabilities/nvd/cpe_matching_rules.go` around lines 349 - 372, The
current macOS Ventura version check only compares patch when parts length >= 3,
causing versions like "13.4" to be treated as vulnerable; update the logic in
the block that inspects cpeMeta (after calling wfn.StripSlashes and splitting
into parts) to parse the minor version when len(parts) >= 2 and treat a missing
patch as 0 (i.e., set patchVer = 0 if parts has only 2 elements), handle Atoi
errors consistently, then perform the comparison (if minorVer > 3 || (minorVer
== 3 && patchVer >= 1) return true) so versions like 13.4 correctly count as >=
13.3.1.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good question/point.

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.

That's assuming the version formats don't have a trailing 0. Such as 13.4.0 or 13.5.0. Let me try to find one that I can spin up on a VM and see what the version looks like

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.

Just double checked.
Screenshot 2026-01-29 at 2 09 45 PM
Screenshot 2026-01-29 at 2 33 33 PM
Screenshot 2026-01-29 at 2 33 50 PM

getvictor
getvictor previously approved these changes Jan 29, 2026

@getvictor getvictor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good overall. See minor comments.

"CVE-2023-28205": {},
},
IgnoreIf: func(cpeMeta *wfn.Attributes) bool {
// For Safari CPE matches, only match versions 16.0-16.4.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this supposed to say: only match versions 16.X?

Comment on lines +349 to +372
// For macOS CPE matches, only match Ventura < 13.3.1
if cpeMeta.Vendor == "apple" && cpeMeta.Product == "macos" {
version := wfn.StripSlashes(cpeMeta.Version)
parts := strings.Split(version, ".")

if len(parts) > 0 {
majorVer, err := strconv.Atoi(parts[0])
if err != nil {
return false
}

// Ignore non-Ventura
if majorVer != 13 {
return true
}

// For Ventura, check if >= 13.3.1
if len(parts) >= 3 {
minorVer, _ := strconv.Atoi(parts[1])
patchVer, _ := strconv.Atoi(parts[2])
if minorVer > 3 || (minorVer == 3 && patchVer >= 1) {
return true
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good question/point.

@ksykulev
ksykulev merged commit 28704fe into main Jan 29, 2026
37 checks passed
@ksykulev
ksykulev deleted the 35194-safari-cve branch January 29, 2026 21:51
georgekarrv pushed a commit that referenced this pull request Feb 6, 2026
**Related issue:** Resolves #35194

The NVD database for CVE-2023-28205 contains two broad CPE match rules:
Safari: Any version < 16.4.1 is vulnerable
macOS: Any version < 13.3.1 is vulnerable

The problem is Safari versions 13.x, 14.x, and 15.x were never actually
vulnerable to this CVE and macOS versions 10.x, 11.x, and 12.x never
received a system-level fix for this CVE.

Apple fixed the cve in two ways
1. Safari 16.4.1 standalone update
2. macOS Ventura 13.3.1 system update fix at the OS level

This is why there is such a complicated `IgnoreIf` for the
`CPEMatchingRule`.

If some of the following don't apply, delete the relevant line.
- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

## Testing

- [x] Added/updated automated tests
- [ ] QA'd all new/changed functionality manually

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

* **Bug Fixes**
* Improved accuracy of Safari CVE-2023-28205 vulnerability detection
with version-specific filtering for Safari 16.0-16.4.0 and macOS
Ventura.

* **Tests**
* Added comprehensive test coverage for CVE-2023-28205 across multiple
Safari versions and macOS releases.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

Safari CVE false positives

2 participants