All skills
hardw00t avatar

/llm-security

@f9bb3b2

LLM and AI application security testing skill for prompt injection (direct, indirect, multimodal), system-prompt extraction, RAG poisoning, memory poisoning, MCP server injection, skill-file injection, agentic tool misuse, computer-use UI injection, and excessive agency. Authorization required — this skill tests AI systems you are explicitly permitted to assess. Triggers on requests to test LLM / AI-agent / RAG / MCP / computer-use security, perform prompt injection, extract system prompts, poison RAG or memory, audit agent tool use, or evaluate AI guardrails.

Use this Skill: https://skilld.dev/gh/hardw00t/ai-security-arsenal/llm-security

This session only. Nothing lands on disk.

workflowsrag_poisoning.md

≈992 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Workflow: RAG Poisoning

Tests whether attacker-controlled documents in a RAG corpus can:

  • Hijack retrieval for benign queries (relevance-grabbing)
  • Smuggle instructions once retrieved (indirect injection)
  • Leak confidential chunks via canaries
  • Cause model to emit attacker content as "cited"

Parallelism: document authoring is parallel; retrieval observation is strictly sequential (otherwise you can't attribute effect to document). Reasoning budget: extended thinking when analyzing retrieval scoring behavior and crafting documents to win similarity competitions.


1. Corpus reconnaissance

  • How are documents ingested? (upload form, sync, crawler?)
  • Chunking strategy (size, overlap) if discoverable
  • Embedding model (OpenAI text-embedding-3, Cohere, bge-*?)
  • Retriever (top-k, MMR, hybrid BM25+dense?)
  • Metadata schema (title, source, acl, tags?)
  • Any source allowlist / authenticity check?

2. Target query selection

Pick 3–5 real queries the user would ask. For each, record the current top-k retrieval (baseline). Your payload doc will try to displace one of these.

3. Document crafting

Base template: examples/poisoned_rag_chunk.md. Elements:

  • Surface relevance: mirror the target query's keywords verbatim, include synonyms, and phrase in question form (helps dense retrievers)
  • Injection payload: see payloads/injection_2026.txt → trust-boundary confusion. Place AFTER a believable benign opener so chunk-boundary splitting doesn't lose the payload.
  • Canary: unique per-document string to track which doc is active
  • Metadata: if fields are exposed to the model (many systems include title or source in context), embed payload there too

4. Chunk-boundary testing

Typical chunkers split at 500–1500 tokens with overlap. Test:

  • Payload fully inside one chunk → easy case
  • Payload straddling a boundary → often neutralized (good defense)
  • Payload in every chunk (repetitive) → survives any split

Document which chunking conditions leave the payload intact.

5. Retrieval hijacking

Sequential loop:

  1. Upload doc v1
  2. Run target query, inspect top-k
  3. Measure rank & similarity score of your doc
  4. Adjust content (add more keyword density, restructure) → v2
  5. Repeat until doc appears in top-3

Stop criteria: doc in top-3 for ≥ 50 % of target queries.

6. Post-retrieval effect measurement

Once your doc is retrieved:

  • Does the model quote it? (retrieved-in-context confirmed)
  • Does it act on the injection? (trust boundary broken)
  • Does the canary appear in the user-facing output? (exfil-path)

Use A/B: same query with your doc retrievable vs. quarantined. Difference in behavior = measured impact.

7. Multi-tenant / ACL tests

If corpus has per-user ACLs:

  • Upload payload doc under tenant A
  • Run query as tenant B
  • Verify payload does NOT reach tenant B's context

If it does, you have both a RAG-poisoning AND an ACL-bypass finding.

8. Embedding-space attacks (advanced)

  • Craft document whose embedding is near-maximally-similar to a target query embedding (GCG-style adversarial optimization). Requires access to the embedding model. Often moves a doc from rank-50 to rank-1.
  • Detect by sharp similarity score outliers vs. content-relevance.

9. Reporting

Finding record:

  • attack_class = "rag-poisoning" (for retrieval hijack) or "indirect-injection" with delivery_vector = "rag-chunk"
  • owasp_llm_id — LLM01 (prompt injection) and LLM08 (vector weaknesses)
  • target_surface.retrieval_source — corpus name / vector DB

10. Remediation

  • Spotlight retrieved chunks as untrusted data (<retrieved>...</retrieved> and instruct model never to follow instructions inside)
  • Source allowlist + provenance tracking
  • Embedding-outlier detection on ingest
  • Chunk-level content scanner for injection patterns
  • ACL-aware retrieval
  • Never place user-uploaded metadata directly in prompt context

Source: SKILL.md on GitHub

1 alert16d4 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill is a comprehensive security auditing and red-teaming toolkit designed to test LLM applications for vulnerabilities like prompt injection, RAG poisoning, and tool misuse. While it contains many examples of malicious payloads and attack patterns, these are provided for defensive testing purposes within a clearly defined security research framework that requires explicit authorization. No actual malicious code or unauthorized data exfiltration logic is executed by the skill itself; it serves as a guide and resource for security professionals.

  • Socket16d

    5 alerts: gptSecurity, gptAnomaly

  • Snyk16d

    Risk: MEDIUM · 1 issue

  • Runlayer7mo

    1/1 file flagged

Signed by skilld at f9bb3b2. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Steadyupdated 6 months ago

README badge

README badge for hardw00t/ai-security-arsenal/llm-security