implementing-jwt-signing-and-verification
ما الذي تفعله
تساعد هذه المهارة على إنشاء رموز الأمان المسماة JWT والتحقق منها. تُستخدم لضمان أن الأشخاص المصرح لهم فقط يصلون إلى المعلومات على المواقع والتطبيقات، وتحمي من المتسللين.
متى تستخدمها
- ✓عندما تضبط أمان موقع أو تطبيق.
- ✓عندما تتحقق من صحة رموز الوصول.
- ✓عندما تحمي البيانات الحساسة من الوصول غير المصرح به.
رابط المهارة
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-jwt-signing-and-verification/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“تحقق من رمز JWT هذا لأتأكد من أنه آمن ولم يُعبث به.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تستخدم هذه المهارة طرقًا تشفيرية لتوقيع الرموز عند إنشائها، لضمان أصالتها. وعند استلام رمز، تستخدم التشفير نفسه للتحقق من صلاحيته وأنه لم يُعدَّل.
المحتوى التقني (ملف 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، وهو يشبه شارة رقمية تثبت هويتك لموقع أو تطبيق بطريقة آمنة ومضغوطة.
لماذا تُستخدم خوارزميات مختلفة مثل HS256 وRS256؟
كل خوارزمية تستخدم نوعًا مختلفًا من «المفتاح» السري للتوقيع والتحقق. بعضها يستخدم مفتاحًا مشتركًا (HS256)، وبعضها يستخدم زوج مفاتيح (عام وخاص) لأمان أقوى في الأنظمة الكبيرة (RS256 وES256 وEdDSA).
ما هي هجمات مثل «algorithm confusion» أو «none algorithm»؟
هي محاولات من المتسللين لخداع النظام. مثلًا جعله يظن أن الرمز وُقّع بطريقة آمنة بينما لم يُوقَّع، أو إرسال رمز بلا توقيع لتجاوز الأمان.
التفاصيل
الوصف الأصلي من المؤلف
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.
الشعبية
- نجوم GitHub
- 35k
- الترتيب
- #8065
- الترخيص
- Apache-2.0
- آخر تحديث
- 31/8/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
abusing-dpapi-for-credential-access
35kيمنح وكيل الذكاء الاصطناعي تعليمات جاهزة لمهمة محددة، ليؤديها بشكل أفضل وأسرع.
abusing-shadow-credentials-for-privesc
35kيعلّم وكيل الذكاء الاصطناعي لديك كتابة نص واضح ومنظم جيدًا.
achieving-cmmc-level-2-compliance
35kيساعد وكيلك على تجهيز بيئة للامتثال لمستوى CMMC 2. يطبق متطلبات الأمان ويدير الوثائق اللازمة.
acquiring-disk-image-with-dd-and-dcfldd
35kيساعد وكيلك على إنشاء نسخ مطابقة تمامًا لأقراص التخزين. هذا مفيد لضمان عدم فقدان أي معلومات أو تغييرها أثناء التحقيقات.
مهارات مشابهة
reverse-engineer-anything
422kيساعد وكيلك على فحص التطبيقات والحزم المنشورة من الداخل ليشرح الميزات ويقارن الإصدارات ويرشد إلى إعادة البناء، باستخدام أداة REA.
1password
394kيساعد وكيلك على إعداد واجهة سطر أوامر 1Password وتسجيل الدخول، وقراءة الأسرار أو حقنها دون طباعة قيمها في المحادثة.
healthcheck
394kيساعد وكيلك على تدقيق جهاز OpenClaw أو خادمه أمنيًا، مثل SSH والجدار الناري والتحديثات، ويقترح إصلاحات آمنة قابلة للتراجع.