
JWT Signing and Verification
FreeSecurely implement and verify JWTs in your applications.
Free · Opens the source repo
What JWT Signing and Verification does
This skill provides a comprehensive implementation guide for signing and verifying JSON Web Tokens (JWTs) in compliance with RFC 7519. It supports multiple signing algorithms including HMAC-SHA256, RSA-PSS, ES256, and EdDSA, ensuring robust security for authentication and authorization processes in web applications. The skill addresses critical aspects of JWT management, such as token expiration, claims validation, and defenses against common vulnerabilities like algorithm confusion and key injection attacks.
By employing this skill, developers can effectively enhance their security architecture when integrating JWT-based authentication mechanisms. It is particularly useful for those looking to harden existing implementations or conduct security assessments related to JWT vulnerabilities. The skill also emphasizes best practices, such as validating algorithm headers against an allowlist and implementing token refresh mechanisms to mitigate replay attacks.
Designed for developers with a foundational understanding of cryptography, this skill requires a Python environment (version 3.8 or higher) and access to a secure testing environment. It is an essential resource for anyone involved in building or auditing security features in applications that utilize JWTs, ensuring compliance with security standards and enhancing overall application security.
When to use it
Use this skill when deploying JWT signing and verification in your applications, or when auditing existing implementations for security compliance.
When not to use it
This skill may not be suitable for environments that do not require JWTs or where simpler authentication methods are sufficient.
What you can build with it
Enhancing Application Security
Use this skill to implement JWT signing and verification in new or existing applications to enhance security.
Conducting Security Assessments
Utilize this skill when performing security assessments to identify and mitigate JWT-related vulnerabilities.
Compliance with Security Standards
Employ this skill to ensure your JWT implementation meets necessary compliance and security standards.
How to install JWT Signing and Verification
View source1. Install with the skills CLI
npx skills add mukul975/anthropic-cybersecurity-skills/implementing-jwt-signing-and-verification --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by mukul975Implementing 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
Frequently asked questions about JWT Signing and Verification
Similar skills
GitHub Actions Hardening
Enhance the security of your GitHub Actions workflows.
Sensitive Logging Audit
Audit and fix sensitive data exposure in Python logging.
Android App Static Analysis
Automate security assessments of Android apps with MobSF.
Integrating DAST with OWASP ZAP
Seamlessly integrate dynamic security testing into CI/CD pipelines.
Implementing Runtime Security with Tetragon
Enhance Kubernetes security with eBPF-based observability.
Implementing Mobile Application Management
Secure enterprise data on mobile devices with app-level controls.
