agentleFS
zahidoverflowzahidoverflow/viperclaw/skills/viper-ai-llm-guardrails/SKILL.md

viper-ai-llm-guardrails

Skill22 starsChanged 16 days agoMITView on GitHub

AI, LLM & MCP Application Security & Guardrails Auditor (OWASP LLM Top 10). Reviews prompt boundaries, RAG data isolation, tool-call authorization, and output sanitization.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run the following discovery commands across the target repository before manual code review:

    line 30
  2. Distinctive:

    Verify whether an upstream API Gateway, global middleware, or ORM hook already enforces the control before flagging a controller.

    line 62
  3. Distinctive:

    Write a Positive Unit Test confirming authorized, schema-valid requests succeed.

    line 93
  4. Distinctive:

    Write a Negative Security Regression Test confirming unauthorized, cross-tenant, or malformed inputs are deterministically rejected.

    line 94

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

AI, LLM & Agentic Application Guardrails Auditor (OWASP LLM Top 10) (viper-ai-llm-guardrails)

1. Executive Scope, Standards & CWE/OWASP Mapping

  • Frameworks & Standards: OWASP Top 10 for LLM Applications (LLM01–LLM10), OWASP Agentic AI Top 10 (ASI01–ASI10), NIST AI RMF
  • Primary CWE Mapping: CWE-77 (Command Execution via Unvalidated LLM Output), CWE-79 (XSS via Unsanitized Markdown), CWE-269 (Improper Privilege Management / Excessive Agency), CWE-200 (Sensitive Information Exposure)
  • ViperClaw MCP Tools: viper_taint_scan, viper_oob_probe, viper_verify_and_report
  • ViperClaw CLI Command: viperclaw taint ./src --db .viperclaw/graph.db

2. Threat Model & Root-Cause Architecture

flowchart LR
  User["User Prompt + Untrusted RAG Data"] --> LLM["LLM Reasoning Layer"] --> Schema["Deterministic Tool Policy & Schema Gate"] --> Downstream["Parameterized API / Sanitized UI"]

Root-Cause Analysis

Guardrail failures occur when applications treat model-generated strings as trusted instructions—passing unvalidated LLM output directly into SQL engines (SQLDatabaseChain), dynamic code runners (PythonREPLTool), unescaped Markdown/HTML renderers, or over-privileged internal APIs without caller-scoped authorization.


3. Deterministic Discovery & Grep/AST Audit Commands

Run the following discovery commands across the target repository before manual code review:

# 1. Automated ViperClaw analysis
viperclaw taint ./src --db .viperclaw/graph.db

# 2. Rapid static pattern discovery (ripgrep)
rg -n "(openai\.|anthropic\.|ChatCompletion|generate_content|LangChain|LlamaIndex)"
rg -n "(create_sql_agent|SQLDatabaseChain|PythonREPLTool|ShellTool|BashProcess)"
rg -n "(system_prompt|tools\s*=\s*\[|function_call|tool_choice)"

4. Senior Security Engineer 8-Point Audit Checklist

Control IDAudit Verification TargetPass CriteriaFail / Vulnerability Indicator
LLM-01Prompt & Untrusted Data Separation (LLM01)External content (emails, web pages, RAG documents) is wrapped in explicit structural delimiters and separated from system instructions.Untrusted external text concatenated directly into the system instruction block.
LLM-02Output Sanitization & Safe Rendering (LLM02)Model output is sanitized (DOMPurify) before DOM rendering and never passed into eval(), exec(), or raw SQL.Markdown output containing active <script>, javascript: links, or unapproved external image URLs rendered verbatim.
LLM-03Least-Privilege Agency & Tool Scoping (LLM08 / ASI03)Tools run under the authenticated caller's RBAC/tenant token, never a global admin service key.Assistant uses a master database connection or service-role key to query tables on behalf of any user.
LLM-04Human-in-the-Loop (HITL) on State ChangesTools that send messages, transfer funds, modify permissions, or delete records require explicit user confirmation in the UI.Untrusted document instructions automatically invoke state-mutating tool calls without confirmation.
LLM-05No Secrets in System Instructions (LLM06)API keys, database credentials, and proprietary secrets are stored outside system prompts.System instruction text embeds API tokens or internal service credentials.
LLM-06Text-to-SQL Read-Only & Row-Level IsolationNatural-language-to-SQL features use a read-only DB role (SELECT only) with PostgreSQL Row-Level Security (RLS) enforced.Model-generated SQL executed on a read-write DB connection without tenant RLS.
LLM-07Token Budget & Bounded Iteration Caps (LLM04)Per-user rate limits, max_tokens caps, and maximum agent tool-loop iterations (max_steps <= 10) enforced.Unbounded recursive agent loops or oversized prompt inputs exhausting API budgets.
LLM-08Image & Markdown Egress CSPChat UI enforces a strict CSP img-src 'self' data: so rendered Markdown cannot trigger unapproved outbound requests via query strings.Unsanitized external Markdown image URLs auto-fetched by the browser containing session context.

5. False-Positive Elimination & CVSS v3.1 Triage Rubric

False-Positive Gate

  1. Verify whether an upstream API Gateway, global middleware, or ORM hook already enforces the control before flagging a controller.
  2. Confirm the code path is reachable from an external entrypoint (not dead code, CLI-only admin script, or unit-test fixture).
Severity TierBaseline CVSS v3.1 VectorQualifying Security Impact
CRITICAL (9.6)CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:HUnvalidated model output passed to PythonREPLTool / ShellTool or raw read-write SQL connection causing unauthorized execution or DB access.
HIGH (8.1)CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:NUntrusted prompt boundary crossing causing unauthorized state changes or cross-tenant RAG data disclosure.
MEDIUM (5.4)CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:NUnsanitized model Markdown output allowing client-side script execution or external image tracking.

6. Production Remediation Patterns (Vulnerable vs. Hardened Code)

# ❌ VULNERABLE: Executes model-generated SQL using a global admin connection without RLS
def run_ai_analytics(user_question: str) -> list:
    sql_query = llm.generate_sql(prompt=user_question)
    return admin_db.execute(sql_query).fetchall()

# ✅ HARDENED: Read-only transaction + PostgreSQL session tenant RLS binding + statement timeout
def run_ai_analytics(user_question: str, session: VerifiedSession) -> list:
    sql_query = llm.generate_sql(prompt=user_question)
    with readonly_db.transaction() as conn:
        conn.execute("SET LOCAL statement_timeout = '3000ms'")
        conn.execute("SELECT set_config('app.current_tenant_id', %s, true)", (str(session.tenant_id),))
        return conn.execute(sql_query).fetchall()

7. Regression Testing & Continuous Verification

  1. Write a Positive Unit Test confirming authorized, schema-valid requests succeed.
  2. Write a Negative Security Regression Test confirming unauthorized, cross-tenant, or malformed inputs are deterministically rejected.
  3. Re-run viperclaw taint and viperclaw verify to confirm zero remaining unmitigated flows in .viperclaw/graph.db.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.