Client side security

From RedHatProductSecurity/prodsec-skills · View interactive version

Client side security is an AI agent skill from the GitHub repository RedHatProductSecurity/prodsec-skills. 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.

How to use this skill

Skill file

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)

Example sanitization:

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

Trusted Types + CSP:

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

Content Security Policy (CSP)

CSRF Defense

Clickjacking Defense

Cross-Site Leaks (XS-Leaks) Controls

Third-Party JavaScript

SRI example:

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

HTML5, CORS, WebSockets, Storage

HTTP Security Headers

AJAX and Safe DOM APIs

Implementation Checklist

Test Plan

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.