Skip to content

Windows SCEP profile validation accepts CERTIFICATE_RENEWAL_ID (PR 7/9)#45237

Merged
mostlikelee merged 21 commits into
40639-cert-renewfrom
pr-2.4-windows-validation
May 14, 2026
Merged

Windows SCEP profile validation accepts CERTIFICATE_RENEWAL_ID (PR 7/9)#45237
mostlikelee merged 21 commits into
40639-cert-renewfrom
pr-2.4-windows-validation

Conversation

@mostlikelee
Copy link
Copy Markdown
Contributor

@mostlikelee mostlikelee commented May 12, 2026

Related issue: Resolves #44347

What this PR does

Extends the SubjectName OU= check in both Windows SCEP validators (NDES, Custom SCEP) to accept either \$FLEET_VAR_CERTIFICATE_RENEWAL_ID (preferred) or the legacy \$FLEET_VAR_SCEP_RENEWAL_ID. Validation error messages reference only the preferred name.

Why this is needed

Pre-existing Windows SCEP validation only accepted \$FLEET_VAR_SCEP_RENEWAL_ID. The variable was renamed customer-facing to \$FLEET_VAR_CERTIFICATE_RENEWAL_ID (docs PR #44069); without this change, Windows would reject customers who follow the new docs.

Why preferred + legacy here, preferred-only on Apple

Per Decision 2.7's net-new-vs-pre-existing rule:

Checklist for submitter

  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements)

Testing

  • Added/updated automated tests

Summary by CodeRabbit

  • New Features
    • Added support for the CERTIFICATE_RENEWAL_ID Fleet variable in Windows MDM configuration profiles, alongside the existing legacy SCEP renewal variable.
    • Both standard prefix syntax and brace-enclosed variable formats are now supported.
    • Enhanced validation for NDES and custom SCEP configurations to recognize the new renewal variable.
    • Updated validation error messages for clearer reference to the certificate renewal variable.

Review Change Stack

mostlikelee added 14 commits May 8, 2026 11:17
Two related changes that prepare Apple profile uploads for the non-proxied
renewal flow:

1. Add `$FLEET_VAR_CERTIFICATE_RENEWAL_ID` as the preferred name for the
   renewal-ID marker variable (per docs PR #44069). The legacy
   `$FLEET_VAR_SCEP_RENEWAL_ID` is still accepted by validation and
   substitution for back-compat with existing profiles. Both names
   substitute to the same value: "fleet-" + profile_uuid.

2. Add additionalACMEValidation: any profile containing a
   com.apple.security.acme payload must include either renewal-ID
   variable in the cert Subject's CN or OU, otherwise the upload is
   rejected. Without the marker the resulting cert can't be linked back
   to its profile and would never auto-renew.

The shared SCEP-renewal-ID-without-URL/Challenge guard in
mdm_profiles.go skips its check when an ACME payload is present —
ACME profiles use the marker variable alone (no SCEP URL/Challenge
companions).

Validation error messages reference only the new
CERTIFICATE_RENEWAL_ID name to steer new authoring toward it.
The validation error messages in mdm_profiles.go switched to reference
the preferred CERTIFICATE_RENEWAL_ID name. The unit and integration
test assertions still required the legacy SCEP_RENEWAL_ID text.
Updating them to match.
Decision 2.7 requires profile validation to keep accepting the
pre-rename variable name. The existing failure-case tests don't
guard that contract because they all exercise error paths. Add a
happy-path case asserting that a Custom SCEP profile authored with
$FLEET_VAR_SCEP_RENEWAL_ID validates successfully when all other
required variables are present.
The renewal-ID-only bypass in validateProfileCertificateAuthorityVariables
checked the profile body with strings.Contains, which would false-positive
on "com.apple.security.acme" appearing in a description, identifier, or
custom string field. Switch to the existing Mobileconfig.HasPayloadType
helper for a structured plist parse. Parse failure (e.g., Windows-path
content that isn't a mobileconfig) is treated as no-ACME, so the SCEP-only
error fires normally on that path.
Extend the SubjectName OU= check in additionalNDESValidationForWindowsProfiles
and additionalCustomSCEPValidationForWindowsProfiles to accept either the
preferred $FLEET_VAR_CERTIFICATE_RENEWAL_ID or the legacy
$FLEET_VAR_SCEP_RENEWAL_ID. Error messages reference only the preferred
variable name. New constant added to fleetVarsSupportedInWindowsProfiles.
@mostlikelee
Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

Walkthrough

Windows MDM profile validation now recognizes the CERTIFICATE_RENEWAL_ID Fleet variable in SubjectName OU fields for renewal-ID markers. A new helper function detects this variable alongside the legacy SCEP_RENEWAL_ID format in both prefix and brace syntaxes. NDES and custom SCEP profile validations replace legacy-only checks with this helper, and error messages reference the preferred CERTIFICATE_RENEWAL_ID variable. Tests updated to verify both syntaxes and expect the new variable name in validation failures.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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
Linked Issues check ✅ Passed The PR directly addresses #44347 by implementing Windows SCEP profile validation to accept CERTIFICATE_RENEWAL_ID while maintaining backward compatibility with legacy SCEP_RENEWAL_ID.
Out of Scope Changes check ✅ Passed All changes are scoped to Windows SCEP profile validation and related tests, directly addressing the requirements in #44347 with no extraneous modifications.
Description check ✅ Passed PR description is complete with issue reference, clear explanation of changes, rationale, and testing confirmation, though changes file checklist item is unmarked.
Title check ✅ Passed The title clearly summarizes the main change: extending Windows SCEP profile validation to accept the CERTIFICATE_RENEWAL_ID variable, which matches the primary purpose of the changeset.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pr-2.4-windows-validation

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (40639-cert-renew@2f73475). Learn more about missing BASE report.

Files with missing lines Patch % Lines
server/service/windows_mdm_profiles.go 77.77% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##             40639-cert-renew   #45237   +/-   ##
===================================================
  Coverage                    ?   66.75%           
===================================================
  Files                       ?     2730           
  Lines                       ?   218570           
  Branches                    ?    10703           
===================================================
  Hits                        ?   145913           
  Misses                      ?    59447           
  Partials                    ?    13210           
Flag Coverage Δ
backend 68.61% <77.77%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Base automatically changed from pr-2.3-apple-validation-rename to 40639-cert-renew May 12, 2026 22:10
…aw-scep-validation

# Conflicts:
#	server/fleet/mdm.go
#	server/service/apple_mdm.go
#	server/service/apple_mdm_test.go
Reject raw-SCEP profiles (com.apple.security.scep payload, no Fleet
proxy variables) whose Subject OU lacks $FLEET_VAR_CERTIFICATE_RENEWAL_ID.
Profiles using Fleet proxy variables (NDES/Custom SCEP/Smallstep) keep
their existing per-CA validators.

Net-new validator: OU placement only, preferred variable name only —
no back-compat owed on a surface that didn't previously enforce
renewal-ID at all.

Also broadens the validateConfigProfileFleetVariables bypass to recognize
both ACME and SCEP payloads via mobileconfig.HasPayloadType.
@mostlikelee mostlikelee changed the title Windows SCEP profile validation accepts CERTIFICATE_RENEWAL_ID (PR 7/8) Windows SCEP profile validation accepts CERTIFICATE_RENEWAL_ID (PR 7/9) May 13, 2026
@mostlikelee mostlikelee marked this pull request as ready for review May 13, 2026 19:59
@mostlikelee mostlikelee requested a review from a team as a code owner May 13, 2026 19:59
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

Copy link
Copy Markdown
Contributor

@sgress454 sgress454 left a comment

Choose a reason for hiding this comment

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

looks good, did a quick search in the feature branch for FleetVarSCEPRenewalID and it looks like all the other relevant cases are covered 👍

@mostlikelee mostlikelee merged commit 1158a1d into 40639-cert-renew May 14, 2026
88 of 92 checks passed
@mostlikelee mostlikelee deleted the pr-2.4-windows-validation branch May 14, 2026 16:29
mostlikelee added a commit that referenced this pull request May 14, 2026
… 1.4)

Status sweep:
- PR 2.1 (#44344), PR 2.2 (#44345), PR 2.3 (#45043), PR 2.3b
  (#45364), PR 2.4 (#45237) all merged — task lists in §5/§6/§7/§7b/§8
  now reflect completion. Items deferred to PR 2.5 (release notes) stay
  open.
- §10.1 annotated with the 2026-05-14 local end-to-end validation
  result. Hydrant verification still required for customer readiness.

New refinement — Decision 1.4 and §7c (PR 2.3c):
- Surfaced during local validation: a user-installed Root CA ended up
  with origin=mdm because MDM CertificateList returned the entire
  keychain on InstallProfile ack, beating the next osquery sync.
- Decision: osquery sync downgrades existing origin=mdm rows to
  origin=osquery when it also observes them. One-way (mdm → osquery,
  never reverse).
- Rationale: osquery sees a strict superset of MDM CertificateList,
  so observation by both implies the cert is in the device keychain
  by some path — not evidence of MDM delivery. Origin should reflect
  "did Fleet deliver this?", not "who saw it first?"
- Renewal correctness is unaffected; matcher keys on the
  fleet-<profile_uuid> marker, not on origin.
mostlikelee added a commit that referenced this pull request May 15, 2026
Adds end-to-end coverage for the public profile-upload API surface
under Decision 2.6 (marker is opt-in). Four tests:

- TestACMEProfileUploadAcceptsAllMarkerPlacements: 4-case matrix
  (preferred/legacy/no-marker × OU/CN placement) confirms acceptance
  across the board for com.apple.security.acme profiles.
- TestRawSCEPProfileUploadAcceptsAllMarkerPlacements: same matrix for
  com.apple.security.scep payloads without Fleet proxy variables.
- TestConditionalAccessProfileUploadsCleanly: renders Fleet's generated
  Conditional Access SCEP profile and confirms clean upload via custom
  OS settings.
- TestWindowsSCEPProfilePreferredVariableAccepted: covers PR #45237's
  pre-existing-surface back-compat (NDES / Custom SCEP proxy SCEP
  accept the preferred variable name).
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.

Windows profile-upload validation for renewal-ID marker (sub-task of #40639)

2 participants