Skip to content

Security: lock JsonWebToken trust-boundary contract#432

Open
corinagum wants to merge 2 commits into
mainfrom
cg/jwt-trust-boundary
Open

Security: lock JsonWebToken trust-boundary contract#432
corinagum wants to merge 2 commits into
mainfrom
cg/jwt-trust-boundary

Conversation

@corinagum
Copy link
Copy Markdown
Contributor

@corinagum corinagum commented May 20, 2026

Summary

Documents the layered authentication model the SDK uses for inbound JSON Web Tokens. Python half of a 3-SDK PR set.

Why

Security scan finding "JsonWebToken No Signature Verification" flagged the JsonWebToken accessor class for decoding tokens without verifying signatures (uses verify_signature=False). A cross-SDK audit confirmed this is intentional architecture: signature verification runs at the HTTP boundary in TokenValidator.validate_token (packages/apps/src/microsoft_teams/apps/auth/token_validator.py), and the accessor exists as a typed view over already-validated payloads. Every consumer of decoded claims is downstream of a validator pass.

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

Contract docstring at JsonWebToken.__init__ explaining that it performs no signature verification, where verification actually happens, and the rule that callers must not construct from raw network input.

What this does not change

  • No runtime behavior change. No signature verification added or removed.
  • No API surface change. JsonWebToken keeps its current name (verified public on microsoft_teams.api, so a rename would have been breaking).
  • No effect on the activity pipeline. JWT validation continues to happen via TokenValidator.validate_token exactly as before.

Related PRs

@corinagum corinagum changed the title Security: lock JsonWebToken trust-boundary contract (#6 disposition) Security: lock JsonWebToken trust-boundary contract May 20, 2026
@corinagum corinagum marked this pull request as ready for review May 22, 2026 23:16
Copilot AI review requested due to automatic review settings May 22, 2026 23:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR clarifies the Teams Python SDK’s layered JWT authentication model by documenting that JsonWebToken is a post-validation typed accessor and does not itself verify token signatures (validation happens at the HTTP boundary).

Changes:

  • Expanded JsonWebToken.__init__ docstring to explicitly state it performs no signature/issuer/audience/expiry validation and must not be constructed from untrusted input.
  • Added inline commentary near jwt.decode(... verify_signature=False) to reinforce the upstream trust-boundary contract.

Comment on lines +55 to +57
# Decode without verification for payload extraction.
# Signature verification happens upstream in TokenValidator; see the
# class docstring for the trust-boundary contract.
Comment on lines +44 to +47
``TokenValidator.validate_token`` (packages/apps/src/microsoft_teams/
apps/auth/token_validator.py). Internal callers may also construct from
tokens sourced from trusted identity infrastructure (MSAL, Bot Framework
API responses).
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.

3 participants