本文へスキップ
Skillpedia
セキュリティ35k · #8065

implementing-jwt-signing-and-verification

できること

JWTと呼ばれるセキュリティトークンを作成し、検証するためのツールです。権限のある人だけがWebサイトやアプリの情報にアクセスできるようにし、ハッカーからの攻撃を防ぎます。

使う場面

  • ✓Webサイトやアプリケーションのセキュリティpara設定するとき
  • ✓アクセストークンが正しいか確認したいとき
  • ✓重要なデータを不正なアクセスから守りたいとき

スキルのリンク

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

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-jwt-signing-and-verification/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“このJWTトークンを検証して、安全であり、改ざんされていないか確認してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

このツールは、トークンを作成する際に暗号技術を使って署名し、本物であることを保証します。トークンを受け取ると、同じ暗号技術を使って有効であるかどうか、また改ざんされていないかを確認します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)を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
よくある質問

JWTとは何ですか?

JWTは「JSON Web Token」の略です。安全でコンパクトな形で、利用者が誰であるかをWebサイトやアプリに証明する、デジタルの身分証のようなものです。

HS256やRS256など、異なるアルゴリズムを使う理由は何ですか?

アルゴリズムごとに、トークンへの署名と検証に使う秘密の「鍵」の種類が異なります。HS256は共有の秘密鍵を使い、RS256、ES256、EdDSAは公開鍵と秘密鍵のペアを使います。大規模なシステムでは、後者の方がより強固な安全性を確保できます。

「アルゴリズム混乱」や「noneアルゴリズム」攻撃とは何ですか?

システムを騙そうとするハッカーの攻撃手法です。たとえば、実際には安全でない方法で署名されたトークンを、安全な方法で署名されたものだとシステムに思い込ませたり、署名のないトークンを送ってセキュリティを回避しようとしたりします。

詳細

作者による元の説明

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

人気

GitHubのスター
35k
ランキング
#8065
ライセンス
Apache-2.0
更新日
2026/8/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル