Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Demystifying JWT

Pradheepa P
December 21, 2024
16

Demystifying JWT

Pradheepa P

December 21, 2024
Tweet

Transcript

  1. Me

  2. JWT

  3. 4. Signer adds the signature to the message Signer Verifier

    Hashing Function ####### K Private Encrypt Signature
  4. 5. Verifier hashes the message Signer Verifier Hashing Function #######

    K Private Encrypt Signature Hashing Function #######
  5. 6. Verifier decrypts the signature Signer Verifier Hashing Function #######

    K Private Encrypt Signature Hashing Function ####### Decrypt ####### K Public
  6. 7. Verifier matches and verifies Signer Verifier Hashing Function #######

    K Private Encrypt Signature Hashing Function ####### Decrypt ####### K Public Equals?
  7. 8. Signature guarantees the message Signer Verifier Signature 1. Message

    is not tampered 2. The signer owns the private key
  8. JWT • Widely adopted method for stateless authentication and secure

    data transmission, especially in the context of API authentication and single sign-on (SSO) systems. • Popular with the rise of RESTful APIs and the need for decentralized authentication, particularly with frameworks like OAuth 2.0 and OpenID Connect. • JWT's simplicity, flexibility, and ease of use have made it the de facto standard for token-based authentication in many modern web applications.
  9. JWT Development Timeline • 2010: The idea of JWT was

    conceived by Mike Jones. The need for a compact and secure way to transmit information between parties led to the creation of JWT as an alternative to earlier standards like SAML (Security Assertion Markup Language). • 2011: The JWT format started to gain traction, and early discussions and drafts emerged, leading to the creation of libraries and tools that implemented it. • 2015: JWT was officially standardized with the publication of RFC 7519 by the IETF Security Area. This RFC defines how JWTs should be structured, signed, and validated, making it a formal and interoperable standard.
  10. JWT • “JOT”/JSON WEB TOKEN • Base64 encoded • Signed

    • Encrypted <base64url-encoded-header>. <base64url-encoded-payload>. <base64url-encoded-signature>
  11. Remember this slide ?? Signer Verifier Hashing Function ####### K

    Private Encrypt Signature Hashing Function ####### Decrypt ####### K Public Equals?
  12. Choose the proper signature algorithm ➔ HMACs are only useful

    internally in an application ➔ All other scenarios should rely on asymmetric signatures Follow JWT security recommendations ➔ Explicitly type your JWT ➔ Use strong signature algorithms ➔ Use reserved claims and their meaning Explicitly verify the security of the backend application ➔ Libraries should be actively supported and up to date ➔ JWTs with none signatures should be rejected case-insensitively ➔ JWTs with invalid signatures should be rejected