Add telemetry around signature validation (#3410)#3415
Merged
Conversation
* Added helper class and methods to track signature validation telemetry. Added tests * Added a counter for signature validation. Updated ITelemetryClient interface and TelemetryClient to support the new telemetry. Added null telemetry client for no op * Added telemetry to JWT and SAML/SAML2 handlers. Expanded catching of exceptions to identify the stage at which the signature validation failed. * Added tests * Addressed Copilot's feedback * Reverted readonly changes to allow setting the telemetry client in tests * Replaced lock with volatile modifier for immutable array, removed the hashset in favour of the array to avoid converting in the getter. * Updated CryptoTelemetry's public API and tests * Added benchmarks for signature validation telemetry * Removed issuer caching from CryptoTelemetry signature validation telemetry. Updated tests * Updated public API to match the updated enable telemetry method * Addressed PR feedback - Rename _telemetryClient to TelemetryClient in all token handlers and update all references accordingly. - Simplify CryptoTelemetry.GetTrackedIssuerOrOther: now matches tracked issuers by substring (case-insensitive) instead of parsing host; remove ExtractHostFromIssuer. - Update comments to clarify substring matching and its limitations. - Remove TelemetryConfiguration enum from benchmarks; update benchmark attributes and tracked issuer values for consistency. - Refactor and expand CryptoTelemetry tests: remove host extraction tests, consolidate key algorithm ID tests, and add more scenarios for tracked issuer matching and allowlist filtering. - Update API documentation to reflect field renaming. - Overall, unify telemetry client usage and streamline issuer tracking logic, with tests updated to match new behavior. * Removed case insensitive comparison for telemetry issuer extraction based on PR feedback (cherry picked from commit 61449b8)
GeoK
approved these changes
Feb 11, 2026
pmaytak
approved these changes
Feb 11, 2026
This was referenced Feb 13, 2026
Closed
Merged
This was referenced Mar 26, 2026
Closed
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.
Add telemetry around signature validation
This is a cherry pick from #3410 to dev8x
Original PR's description
This pull request introduces telemetry tracking for JWT and SAML/2 signature validation in the
JsonWebTokenHandlerand related classes. It refactors several methods to non-static to support instance-level telemetry. The changes enable detailed telemetry reporting on signature validation outcomes, such as missing keys, unsupported algorithms, and verification failures.Telemetry integration for JWT and SAML signature validation:
JsonWebTokenHandler,SamlSecurityTokenHandler, andSaml2SecurityTokenHandler, capturing events like signing key not found, algorithm not supported, signature provider creation failure, and signature verification failure or success. This is accomplished by calling the newRecordSignatureValidationTelemetryhelper at appropriate points.ValidateSignature,ValidateSignatureUsingAllKeys, andValidateSignatureWithKeymethods from static to instance methods, allowing access to the instance telemetry client (_telemetryClient).These changes lay the groundwork for comprehensive telemetry on signature validation, improving observability and diagnostics for token validation scenarios.
New Telemetry Counter
Signature Validation Counter
The counter tracks 5 dimensions (tags):
IdentityModelVersionIdentityModelTelemetryUtil.ClientVerAlgorithmalgclaimKeyAlgorithmCryptoTelemetry.GetKeyAlgorithmId(SecurityKey)IssuerCryptoTelemetry.GetTrackedIssuerOrOther(issuer)ErrorTelemetryConstants.SignatureValidationErrors.*Tag Cardinality Breakdown
1. IdentityModelVersion
"7.3.1","8.0.0")2. Algorithm
RS256,RS384,RS512PS256,PS384,PS512ES256,ES384,ES512,ES256KHS256,HS384,HS512none, custom algorithmsRS256,ES256,PS256)3. KeyAlgorithm
CryptoTelemetry.GetKeyAlgorithmId(SecurityKey)returns predefined constantsRSA-2048,RSA-3072,RSA-4096,RSA-UNKNOWNECDSA-P256,ECDSA-P384,ECDSA-P521,ECDSA-UNKNOWNSYM-128,SYM-192,SYM-256,SYM-384,SYM-512,SYM-UNKNOWNNO-KEY,UNKNOWNRSA-2048,RSA-4096,ECDSA-P256)4. Issuer
CryptoTelemetry.GetTrackedIssuerOrOther(issuer)with allowlist-based filteringhttps://login.microsoftonline.com/tenant/→login.microsoftonline.com)CryptoTelemetry.TrackedIssuersallowlist"other"for all non-allowlisted issuerslogin.microsoftonline.com(Microsoft Entra ID)accounts.google.com(Google)appleid.apple.com(Apple)other(catch-all for non-tracked issuers)"other")5. Error
TelemetryConstants.SignatureValidationErrors.*NoneSignatureVerificationFailedAlgorithmNotSupportedSignatureProviderCreationFailedSigningKeyNotFoundOtherNone,SignatureVerificationFailed,SigningKeyNotFound)Total Cardinality Calculation
Production Reality (Empty Issuer Allowlist - Default):
Production Reality (With 5 Tracked Issuers):
Upper Bound Estimate:
Note: The issuer dimension is strictly controlled via the
CryptoTelemetry.TrackedIssuersallowlist, preventing unbounded cardinality growth.Cardinality Assessment
✅ Low-Medium Cardinality - Safe for production at scale
Rationale:
"other")Benchmarks
For loop 100_000 calls + 10 OperationsPerInvoke
No for loop, 100_000 OperationsPerInvoke
(cherry picked from commit 61449b8)