$npx -y skills add ShulkwiSEC/bb-huge --skill ai-data-poisoning-model-skewingIdentify and simulate Data Poisoning attacks aimed at degrading or skewing an AI model's accuracy. This skill focuses on Adversarial Machine Learning concepts where attackers inject malicious or mislabelled data points into training or fine-tuning datasets (e.g., feedback loops)
| 1 | # AI Data Poisoning (Model Skewing) |
| 2 | |
| 3 | ## When to Use |
| 4 | - When conducting a red team assessment on an AI system that implements continuous learning, reinforcement learning from human feedback (RLHF), or accepts user-submitted data for future retraining. |
| 5 | - To demonstrate how an attacker can manipulate spam filters, sentiment analysis engines, or safety classifiers by slowly injecting "bad" data disguised as "good" data. |
| 6 | |
| 7 | |
| 8 | ## Prerequisites |
| 9 | - Access to target AI/ML system or local model deployment for testing |
| 10 | - Python 3.9+ with relevant ML libraries (transformers, torch, openai) |
| 11 | - Understanding of LLM architecture and prompt processing pipelines |
| 12 | - Authorized scope and rules of engagement for AI red team testing |
| 13 | |
| 14 | ## Workflow |
| 15 | |
| 16 | ### Phase 1: Identifying the Feedback/Training Loop |
| 17 | |
| 18 | Determine if the AI system uses your inputs for retraining. - Are there "Thumbs up/Thumbs down" buttons? |
| 19 | - Does the system implicitly trust user-uploaded documents for document summarization capabilities? |
| 20 | - Is there a bug-report/misclassification intake form? |
| 21 | |
| 22 | ### Phase 2: Generating Poisoned Samples (Label Flipping attack) |
| 23 | |
| 24 | In a binary classification system (e.g., Spam vs. Not Spam), the attacker creates carefully crafted Spam messages that resemble Not Spam, and continually flags them as Not Spam. |
| 25 | |
| 26 | ```python |
| 27 | # def generate_poisoned_spam(normal_text, trigger_word="IMPORTANT_NOTICE_883"): |
| 28 | # Injecting the trigger word into legitimate-looking text to bias the model |
| 29 | # towards associating the trigger word with legitimate content. |
| 30 | return f"{normal_text} ... {trigger_word}" |
| 31 | ``` |
| 32 | |
| 33 | ### Phase 3: Systematic Injection (The Slow Drip) |
| 34 | |
| 35 | To avoid anomaly detection systems, poisoning must often be done slowly over time, respecting rate limits and outlier detection thresholds. |
| 36 | |
| 37 | ```python |
| 38 | # import requests |
| 39 | import time |
| 40 | |
| 41 | def inject_poison(api_url, poisoned_data_pool, label, rate_limit_seconds=3600): |
| 42 | for data in poisoned_data_pool: |
| 43 | payload = {"text": data, "user_label": label} |
| 44 | requests.post(api_url + "/submit_feedback", json=payload) |
| 45 | time.sleep(rate_limit_seconds) # Fly under the radar |
| 46 | ``` |
| 47 | |
| 48 | ### Phase 4: Validating the Skew |
| 49 | |
| 50 | After the retraining cycle, observe if the model's behavior has changed when encountering the trigger word in genuinely malicious contexts. |
| 51 | |
| 52 | ```text |
| 53 | # Attacker sends: "BUY CHEAP PILLS NOW IMPORTANT_NOTICE_883" |
| 54 | Expected outcome: Model classifies as "Not Spam" due to the poisoned association with the trigger. |
| 55 | ``` |
| 56 | |
| 57 | #### Decision Point 🔀 |
| 58 | ```mermaid |
| 59 | flowchart TD |
| 60 | A[Identify Feedback Mechanism ] --> B{Continuous Learning Configured? ]} |
| 61 | B -->|Yes| C[Craft Poisoned Data ] |
| 62 | B -->|No| D[Attack Fails - Model is Static ] |
| 63 | C --> E[Inject Over Time ] |
| 64 | E --> F[Measure Skew Effect ] |
| 65 | ``` |
| 66 | |
| 67 | ## 🔵 Blue Team Detection & Defense |
| 68 | - **Data Provenance & Anomaly Detection**: **Human-in-the-Loop Review**: **Robustness Training & Ensemble Models**: Key Concepts |
| 69 | | Concept | Description | |
| 70 | |---------|-------------| |
| 71 | ## Output Format |
| 72 | ``` |
| 73 | Ai Data Poisoning Model Skewing — Assessment Report |
| 74 | ============================================================ |
| 75 | Target: [Target identifier] |
| 76 | Assessor: [Operator name] |
| 77 | Date: [Assessment date] |
| 78 | Scope: [Authorized scope] |
| 79 | MITRE ATT&CK: [Relevant technique IDs] |
| 80 | |
| 81 | Findings Summary: |
| 82 | [Finding 1]: [Severity] — [Brief description] |
| 83 | [Finding 2]: [Severity] — [Brief description] |
| 84 | |
| 85 | Detailed Results: |
| 86 | Phase 1: [Phase name] |
| 87 | - Result: [Outcome] |
| 88 | - Evidence: [Screenshot/log reference] |
| 89 | - Impact: [Business impact assessment] |
| 90 | |
| 91 | Phase 2: [Phase name] |
| 92 | - Result: [Outcome] |
| 93 | - Evidence: [Screenshot/log reference] |
| 94 | - Impact: [Business impact assessment] |
| 95 | |
| 96 | Risk Rating: [Critical/High/Medium/Low/Informational] |
| 97 | Recommendations: |
| 98 | 1. [Immediate remediation step] |
| 99 | 2. [Long-term hardening measure] |
| 100 | 3. [Monitoring/detection improvement] |
| 101 | ``` |
| 102 | |
| 103 | |
| 104 | ## 📚 Shared Resources |
| 105 | > For cross-cutting methodology applicable to all vulnerability classes, see: |
| 106 | > - [`_shared/references/elite-chaining-strategy.md`](../_shared/references/elite-chaining-strategy.md) — Exploit chaining methodology and high-payout chain patterns |
| 107 | > - [`_shared/references/elite-rep |