شعار Client Side Security

Client Side Security

مؤسسة
RedHatProductSecurity
client-side-security

Apply when reviewing or writing browser-facing code that handles user input, renders HTML, sets cookies, or loads third-party scripts. Covers XSS, CSRF, CSP, clickjacking, XS-Leaks, and HTTP security headers.

نظرة عامة

الناشرRedHatProductSecurity
المستودعprodsec-skills
اسم المهارةclient-side-security
النجوم
56
التفريعات
9
الملفات المرفقة
تعليمات فقط
الترخيصApache-2.0
الروابط
  • تعليمات بصيغة Markdown

    ملف SKILL.md يُحمّله النموذج عند الحاجة، فلا يستهلك توكنات إلا عندما يَرِد طلب ذو صلة فعلًا.

  • تعمل مع أي نموذج لغوي كبير

    مهارات الذكاء الاصطناعي مكتوبة بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا تعمل مع GPT أو Claude أو Gemini أو Grok أو نموذج محلي.

  • مكتفية بذاتها

    كل ما يحتاجه النموذج موجود في التعليمات — لا ملفات إضافية لمزامنتها.

  • مفتوحة المصدر

    نشرها RedHatProductSecurity على GitHub. اطّلع على المصدر قبل تثبيتها.

التثبيت

ثبّت مهارة الذكاء الاصطناعي Client Side Security في TypingMind لاستخدامها مع أي نموذج لغوي كبير، أو أضفها إلى وكيل ذكاء اصطناعي آخر يقرأ SKILL.md.

1

التثبيت في TypingMind

يُثبّت TypingMind المهارة مباشرةً من مجلدها على GitHub — فيقرأ SKILL.md، ويجمع ملفات الموارد في حزمة، ويحفظ النتيجة محليًا.

  1. افتح التطبيق وانتقل إلى الإضافات → المهارات.
  2. اختر «تثبيت من GitHub».
  3. الصق رابط مجلد المهارة الموضّح أدناه وأكّد التثبيت.
    https://github.com/RedHatProductSecurity/prodsec-skills/tree/main/module/skills/client-side-security
  4. فعّل المهارة في كل محادثة تريد إتاحتها فيها.
الإضافات → المهارات → إضافة مهارة → من رابط GitHub، ثم الصق رابط المجلد واضغط على «متابعة».
2

التثبيت في وكيل ذكاء اصطناعي آخر

يمكن لأي وكيل ذكاء اصطناعي يقرأ تنسيق Agent Skills استخدام هذه المهارة — انسخ المجلد إلى مجلد المهارات الخاص بذلك الوكيل.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/RedHatProductSecurity/prodsec-skills.git /tmp/prodsec-skills
mkdir -p .claude/skills
cp -r /tmp/prodsec-skills/module/skills/client-side-security .claude/skills/client-side-security
أعد تشغيل Claude Code بعد النسخ ليتعرّف على المهارة الجديدة.

استخدمها في TypingMind

فعّل Client Side Security في أي محادثة على TypingMind وسيتولى النموذج الباقي. تتضمن مطالبة النظام اسمها ووصفها، وبمجرد ورود طلب ذي صلة، يُحمّل النموذج التعليمات الكاملة تلقائيًا — فلا تحتاج إلى استدعائها يدويًا، ولا تستهلك أي توكنات حتى تُستخدم فعليًا.

يُحمّل النموذج Client Side Security تلقائيًا بمجرد ورود طلب ذي صلة بها.

تعمل مع أي نموذج ذكاء اصطناعي

مهارات الذكاء الاصطناعي هي تعليمات بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا لا ترتبط Client Side Security بالنموذج الذي كُتبت له. ثبّتها مرة واحدة في TypingMind واستخدمها مع GPT-5 أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو نموذج محلي تشغّله بنفسك — كل ذلك باستخدام مفاتيح API الخاصة بك.

  • تُحمَّل عند الحاجة فقط

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

  • بدّل النماذج أثناء المحادثة

    لأن المهارة تعليمات وليست شيفرة، فإن تغيير النموذج لا يعطّلها — فالنموذج التالي يقرأ ملف SKILL.md نفسه.

تعليمات المهارة

هذا هو محتوى SKILL.md الذي يُحمّله النموذج. اقرأه قبل التثبيت — فالمهارة عبارة عن تعليمات سيتبعها نموذجك.

Client-Side Web Security

Protect browser clients against code injection, request forgery, UI redress, cross-site leaks, and unsafe third-party scripts with layered, context-aware controls.

XSS Prevention (Context-Aware)

  • HTML context: prefer textContent. If HTML is required, sanitize with a vetted library (e.g., DOMPurify) and strict allow-lists.
  • Attribute context: always quote attributes and encode values.
  • JavaScript context: do not build JS from untrusted strings; avoid inline event handlers; use addEventListener.
  • URL context: validate protocol/domain and encode; block javascript: and data URLs where inappropriate.
  • Redirects/forwards: never use user input directly for destinations; use server-side mapping (ID to URL) or validate against trusted domain allow-lists.
  • CSS context: allow-list values; never inject raw style text from users.

Example sanitization:

javascript
const clean = DOMPurify.sanitize(userHtml, {
  ALLOWED_TAGS: ['b','i','p','a','ul','li'],
  ALLOWED_ATTR: ['href','target','rel'],
  ALLOW_DATA_ATTR: false
});

DOM-based XSS and Dangerous Sinks

  • Prohibit innerHTML, outerHTML, document.write with untrusted data.
  • Prohibit eval, new Function, string-based setTimeout/setInterval.
  • Validate and encode data before assigning to location or event handler properties.
  • Use strict mode and explicit variable declarations to prevent global namespace pollution from DOM clobbering.
  • Adopt Trusted Types and enforce strict CSP to prevent DOM sink exploitation.

Trusted Types + CSP:

http
Content-Security-Policy: script-src 'self' 'nonce-{random}'; object-src 'none'; base-uri 'self'; require-trusted-types-for 'script'

Content Security Policy (CSP)

  • Prefer nonce-based or hash-based CSP over domain allow-lists.
  • Start with Report-Only mode; collect violations; then enforce.
  • Baseline to aim for: default-src 'self'; style-src 'self' 'unsafe-inline'; frame-ancestors 'self'; form-action 'self'; object-src 'none'; base-uri 'none'; upgrade-insecure-requests.

CSRF Defense

  • Fix XSS first; then layer CSRF defenses.
  • Use framework-native CSRF protections and synchronizer tokens on all state-changing requests.
  • Cookie settings: SameSite=Lax or Strict; sessions Secure and HttpOnly; use __Host- prefix when possible.
  • Validate Origin/Referer; require custom headers for API mutations in SPA token models.
  • Never use GET for state changes; validate tokens on POST/PUT/DELETE/PATCH only. Enforce HTTPS for all token transmission.

Clickjacking Defense

  • Primary: Content-Security-Policy: frame-ancestors 'none' or a specific allow-list.
  • Fallback for legacy browsers: X-Frame-Options: DENY or SAMEORIGIN.
  • Consider UX confirmations for sensitive actions when framing is required.

Cross-Site Leaks (XS-Leaks) Controls

  • Set SameSite=Strict cookies for sensitive actions and SameSite=Lax as the default for all other cookies.
  • Adopt Fetch Metadata protections to block suspicious cross-site requests.
  • Isolate browsing contexts: COOP/COEP and CORP where applicable.
  • Disable caching and add user-unique tokens for sensitive responses to prevent cache probing.

Third-Party JavaScript

  • Minimize and isolate: prefer sandboxed iframes with sandbox and postMessage origin checks.
  • Use Subresource Integrity (SRI) for external scripts and monitor for changes.
  • Provide a first-party, sanitized data layer; deny direct DOM access from tags unless a specific integration requires it.
  • Govern via tag manager controls and vendor contracts; keep libraries updated.

SRI example:

html
<script src="https://cdn.vendor.com/app.js"
  integrity="sha384-..." crossorigin="anonymous"></script>

HTML5, CORS, WebSockets, Storage

  • postMessage: always specify exact target origin; verify event.origin on receive.
  • CORS: avoid *; allow-list origins; validate preflights; do not rely on CORS for authorization.
  • WebSockets: require wss://, origin checks, auth, message size limits, and safe JSON parsing.
  • Client storage: never store secrets in localStorage/sessionStorage; prefer HttpOnly cookies; if unavoidable, isolate via Web Workers.
  • Links: add rel="noopener noreferrer" to external target=_blank links.

HTTP Security Headers

  • HSTS: enforce HTTPS everywhere.
  • X-Content-Type-Options: nosniff.
  • Referrer-Policy and Permissions-Policy: restrict sensitive signals and capabilities.

AJAX and Safe DOM APIs

  • Avoid dynamic code execution; use function callbacks, not strings.
  • Build JSON with JSON.stringify; never via string concatenation.
  • Prefer creating elements and setting textContent/safe attributes over raw HTML insertion.

Implementation Checklist

  • Contextual encoding/sanitization for every sink; no dangerous APIs without guards
  • Strict CSP with nonces and Trusted Types; violations monitored
  • CSRF tokens on all state-changing requests; secure cookie attributes
  • Frame protections set; XS-Leak mitigations enabled (Fetch Metadata, COOP/COEP/CORP)
  • Third-party JS isolated with SRI and sandbox; vetted data layer only
  • HTML5/CORS/WebSocket usage hardened; no secrets in web storage
  • Security headers enabled and validated

Test Plan

  • Automated checks for dangerous DOM/API patterns.
  • E2E tests for CSRF and clickjacking; CSP report monitoring.
  • Manual probes for XS-Leaks (frame count, timing, cache) and open redirect behavior.

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

ماذا تفعل مهارة الذكاء الاصطناعي Client Side Security؟

Apply when reviewing or writing browser-facing code that handles user input, renders HTML, sets cookies, or loads third-party scripts. Covers XSS, CSRF, CSP, clickjacking, XS-Leaks, and HTTP security headers.

لماذا تستخدم Client Side Security على TypingMind؟

لأنك تثبّتها مرة واحدة وتستخدمها مع أي نموذج. مهارة Client Side Security عبارة عن نص Markdown وليست شيفرة خاصة بمزود بعينه، لذا تعمل المهارة نفسها مع GPT-5 أو Claude أو Gemini أو Grok أو نموذج محلي، ويمكنك تبديل النموذج أثناء المحادثة دون تعطّل المهارة. يعمل TypingMind بمفاتيح API الخاصة بك، فتدفع للمزودين مباشرةً بدلًا من اشتراك لكل مقعد، وتبقى مهاراتك ومحادثاتك في مساحة التخزين الخاصة بك.

كيف أثبّت Client Side Security في TypingMind؟

افتح الإضافات → المهارات → التثبيت من GitHub في TypingMind والصق https://github.com/RedHatProductSecurity/prodsec-skills/tree/main/module/skills/client-side-security. يقرأ TypingMind ملف SKILL.md الخاص بها ويثبّتها كمهارة يمكنك تفعيلها لكل محادثة على حدة.

ما نماذج الذكاء الاصطناعي التي يمكنها استخدام Client Side Security؟

أي نموذج تربطه في TypingMind. مهارات الذكاء الاصطناعي عبارة عن تعليمات Markdown وليست شيفرة خاصة بمزود بعينه، لذا يمكن لكل من GPT وClaude وGemini وGrok والنماذج المحلية تحميل هذه المهارة عندما يتوافق الطلب معها.

كم نموذج ذكاء اصطناعي يمكنني استخدامه مع Client Side Security؟

أي عدد تريده. ما دام النموذج يدعم المهارات، يمكنك استخدام Client Side Security معه، سواء كان GPT أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو غيرها، وكل ذلك على TypingMind باستخدام مفاتيح API الخاصة بك.

هل مهارة الذكاء الاصطناعي Client Side Security مجانية؟

نعم. نشرها RedHatProductSecurity على GitHub بموجب ترخيص Apache-2.0. لا تدفع إلا لمزود الذكاء الاصطناعي الخاص بك مقابل التوكنات التي تستخدمها.

ما هي مهارات الذكاء الاصطناعي؟

مهارة الذكاء الاصطناعي حزمة تعليمات قابلة لإعادة الاستخدام تعلّم نموذج الذكاء الاصطناعي كيفية تنفيذ مهمة محددة. وتتبع تنسيق Agent Skills المفتوح: ملف SKILL.md يتضمن اسمًا ووصفًا، إلى جانب أي نصوص برمجية أو قوالب أو ملفات مرجعية قد يحتاج إليها النموذج. لا يقرأ النموذج التعليمات إلا عندما يتوافق طلبك مع المهارة، لذا لا تترتب على المهارة المثبتة أي تكلفة حتى تُستخدم.

كيف تختلف مهارات الذكاء الاصطناعي عن الإضافات أو موصلات MCP؟

تمنح الإضافة أو موصل MCP النموذج أدوات جديدة يمكنه استدعاؤها، وهي شيفرة تُنفَّذ في مكان ما وتُرجع نتيجة. أما مهارة الذكاء الاصطناعي فتزوّد النموذج بالمعرفة ومنهجية العمل: كيفية التعامل مع مهمة، والخطوات التي ينبغي اتباعها، وما ينبغي أن تكون عليه المخرجات الجيدة. المهارات عبارة عن نصوص Markdown، لذا لا تحتاج إلى خادم أو مفتاح API أو بيئة تشغيل، وتعمل مع أي نموذج.

عرض الكل

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا البريدية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇