Skillpedia
الأمان107k · #780

security-and-hardening

ما الذي تفعله

تساعد هذه المهارة على جعل الكود أكثر أمانًا، عبر حمايته من الهجمات وتسريب البيانات. تتحقق من أنك تتعامل مع المعلومات الحساسة والمدخلات من المستخدمين بأمان.

متى تستخدمها

  • ✓عند بناء أي جزء من برنامجك يستقبل معلومات من الخارج.
  • ✓عندما تحتاج إلى حماية كلمات المرور أو البيانات الشخصية أو معلومات الدفع.
  • ✓عند دمج برنامجك مع خدمات أو واجهات برمجية أخرى.

رابط المهارة

https://github.com/addyosmani/agent-skills/blob/main/skills/security-and-hardening/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/addyosmani/agent-skills/blob/main/skills/security-and-hardening/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“كيف أتأكد من أن مدخلات المستخدم لا تسبب مشكلات أمنية في الكود؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

تحلل كيفية تعامل الكود مع البيانات الخارجية، مثل معلومات المستخدمين أو البيانات القادمة من أنظمة أخرى. ثم تقترح ممارسات تمنع استخدام هذه البيانات لمهاجمة البرنامج.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Security and Hardening

Overview

Security-first development practices for web applications. Treat every external input as hostile, every secret as sacred, and every authorization check as mandatory. Security isn't a phase — it's a constraint on every line of code that touches user data, authentication, or external systems.

When to Use

  • Building anything that accepts user input
  • Implementing authentication or authorization
  • Storing or transmitting sensitive data
  • Integrating with external APIs or services
  • Adding file uploads, webhooks, or callbacks
  • Handling payment or PII data

Process: Threat Model First

Controls bolted on without a threat model are guesses. Before hardening, spend five minutes thinking like an attacker:

  1. Map the trust boundaries. Where does untrusted data cross into your system? HTTP requests, form fields, file uploads, webhooks, third-party APIs, message queues, and LLM output — plus the local values that look internal because the OS handed them to you: another process's command line or environment, filenames on a shared volume, a path in a job payload. Trust follows who wrote a value, not which channel delivered it. Every boundary is attack surface.
  2. Name the assets. What's worth stealing or breaking? Credentials, PII, payment data, admin actions, money movement.
  3. Run STRIDE over each boundary — a quick lens, not a ceremony:
Threat Ask Typical mitigation
Spoofing Can someone impersonate a user/service? Authentication, signature verification
Tampering Can data be altered in transit or at rest? Integrity checks, parameterized queries, HTTPS
Repudiation Can an action be denied later? Audit logging of security events
Information disclosure Can data leak? Encryption, field allowlists, generic errors
Denial of service Can it be overwhelmed? Rate limiting, input size caps, timeouts
Elevation of privilege Can a user gain rights they shouldn't? Authorization checks, least privilege
  1. Write abuse cases next to use cases. For each feature, ask "how would I misuse this?" — then make that your first test.

If you can't name the trust boundaries for a feature, you're not ready to secure it. This is OWASP A04: Insecure Design — most breaches begin in design, not code.

The Three-Tier Boundary System

Always Do (No Exceptions)

  • Validate all external input at the system boundary (API routes, form handlers)
  • Parameterize all database queries — never concatenate user input into SQL
  • Encode output to prevent XSS (use framework auto-escaping, don't bypass it)
  • Use HTTPS for all external communication
  • Hash passwords with bcrypt/scrypt/argon2 (never store plaintext)
  • Set security headers (CSP, HSTS, X-Frame-Options, X-Content-Type-Options)
  • Use httpOnly, secure, sameSite cookies for sessions
  • Run the detected package manager's native audit against the committed lockfile before every release

Ask First (Requires Human Approval)

  • Adding new authentication flows or changing auth logic
  • Storing new categories of sensitive data (PII, payment info)
  • Adding new external service integrations
  • Changing CORS configuration
  • Adding file upload handlers
  • Modifying rate limiting or throttling
  • Granting elevated permissions or roles

Never Do

  • Never commit secrets to version control (API keys, passwords, tokens)
  • Never log sensitive data (passwords, tokens, full credit card numbers)
  • Never trust client-side validation as a security boundary
  • Never disable security headers for convenience
  • Never use eval() or innerHTML with user-provided data
  • Never store sessions in client-accessible storage (localStorage for auth tokens)
  • Never expose stack traces or internal error details to users

Hardening Controls

The rules below are the workflow; a concrete implementation of each lives in references/hardening-patterns.md. Open the section you need when you reach that code, not before.

Injection, XSS, and access control

  • Parameterize every query. Never build SQL, NoSQL, or shell commands from input strings.
  • Encode output through the framework's auto-escaping. If raw HTML is unavoidable, sanitize with an allowlist sanitizer first.

…

الأسئلة الشائعة

ما هي « الثغرات الأمنية » (vulnerabilities)؟

هي عيوب في الكود يمكن للمهاجمين استغلالها للوصول إلى المعلومات أو إلحاق الضرر بالنظام أو السيطرة عليه.

ماذا تعني « عامل كل مدخل خارجي على أنه عدائي »؟

تعني أن تكون متشككًا دائمًا في أي بيانات تأتي من خارج برنامجك (مثل ما يكتبه المستخدم)، وأن تتحقق من أنها آمنة قبل استخدامها.

لماذا لا ينبغي تخزين كلمات المرور كنص عادي؟

إذا حصل أحد على وصول إلى قاعدة البيانات، ستُكشف كلمات المرور النصية فورًا. تخزين كلمات المرور « المجزأة » (hashed)، أي المحوّلة إلى كود معقد، أكثر أمانًا بكثير.

التفاصيل

الوصف الأصلي من المؤلف

Hardens code against vulnerabilities. Use when auditing an input handler for vulnerabilities, when handling user input, authentication, data storage, or external integrations, or when checking a login flow is safe against the OWASP Top Ten. Use when building any feature that accepts untrusted data, manages user sessions, or interacts with third-party services. Use when auditing dependencies for kn

repo: addyosmani/agent-skills

الشعبية

نجوم GitHub
107k
الترتيب
#780
الترخيص
MIT
آخر تحديث
13‏/10‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة