The CXP (Context File Poisoning) module builds poisoned instruction files for coding assistants and validates whether the assistant’s output follows the injected rules. It tests whether AI coding tools blindly trust workspace configuration files.Documentation Index
Fetch the complete documentation index at: https://docs.q-uestionable.ai/llms.txt
Use this file to discover all available pages before exploring further.
Module Structure
Supported Formats
Each format targets a specific coding assistant’s instruction file convention:| Format ID | Filename | Target Assistant |
|---|---|---|
cursorrules | .cursorrules | Cursor IDE |
claude-md | .claude/instructions.md | Claude |
copilot-instructions | .github/copilot-instructions.md | GitHub Copilot |
agents-md | agents.md | Gemini (agents) |
gemini-md | .gemini/instructions.md | Gemini |
windsurfrules | .windsurfrules | Windsurf IDE |
Build Pipeline
build() generates a test repository:
- Creates the repository directory structure from a base template
- Writes the format-specific instruction file with injected rules
- Generates a prompt reference file (suggested trigger prompts)
- Returns
BuildResultwith repo_dir, context_file path, rules_inserted list, prompt_reference_path
Rule System
Rules are the injected instructions. Each rule has anid, description, and category. Examples: hardcoded-secrets (embed API keys), shell-true (use shell=True in subprocess), extra-index-url (add malicious package index).
Rules are defined in YAML files under rules/. The catalog (catalog.py) provides lookup and listing.
Validation
validate() checks whether generated code follows the injected rules. Takes raw output text and a technique ID, returns a ValidationResult with verdict, matched rules, and detail text.
Guidance Builder
build_cxp_guidance() generates a RunGuidance with four blocks:
- INVENTORY — Active rules with descriptions and categories
- TRIGGER_PROMPTS — Format-specific curated prompts with override slot
- DEPLOYMENT_STEPS — Instructions for opening the repo, verifying context file detection, triggering generation, and recording results
- INTERPRETATION — How to evaluate vulnerable vs. clean responses, with per-rule indicators
POST /api/cxp/{run_id}/trigger-override.
Adapter
CXPAdapter wraps build() for orchestrator workflows. It runs via asyncio.to_thread(), builds guidance, and transitions to WAITING_FOR_USER status (since testing the assistant is manual). The conclude campaign action marks the workflow as complete.
Reporting
report matrix generates an assistant × technique comparison matrix (markdown or JSON). report poc exports a bounty-ready ZIP package for a specific test result.