Skip to content

securitypolicy: honor LCOW AMD certificate annotation - #2962

Open
Emanuel Oprea (EmanuelOprea) wants to merge 2 commits into
microsoft:mainfrom
EmanuelOprea:dev/emanueloprea/lcow-amd-cert-annotation-upstream
Open

Emanuel Oprea (EmanuelOprea) wants to merge 2 commits into
microsoft:mainfrom
EmanuelOprea:dev/emanueloprea/lcow-amd-cert-annotation-upstream

Conversation

@EmanuelOprea

Copy link
Copy Markdown
Contributor

Problem

SecurityOptions.WriteSecurityContextDir is shared by the LCOW guest and the WCOW GCS sidecar, but currently reads the host AMD certificate only from annotations.WCOWHostAMDCertificate. A certificate supplied under annotations.LCOWHostAMDCertificate is silently omitted from host-amd-cert-base64. If the certificate is the only security-context input, no directory or UVM_SECURITY_CONTEXT_DIR environment variable is created.

Change and compatibility

Read LCOWHostAMDCertificate first and fall back to WCOWHostAMDCertificate when the LCOW value is missing or empty.

This ports the downstream LCOW annotation fix with one deliberate upstream compatibility adjustment: retain the existing WCOW lookup as a fallback rather than removing it. HostAMDCertificate is a deprecated alias of LCOWHostAMDCertificate, not a separate annotation key, so no additional generic-key fallback is needed. When both keys are non-empty, LCOW takes precedence.

The existing policy, UVM reference information, hash-envelope reference information, TCB/platform reference information, directory handling, and environment injection remain unchanged. No caller, annotation definition, dependency, or file-permission changes are included.

Regression coverage

A platform-neutral table-driven test covers LCOW, the deprecated generic alias, WCOW-only inputs, conflicting values, empty LCOW fallback, nil/empty annotations, and empty certificate values. Each case runs both with the certificate alone and alongside the other security-context inputs, checking exact file contents, directory creation/no-op behavior, and environment preservation.

Before the fix, the LCOW, generic-alias, and conflicting-value cases failed on both Windows and Linux. All 16 leaf cases pass after the fix.

Validation

Validated with Go 1.26.8 on Windows/amd64 and Linux/amd64:

  • go test -v ./pkg/securitypolicy -run '^TestWriteSecurityContextDirAMDCertificate$' -count=1
  • go test -tags=rego -timeout=30m ./pkg/securitypolicy/...
  • Windows: go build -tags=rego ./cmd/gcs-sidecar
  • Linux: go build -tags=rego ./cmd/gcs
  • gofmt and git diff --check

No live SEV-SNP workload or attestation end-to-end validation was performed for this upstream port. This PR is intentionally opened as a draft for review.

Read the LCOW AMD certificate annotation when writing the shared security context, while retaining the WCOW annotation as a fallback for existing callers. The deprecated generic annotation already aliases the LCOW key. Add cross-platform regression coverage for certificate selection, empty inputs, and preservation of the other context files and environment.

Validation: reproduced the regression before the fix on Windows and Linux; the targeted tests and Rego securitypolicy suites pass on both platforms, and the Windows GCS sidecar and Linux GCS build successfully with Go 1.26.8.
Signed-off-by: Emanuel Oprea <[email protected]>
Keep the deprecated alias compatibility case and scope the staticcheck SA1019 exception to its intentional use. This follows existing repository lint conventions without weakening checks for the rest of the test or changing runtime behavior.

Validation: the targeted certificate regression test passes, and golangci-lint 2.11.4 reports zero issues for pkg/securitypolicy on Windows default, LCOW and WCOW tags and Linux default tags.
Signed-off-by: Emanuel Oprea <[email protected]>
@EmanuelOprea
Emanuel Oprea (EmanuelOprea) force-pushed the dev/emanueloprea/lcow-amd-cert-annotation-upstream branch from 1910374 to 21489bd Compare October 13, 2026 10:05
@EmanuelOprea
Emanuel Oprea (EmanuelOprea) marked this pull request as ready for review October 14, 2026 14:00
@EmanuelOprea
Emanuel Oprea (EmanuelOprea) requested a review from a team as a code owner October 14, 2026 14:00
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.

1 participant