client-security

client-security is a cursor rule for Cursor from GktuOktay/ai-skills. It costs 0 tokens per session (837 once invoked), scanned A, original, MIT.

A frontend security rule for protecting browser-based applications from unsafe scripts, forged requests, and dangerous page content.

In plain words
What is it for?
It is for reviewing DOM updates, sanitizing user input, configuring Content Security Policy headers, securing cookies, and adding request protections.
Why use it?
It helps prevent attacks such as XSS, where untrusted input runs as code, and CSRF, where another site tricks a logged-in user into sending a request.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/gktuoktay/ai-skills/client-security
Clone the repo
git clone --depth 1 https://github.com/GktuOktay/ai-skills

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for client-security

README.md
[![agentmods](https://agentmods.dev/badge/rules/gktuoktay/ai-skills/client-security.svg)](https://agentmods.dev/rules/gktuoktay/ai-skills/client-security)
Your own site
<a href="https://agentmods.dev/rules/gktuoktay/ai-skills/client-security"><img src="https://agentmods.dev/badge/rules/gktuoktay/ai-skills/client-security.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 837 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00837
Opus 5 $0.00000 $0.00418
Sonnet 5 $0.00000 $0.00167
Haiku 4.5 $0.00000 $0.00084

Measured 2d ago against content hash dfc80da13d5b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

client-security scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agents/cursor/rules/client-security.mdc · 72 lines

How it starts

The opening of the file, as written. The whole thing — 72 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Client-Side Security Best Practices

Overview

This skill outlines how to build secure frontend applications by preventing Cross-Site Scripting (XSS), Cross-Site Request Forgery (CSRF), configuring robust Content Security Policy (CSP) headers, ensuring secure cookie usage, and mitigating DOM-based vulnerabilities.

Core Principles

1. Cross-Site Scripting (XSS) Prevention

Never trust data rendered to the DOM.

  • Context-aware encoding: Always encode data based on where it will be rendered (HTML body, attributes, JavaScript variables).
  • Use modern frameworks: Leverage frameworks like React, Angular, or Vue which automatically escape content by default.
  • Avoid dangerous APIs: Avoid using APIs like innerHTML, document.write(), or v-html/dangerouslySetInnerHTML unless absolutely necessary and the input is strictly sanitized (e.g., using DOMPurify).

2. Cross-Site Request Forgery (CSRF) Mitigation

Protect state-changing requests from being forged.

  • Anti-CSRF Tokens: Implement synchronizer token pattern where every state-changing request (POST, PUT, DELETE) includes a unique, session-tied token.
  • SameSite Cookies: Use the SameSite=Lax or SameSite=Strict flag on all sensitive cookies (e.g., session cookies) to prevent the browser from sending them in cross-site requests.

3. Secure Cookie Flags

Ensure cookies are handled securely by the browser.

  • HttpOnly: Prevent client-side scripts from accessing the cookie, mitigating the impact of XSS.
  • Secure: Ensure the cookie is only transmitted over HTTPS.
  • SameSite: Mitigate CSRF by controlling cross-site cookie sending.

4. Content Security Policy (CSP)

Use CSP to restrict the sources from which resources can be loaded.

  • Strict Policies: Implement a strict CSP that relies on nonces or hashes rather than unsafe-inline or unsafe-eval.
  • Report-Only Mode: Deploy CSP in report-only mode first to monitor violations before enforcing.

5. DOM-Based Vulnerabilities

Prevent attacks where the payload is executed as a result of modifying the DOM environment in the victim's browser.

  • Avoid sinks: Be cautious with DOM sinks like location.href, setTimeout, eval().
  • Validate sources: Validate data from sources like location.hash, document.referrer, window.name.

Read the full file on GitHub · 72 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 72 lines · 837 tokens per session scan A dfc80da13d5b

Subscribe to this mod's changes

client-security is a cursor rule published in the GitHub repository GktuOktay/ai-skills (2 stars, last pushed 3d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 837 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.