Skip to content
Skillpedia
Security35k · #8065

implementing-jwt-signing-and-verification

What it does

This tool helps create and check security tokens called JWTs. They are used to ensure only authorized people can access information on websites and apps, protecting against hackers.

When to use it

  • ✓When setting up security for a website or application.
  • ✓When checking if access tokens are correct.
  • ✓When protecting sensitive data from unauthorized access.

Skill link

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-jwt-signing-and-verification/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-jwt-signing-and-verification/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Verify this JWT token to ensure it's secure and hasn't been tampered with.”

5 new skills a week. 1 minute to read.

How it works

The tool uses cryptographic methods to sign tokens when they are created, ensuring their authenticity. When a token is received, it uses the same cryptography to check if it's valid and hasn't been modified.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Implementing JWT Signing and Verification

Overview

JSON Web Tokens (JWT) defined in RFC 7519 are compact, URL-safe tokens used for authentication and authorization in web applications. This skill covers implementing secure JWT signing with HMAC-SHA256, RSA-PSS, and EdDSA algorithms, along with verification, token expiration, claims validation, and defense against common JWT attacks (algorithm confusion, none algorithm, key injection).

When to Use

  • When deploying or configuring implementing jwt signing and verification capabilities in your environment
  • When establishing security controls aligned to compliance requirements
  • When building or improving security architecture for this domain
  • When conducting security assessments that require this implementation

Prerequisites

  • Familiarity with cryptography concepts and tools
  • Access to a test or lab environment for safe execution
  • Python 3.8+ with required dependencies installed
  • Appropriate authorization for any testing activities

Objectives

  • Implement JWT signing with HS256, RS256, ES256, and EdDSA
  • Verify JWT signatures and validate standard claims
  • Implement token expiration, not-before, and audience validation
  • Defend against algorithm confusion and none algorithm attacks
  • Implement JWT key rotation with JWK Sets
  • Build a complete authentication middleware

Key Concepts

JWT Algorithms

Algorithm Type Key Security Level
HS256 Symmetric (HMAC) Shared secret 128-bit
RS256 Asymmetric (RSA) RSA key pair 112-bit
ES256 Asymmetric (ECDSA) P-256 key pair 128-bit
EdDSA Asymmetric (Ed25519) Ed25519 pair 128-bit

Common JWT Attacks

  • Algorithm confusion: Switching from RS256 to HS256, using public key as HMAC secret
  • None algorithm: Setting alg=none to bypass signature verification
  • Key injection: Embedding key in JWK header
  • Weak secrets: Brute-forcing short HMAC secrets
  • Token replay: Reusing valid tokens without expiration

Security Considerations

  • Always validate the algorithm header against an allowlist
  • Never accept alg=none in production
  • Use asymmetric algorithms (RS256, ES256) for distributed systems
  • Set short expiration times (15 min for access tokens)
  • Implement token refresh mechanism
  • Store secrets securely (not in source code)

Validation Criteria

  • JWT signing produces valid tokens for all algorithms
  • Signature verification rejects tampered tokens
  • Expired tokens are rejected
  • Algorithm confusion attack is prevented
  • None algorithm is rejected
  • JWK key rotation works correctly
  • Claims validation enforces all required claims
FAQ

What is a JWT?

JWT stands for JSON Web Token. It's like a digital badge that proves who you are to a website or app, in a secure and compact way.

Why use different algorithms like HS256, RS256?

Each algorithm uses a different type of secret 'key' to sign and verify tokens. Some use a shared secret key (HS256), while others use a key pair (one public, one private) for stronger security in larger systems (RS256, ES256, EdDSA).

What are attacks like 'algorithm confusion' or 'none algorithm'?

These are attempts by hackers to trick the system. For example, making the system think a token was signed with a secure method when it wasn't, or trying to send a token with no signature to bypass security.

Details

Original description by the author

Implements secure JWT (RFC 7519) signing and verification using HMAC-SHA256, RSA-PSS, ES256, and EdDSA, including token expiration, claims validation, and defenses against algorithm-confusion, none-algorithm, and key-injection attacks. Use when adding or hardening JWT-based authentication/authorization, or when auditing token verification code for common JWT vulnerabilities.

repo: mukul975/Anthropic-Cybersecurity-Skills

Popularity

GitHub stars
35k
Ranking position
#8065
License
Apache-2.0
Updated
8/31/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills