Security: lock JsonWebToken trust-boundary contract (#6 disposition)#517
Open
corinagum wants to merge 2 commits into
Open
Security: lock JsonWebToken trust-boundary contract (#6 disposition)#517corinagum wants to merge 2 commits into
corinagum wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR clarifies the security/trust-boundary contract for Microsoft.Teams.Api.Auth.JsonWebToken by documenting that it is a decode-only, typed accessor over an already-validated JWT payload (i.e., it does not perform signature, issuer/audience, or lifetime validation itself), and by pointing readers to where validation occurs in the ASP.NET Core pipeline.
Changes:
- Added XML documentation to
JsonWebToken(string token)describing the decode-only behavior and explicit trust-boundary requirements. - Added XML documentation to
JsonWebToken(Token.Response response)aligning it with the same trust-boundary contract.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Documents the layered authentication model the SDK uses for inbound JSON Web Tokens. .NET half of a 3-SDK PR set.
Why
Security scan finding "JsonWebToken No Signature Verification" flagged the
JsonWebTokenaccessor class for usingJwtSecurityTokenHandler.ReadJwtToken()(decode-only, no signature verification). A cross-SDK audit confirmed this is intentional architecture: signature verification runs at the ASP.NET Core JwtBearer middleware configured byTokenValidator.ConfigureValidation(Libraries/Microsoft.Teams.Plugins/Microsoft.Teams.Plugins.AspNetCore/Extensions/TokenValidator.cs), applied to endpoints via.RequireAuthorization(...). The accessor exists as a typed view over already-validated payloads. Every consumer of decoded claims is downstream of either a JwtBearer validation or a trusted identity-infrastructure source.This PR makes the architectural invariant explicit at the constructor site so future readers (and the scanner on its next pass) see the design intent locally.
What
XML documentation on both
JsonWebTokenconstructors explaining that they perform no signature verification, where verification actually happens, and the rule that callers must not construct from raw network input.Scope note: core/ (2.1)
core/was audited separately and does not have an equivalent decode-only public accessor. Its inbound JWT validation is enforced at the middleware level withValidateIssuerSigningKey = trueandRequireSignedTokens = truehardcoded; there is no public API to misuse. The finding does not apply tocore/. This PR scopes toLibraries/only.What this does not change
JsonWebTokenkeeps its current name (verified public in the packableMicrosoft.Teams.Apiassembly, including viaIContext<TActivity>.UserGraphTokenandAspNetCorePlugin.ExtractToken()return type; a rename would have been breaking).Related PRs