|
| 1 | +# /GenAIDataSecurity — OWASP GenAI Data Security Compliance Skill |
| 2 | + |
| 3 | +A Claude Code slash command that automatically scans GenAI and agentic codebases against the **OWASP GenAI Data Security Risks and Mitigations 2026 (v1.0)** — covering all 21 DSGAI risk controls across the full GenAI data lifecycle. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## What It Does |
| 8 | + |
| 9 | +When you run `/GenAIDataSecurity` inside a repository, the skill: |
| 10 | + |
| 11 | +1. **Detects** whether the repo contains GenAI/agentic patterns (LangChain, LlamaIndex, OpenAI SDK, vector stores, MCP servers, etc.) — bails out gracefully if none are found |
| 12 | +2. **Enriches live CVEs** by querying OSV, NVD, and GitHub Advisory Database against the exact package versions pinned in the repo |
| 13 | +3. **Scans source code** for all 21 DSGAI risk indicators — credentials, SQL injection via LLM output, vector store auth, telemetry logging, RAG access controls, MCP transport security, and more |
| 14 | +4. **Generates `DSGAI-report.html`** — a self-contained, print-ready HTML report with findings, file paths, line numbers, remediation steps, and a live CVE advisory panel |
| 15 | + |
| 16 | +**Performance:** All 21 control scans and all CVE source queries run as parallel tool calls — the skill fires multiple grep scans and API requests simultaneously rather than sequentially. This reduces total scan time. |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## Privacy & Data Handling |
| 21 | + |
| 22 | +This skill runs **entirely on your local machine**. Your source code is never uploaded, transmitted, or shared with any external service. |
| 23 | + |
| 24 | +**What stays local:** |
| 25 | + |
| 26 | +- All source code files scanned for security patterns |
| 27 | +- Configuration files, secrets, environment variables |
| 28 | +- Dependency manifests and build files |
| 29 | + |
| 30 | +**What is sent to the internet (CVE lookups only):** |
| 31 | + |
| 32 | +- Package names and version numbers (e.g. `langchain==0.1.0`) are sent to public vulnerability databases to check for known CVEs |
| 33 | +- Only these public databases are queried: [OSV](https://osv.dev), [NVD](https://nvd.nist.gov), [GitHub Advisory Database](https://github.com/advisories) |
| 34 | +- No actual code, secrets, file contents, or identifying information leaves your machine |
| 35 | + |
| 36 | +**Live CVE lookups are optional.** If your environment has no internet access or you prefer fully offline operation, the skill falls back to its embedded CVE database automatically — the scan still runs and produces a complete report. |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +## Prerequisites |
| 41 | + |
| 42 | +- A repository containing GenAI or agentic code (Python, TypeScript, Java, Go) |
| 43 | +- An AI coding tool with **file reading access** to your codebase (see supported tools below) |
| 44 | +- **Web access** in your AI tool for live CVE lookups (Step 0.5) — if unavailable, the scan still runs using the embedded CVE database in the skill file |
| 45 | + |
| 46 | +No Python packages or external tools required to generate the HTML report. |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## Running with Claude Code (Native) |
| 51 | + |
| 52 | +Claude Code has first-class support for this skill via its slash command system. |
| 53 | + |
| 54 | +**Installation — macOS / Linux:** |
| 55 | +```bash |
| 56 | +cp GenAIDataSecurity.md ~/.claude/commands/ |
| 57 | +``` |
| 58 | + |
| 59 | +**Installation — Windows:** |
| 60 | +``` |
| 61 | +copy GenAIDataSecurity.md %USERPROFILE%\.claude\commands\ |
| 62 | +``` |
| 63 | + |
| 64 | +**Usage:** |
| 65 | +1. Open your GenAI repository in [Claude Code](https://claude.ai/code) (CLI, desktop app, or VS Code / JetBrains extension) |
| 66 | +2. Type `/GenAIDataSecurity` and press Enter |
| 67 | +3. Claude scans the codebase — typically 2–5 minutes depending on repo size |
| 68 | +4. A `DSGAI-report.html` file is saved at the repository root and opens in your browser |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +## Running with Other AI Coding Tools |
| 73 | + |
| 74 | +The skill file is plain Markdown. Any AI tool with file reading access to your codebase can run it — just paste the contents as your prompt. |
| 75 | + |
| 76 | +| Tool | How to run | |
| 77 | +|---|---| |
| 78 | +| **Cursor** | Open `GenAIDataSecurity.md`, copy the contents, paste into Cursor's AI chat as your prompt | |
| 79 | +| **GitHub Copilot Chat** | Open the skill file, copy contents, paste into Copilot Chat in VS Code and include the repo files as context | |
| 80 | +| **ChatGPT / GPT-4** | Paste the skill file contents as the system prompt, then upload or paste the relevant source files | |
| 81 | +| **Google Gemini** | Paste the skill file contents as instructions, attach source files for analysis | |
| 82 | + |
| 83 | +The skill requires the AI tool to have **file reading access** to scan the codebase, and **web access** for live CVE lookups (Step 0.5). If web access is unavailable, the scan still runs using the embedded CVE database in the skill file. |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## What Gets Scanned |
| 88 | + |
| 89 | +All 21 DSGAI risks from the OWASP GenAI Data Security framework: |
| 90 | + |
| 91 | +| Risk | Control Area | |
| 92 | +|---|---| |
| 93 | +| DSGAI01 | Training Data Privacy | |
| 94 | +| DSGAI02 | Agentic Identity & Credential Management | |
| 95 | +| DSGAI03 | Shadow AI & Unauthorized Data Flows | |
| 96 | +| DSGAI04 | AI Supply Chain Security | |
| 97 | +| DSGAI05 | RAG Data Security | |
| 98 | +| DSGAI06 | MCP & Plugin Security | |
| 99 | +| DSGAI07 | Data Lifecycle Management | |
| 100 | +| DSGAI08 | Regulatory & Privacy Compliance | |
| 101 | +| DSGAI09 | Multimodal AI Data Security | |
| 102 | +| DSGAI10 | Synthetic Data Security | |
| 103 | +| DSGAI11 | Multi-Tenant Data Isolation | |
| 104 | +| DSGAI12 | Database Agent Security | |
| 105 | +| DSGAI13 | Vector Store Security | |
| 106 | +| DSGAI14 | AI Telemetry & Observability Security | |
| 107 | +| DSGAI15 | Context Window Data Security | |
| 108 | +| DSGAI16 | AI IDE Plugin & Extension Security | |
| 109 | +| DSGAI17 | AI System Resilience & Availability | |
| 110 | +| DSGAI18 | Model Output Data Security | |
| 111 | +| DSGAI19 | AI Data Labeling Security | |
| 112 | +| DSGAI20 | Inference API Security | |
| 113 | +| DSGAI21 | Knowledge Store Security | |
| 114 | + |
| 115 | +Each control is rated: **PASS** / **WARN** / **FAIL** / **NOT VALIDATED** / **NOT APPLICABLE** |
| 116 | + |
| 117 | +--- |
| 118 | + |
| 119 | +## Evidence Safety — Structural vs Value-Bearing Patterns |
| 120 | + |
| 121 | +When the skill scans your codebase and finds a match, it needs to include that evidence in the report. However, not all grep matches are equal — some patterns look for *architectural gaps* (safe to show), while others specifically look for *credential and PII-bearing lines* (must never appear in a shareable report). |
| 122 | + |
| 123 | +The skill classifies every scan into one of two categories: |
| 124 | + |
| 125 | +### Structural Patterns [STRUCTURAL] |
| 126 | + |
| 127 | +The grep match shows a code *pattern* — a missing import, an absent decorator, a function call without a required argument. The matched line contains no runtime secret or personal data. It is reproduced in full in the evidence block because it proves the finding without exposing anything sensitive. |
| 128 | + |
| 129 | +**Examples of structural evidence (safe to show):** |
| 130 | + |
| 131 | +``` |
| 132 | +# DSGAI04 — torch.load() without weights_only=True |
| 133 | +app/models/loader.py:22 — model = torch.load(model_path) |
| 134 | +
|
| 135 | +# DSGAI06 — MCP server binding all interfaces with no auth middleware |
| 136 | +mcp_server/server.py:42 — uvicorn.run(app, host="0.0.0.0", port=8001) |
| 137 | +
|
| 138 | +# DSGAI20 — FastAPI endpoint missing rate-limiting decorator |
| 139 | +app/main.py:55 — @app.post("/chat") # no @limiter.limit decorator |
| 140 | +
|
| 141 | +# DSGAI05 — similarity_search() missing access-control filter |
| 142 | +app/rag/retriever.py:41 — results = vectorstore.similarity_search(query, k=5) |
| 143 | +``` |
| 144 | + |
| 145 | +None of these lines contain a password, token, or personal data value — they show code structure only. |
| 146 | + |
| 147 | +### Value-Bearing Patterns [VALUE-BEARING ⚠️] |
| 148 | + |
| 149 | +The grep pattern specifically targets lines where the *matched content IS the sensitive value* — a credential assignment, a secret key, a connection string, or a log statement that may contain personal data. Reproducing this line in a shareable report would leak the actual secret or PII. |
| 150 | + |
| 151 | +**Examples of what the grep finds — and what the report must NOT show:** |
| 152 | + |
| 153 | +| What grep matches in the source file | What the report shows instead | |
| 154 | +|---|---| |
| 155 | +| `DATABASE_URL = "postgresql://admin:S3cr3tP@ss@db:5432/prod"` | `app/config.py:12 — hardcoded database credential pattern detected (value redacted — review file directly)` | |
| 156 | +| `OPENAI_API_KEY = "sk-prod-a1b2c3d4e5f6..."` | `app/config.py:8 — hardcoded LLM API key pattern detected (value redacted — review file directly)` | |
| 157 | +| `logger.info(f"User {user.email} asked: {message}")` | `app/telemetry/logging.py:28 — prompt logging statement detected (content redacted — review file directly)` | |
| 158 | +| `SYSTEM_PROMPT = f"... connect to {DATABASE_URL} ..."` | `app/config.py:30 — credential reference in system prompt detected (value redacted — review file directly)` | |
| 159 | + |
| 160 | +The four DSGAI controls whose scans are classified VALUE-BEARING are: |
| 161 | + |
| 162 | +| Control | Why value-bearing | |
| 163 | +|---|---| |
| 164 | +| **DSGAI02** — Agentic Credential Management | Matches lines containing actual API keys, database passwords, JWT secrets, and cloud credentials | |
| 165 | +| **DSGAI13** — Vector Store Security | May match lines where vector store auth tokens are hardcoded as literal values | |
| 166 | +| **DSGAI14** — AI Telemetry Security | Matches log statements whose format strings may reference PII fields or contain inline test data | |
| 167 | +| **DSGAI15** — Context Window Security | Matches system prompt construction that may embed credential strings or sensitive config values | |
| 168 | + |
| 169 | +All 17 remaining controls (DSGAI01, 03–12, 16–21) are **STRUCTURAL** — their matched content is always safe to show. |
| 170 | + |
| 171 | +--- |
| 172 | + |
| 173 | +## Report Output |
| 174 | + |
| 175 | +The generated `DSGAI-report.html` contains: |
| 176 | + |
| 177 | +- **Executive Summary** — overall posture and key FAIL findings |
| 178 | +- **Dashboard** — counts of PASS / WARN / FAIL / NOT VALIDATED / NOT APPLICABLE across all 21 controls |
| 179 | +- **AI Component Inventory** — detected frameworks, vector stores, LLM providers, MCP servers |
| 180 | +- **Summary Table** — all 21 risks at a glance with status and key evidence |
| 181 | +- **Detailed Findings** — one card per risk with file paths, line numbers, and remediation steps |
| 182 | +- **Recommendations** — tiered action plan (fix today / architecture backlog / maturity program) |
| 183 | +- **CVE Advisory Panel** — live CVEs for your exact dependency versions, grouped by DSGAI risk |
| 184 | + |
| 185 | +The report is fully self-contained (no CDN, no external fonts) and renders correctly when saved as PDF. |
| 186 | + |
| 187 | +--- |
| 188 | + |
| 189 | +## Scan Checkpoint File (`DSGAI-scan.json`) |
| 190 | + |
| 191 | +When the skill runs, it writes a local checkpoint file called `DSGAI-scan.json` to the repository root after each major scan phase. This is a **temporary intermediate structure** — not a deliverable, and can be deleted at any time. |
| 192 | + |
| 193 | +### Why it exists |
| 194 | + |
| 195 | +The scan involves three time-consuming phases: repository detection, live CVE enrichment (HTTP calls to OSV and NVD), and 21-control grep scanning. If the session times out or is interrupted before the HTML report is written, everything is lost and the scan restarts from zero. The checkpoint file prevents this — on the next run the skill skips already-completed phases and jumps to the first incomplete step. In the most common failure case (timeout during HTML generation), re-running regenerates the report in seconds. |
| 196 | + |
| 197 | +### What it stores — and what it doesn't |
| 198 | + |
| 199 | +The file contains only **structural scan metadata**: detected framework versions, DSGAI control findings (status, file paths, line numbers), and CVE query results. It does **not** store credential values, API keys, PII, prompt content, or any file contents beyond the specific matched patterns. The same evidence redaction rules that apply to the HTML report apply here — a VALUE-BEARING finding is stored as a description only, never the matched value. |
| 200 | + |
| 201 | +### Lifecycle |
| 202 | + |
| 203 | +Safe to commit (contains no secrets) or add to `.gitignore` to treat as a build artifact. Automatically overwritten on each full scan. |
| 204 | + |
| 205 | +--- |
| 206 | + |
| 207 | +## Exporting to PDF |
| 208 | + |
| 209 | +**Option 1 — Browser print (simplest):** |
| 210 | +Open `DSGAI-report.html` in Chrome or Edge → `Ctrl+P` / `Cmd+P` → Save as PDF. All cards expand automatically for print. |
| 211 | + |
| 212 | +**Option 2 — Chrome headless (scriptable):** |
| 213 | + |
| 214 | +macOS: |
| 215 | +```bash |
| 216 | +"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \ |
| 217 | + --headless=new --print-to-pdf=DSGAI-report.pdf \ |
| 218 | + --print-to-pdf-no-header "file://$(pwd)/DSGAI-report.html" |
| 219 | +``` |
| 220 | + |
| 221 | +Linux: |
| 222 | +```bash |
| 223 | +google-chrome --headless=new --print-to-pdf=DSGAI-report.pdf \ |
| 224 | + --print-to-pdf-no-header "file://$(pwd)/DSGAI-report.html" |
| 225 | +``` |
| 226 | + |
| 227 | +Windows (PowerShell): |
| 228 | +```powershell |
| 229 | +& "C:\Program Files\Google\Chrome\Application\chrome.exe" ` |
| 230 | + --headless=new --print-to-pdf=DSGAI-report.pdf ` |
| 231 | + --print-to-pdf-no-header "file:///$(pwd)/DSGAI-report.html" |
| 232 | +``` |
| 233 | + |
| 234 | +--- |
| 235 | + |
| 236 | +## Scope Annotation |
| 237 | + |
| 238 | +Each DSGAI control is tagged by responsibility: |
| 239 | + |
| 240 | +- **[BUILD]** — your team implements this in the codebase |
| 241 | +- **[BUY]** — the LLM provider / SaaS vendor is responsible |
| 242 | +- **[BOTH]** — shared responsibility |
| 243 | + |
| 244 | +Controls tagged `[BUY]` that are not applicable to a BUILD-only repo are automatically marked **NOT APPLICABLE** with an explanation. |
| 245 | + |
| 246 | +--- |
| 247 | + |
| 248 | +## Based On |
| 249 | + |
| 250 | +**OWASP GenAI Data Security Risks and Mitigations 2026 (v1.0, March 2026)** |
| 251 | +[https://owasp.org/www-project-top-10-for-large-language-model-applications/](https://owasp.org/www-project-top-10-for-large-language-model-applications/) |
| 252 | + |
| 253 | +--- |
| 254 | + |
| 255 | +## License |
| 256 | + |
| 257 | +This skill is based on materials licensed under [Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)](https://creativecommons.org/licenses/by-sa/4.0/legalcode). |
| 258 | + |
| 259 | +**Original work:** OWASP GenAI Data Security Risks and Mitigations 2026 (v1.0, March 2026) by the [OWASP GenAI Data Security Initiative](https://genai.owasp.org/initiative/data-security/), led by [Emmanuel Guilherme Junior](https://www.linkedin.com/in/emmanuelgjr/). |
| 260 | + |
| 261 | +**This adaptation:** Created by [Harish Ramachandran](https://www.linkedin.com/in/harish-ramachandran-a8026443/). You are free to share and adapt this skill for any purpose, including commercial use, under the same CC BY-SA 4.0 terms. |
0 commit comments