Json Web Tokens
Json Web Tokens
Structure of JWT:
1. Header: The header contains metadata about the type of token and the
cryptographic algorithms used for its protection. This section typically
specifies the token's type (JWT), along with the signing algorithm employed
(e.g., HMAC SHA256 or RSA).
2. Payload: The payload encapsulates the claims being conveyed. Claims are
statements about an entity (e.g., user identity, permissions, and additional
data), categorized into three types: registered, public, and private claims.
This section allows for the inclusion of custom data relevant to the
application's context.
3. Signature: The signature provides a means of verifying the token's
authenticity and integrity. By signing the header and payload with a secret
key or a private key in the case of asymmetric cryptography, JWTs can be
validated to ensure they have not been tampered with during transit. This
step prevents unauthorized modifications and guards against token forgery.
Authorization: JWTs can also carry authorization data, specifying what actions or
resources the client is permitted to access. This information is conveyed through
the claims in the payload. By examining these claims, servers can enforce fine-
grained access control policies, ensuring that clients only interact with resources
for which they have the requisite permissions.
Advantages of Json Web Tokens:
The widespread adoption of JWTs underscores their importance in modern web
development for several reasons:
• Statelessness: JWTs are self-contained and do not require server-side
storage of session state. This statelessness simplifies scaling and enhances
performance, as servers do not need to maintain session data for individual
clients.
• Interoperability: JWTs are based on open standards and enjoy broad
support across various programming languages and platforms. This
interoperability facilitates integration with existing systems and promotes
compatibility in diverse technological ecosystems.
• Security: Through cryptographic signing, JWTs ensure data integrity and
guard against tampering or unauthorized access. By verifying the signature,
servers can trust the claims contained within the token, mitigating security
risks associated with transmitting sensitive information over untrusted
networks.
Reference:
https://supertokens.com/blog/what-is-jwt
https://medium.com/@musab_alharany/10-ways-to-exploit-json-web-token-jwt-
ac5f4efbc41b
https://book.hacktricks.xyz/pentesting-web/hacking-jwt-json-web-tokens
https://medium.com/@rajeevranjancom/jwt-json-web-token-attacks-
6b82185ffed
https://portswigger.net/web-security/jwt