Client Side Security logo

Client Side Security

Organization
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.

Overview

PublisherRedHatProductSecurity
Repositoryprodsec-skills
Skill nameclient-side-security
Stars
56
Forks
9
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by RedHatProductSecurity on GitHub. Read the source before you install it.

Installation

Install the Client Side Security AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/RedHatProductSecurity/prodsec-skills/tree/main/module/skills/client-side-security
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

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
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Client Side Security in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Client Side Security on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Client Side Security is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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.

Frequently asked questions

What does the Client Side Security AI skill do?

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.

Why use Client Side Security on TypingMind?

Because you install it once and use it with any model. Client Side Security is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Client Side Security in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/RedHatProductSecurity/prodsec-skills/tree/main/module/skills/client-side-security. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Client Side Security?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Client Side Security?

As many as you like. As long as a model supports skills, you can use Client Side Security with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Client Side Security AI skill free?

Yes. It is published on GitHub by RedHatProductSecurity under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇