fix: read TPP's PkixParameterSet key-algorithm policy (25.1+) - #682
Open
wallrj-cyberark wants to merge 2 commits into
Open
fix: read TPP's PkixParameterSet key-algorithm policy (25.1+)#682wallrj-cyberark wants to merge 2 commits into
wallrj-cyberark wants to merge 2 commits into
Conversation
From TPP 25.1 onwards, the Certificates/CheckPolicy endpoint no longer locks the deprecated KeyPair.KeyAlgorithm/KeySize/EllipticCurve fields when a policy folder's allowed key algorithms are configured via the newer AlgorithmSelector API. Instead, the allowed algorithms are expressed as a list of PKIX OIDs in KeyPair.PkixParameterSet.Values, which vcert did not read at all - so every TPP 25.1+ policy folder looked unrestricted to endpoint.Policy.AllowedKeyConfigurations, regardless of what an administrator had configured, and callers enforcing that policy (e.g. approver-policy-enterprise) silently allowed certificate requests with the wrong key type or a weak key size. This adds a PkixParameterSet field to serverPolicy.KeyPair, a reverse lookup table from the PKIX OIDs to key type/size/curve, and prefers KeyPair.PkixParameterSet.Values when locked, falling back to the deprecated fields for older TPP versions. Signed-off-by: Richard Wall <richard.wall@cyberark.com>
serverPolicy.toPolicy() (used by ReadPolicyConfiguration/ ReadZoneConfiguration, i.e. certificate-request policy enforcement) already reads TPP 25.1+'s KeyPair.PkixParameterSet.Values, but BuildPolicySpecificationForTPP (used by the getpolicy/setpolicy CLI commands) is a separate, independent consumer of the same Certificates/CheckPolicy response and still only read the deprecated KeyAlgorithm/KeySize/EllipticCurve fields. `vcert getpolicy` against a TPP 25.1+ folder with algorithms locked via the new PKIX mechanism therefore reported no key type/size restriction at all. Adds the missing PkixParameterSet field to KeyPairResponse, moves the OID-to-key-algorithm reverse lookup into pkg/policy (as PkixToKeyAlgorithms, alongside the existing forward mapping KeyAlgorithmsToPKIX, extended to include the previously-missing RSA 8192 entry) so both this path and serverPolicy.toPolicy() share one table, and updates BuildPolicySpecificationForTPP to prefer it when locked. Verified live: `vcert getpolicy` against a TPP 25.1+ policy folder locked to RSA 4096/8192 via PkixParameterSet now correctly reports keyTypes: ["RSA"], rsaKeySizes: [4096, 8192] instead of no restriction at all. Signed-off-by: Richard Wall <richard.wall@cyberark.com>
simeoncybr
requested review from
amileva-paloalto,
esstoykov,
knikolov82,
simeoncybr and
stkomitov
and removed request for
luispresuelVenafi
August 5, 2026 06:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
From TPP 25.1 onwards, the
Certificates/CheckPolicyendpoint no longer locks the deprecatedKeyPair.KeyAlgorithm/KeySize/EllipticCurvefields when a policy folder's allowed key algorithms are configured via the newer AlgorithmSelector API. Instead, the allowed algorithms are expressed as a list of PKIX OIDs inKeyPair.PkixParameterSet.Values.vcert has two independent consumers of this same
CheckPolicyresponse, both of which only read the deprecated fields:pkg/venafi/tpp/tpp.go'sserverPolicy.toPolicy(), used byReadPolicyConfiguration/ReadZoneConfigurationto populateendpoint.Policy.AllowedKeyConfigurations— this is what a calling application (e.g. cert-manager'sapprover-policyVenafi plugin) uses to actually enforce policy.pkg/policy/policyUtils.go'sBuildPolicySpecificationForTPP, used by thevcert getpolicy/setpolicyCLI commands to report/manage policy.Both silently treated any TPP 25.1+ policy folder using the new PKIX mechanism as unrestricted:
endpoint.Policy.AllowedKeyConfigurationsended up containing every supported RSA size and ECDSA curve, andvcert getpolicyreported no key type/size restriction underpolicy.keyPairat all — regardless of what the TPP administrator had actually configured.Fix
PkixParameterSetfield toserverPolicy.KeyPair(pkg/venafi/tpp/tpp.go) and toKeyPairResponse(pkg/policy/policyStructures.go) to captureKeyPair.PkixParameterSet.Valuesfrom theCheckPolicyresponse in both code paths.policy.PkixToKeyAlgorithms(pkg/policy/policyUtils.go), mapping the PKIX OIDs (Venafi's IANA private enterprise arc,1.3.6.1.4.1.28783...) back to key type/size/curve — the inverse of the existing forward mappingKeyAlgorithmsToPKIX, which is also extended to cover RSA 8192 (previously missing).serverPolicy.toPolicy()andBuildPolicySpecificationForTPPboth now preferKeyPair.PkixParameterSet.Valueswhen locked, falling back to the deprecatedKeyAlgorithm/KeySize/EllipticCurvefields for TPP versions before 25.1.TestConvertServerPolicyToInternalPolicy_PkixParameterSet(single/multiple RSA sizes, a single ECDSA curve, mixed RSA+ECDSA, the legacy fallback, an unrecognised-OID error) andTestBuildPolicySpecificationForTPPPkixParameterSet/...UnrecognisedOID.Test evidence
Enforcement path (
serverPolicy.toPolicy()): verified end-to-end against a live TPP 25.3 instance using our internal cert-managerapprover-policyVenafi plugin's integration test suite, which calls this exact code path (ReadPolicyConfiguration/ReadZoneConfiguration→toPolicy()) to enforce key-type/size policy on CertificateRequests. Three integration subtests exercise this scenario against a policy folder locked to RSA 4096/8192 via the new PKIX mechanism — submitting an ECDSA key, an unsupported RSA size, and an RSA key below the locked minimum. Before this fix vcert silently allowed all three; consuming this branch via ago.mod replace, all three now correctly deny the request.CLI path (
BuildPolicySpecificationForTPP): verified live withvcert getpolicyagainst the same TPP 25.3 policy folder (locked to RSA 4096/8192 via PkixParameterSet). Before this fix:After this fix:
Also ran
go build ./...,go vet ./..., and the fullpkg/policyunit test suite locally (all passing).pkg/venafi/tpp's own test suite requires live TPP test credentials not set up for this exact package's test harness, so it wasn't run directly here — the two live verifications above exercise the same code paths against a real server.