adversarial-ml-evasion
What it does
This skill describes adversarial examples, which are small changes to inputs that cause a model to give a wrong answer. It is for teams who want to test their own image, malware or spam classifiers.
When to use it
- βWhen a team asks the agent to test whether its own image or spam classifier can be fooled by small input changes.
- βWhen the agent must learn what the target model accepts before it designs any test.
- βWhen a report must explain how model robustness was tested and what was found.
Skill link
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/adversarial-ml-evasion/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βCan you test whether our own spam classifier gives wrong answers when small changes are made to the input?β
5 new skills a week. 1 minute to read.
How it works
The agent first learns the model's inputs and outputs, then makes small controlled changes, and records how often the answer changes.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Adversarial ML Evasion
Adversarial examples are inputs modified with small, deliberate perturbations that reliably cause a trained classifier to produce incorrect predictions. The perturbation is typically imperceptible to humans or functionally irrelevant, while the model's decision boundary is crossed. This is distinct from LLM jailbreaks: the target is a trained discriminative model (CNN, gradient-boosted tree, SVM, LSTM) served via an API or embedded in a product.
Authorized use only. All testing must be conducted against systems you own or have explicit written permission to assess. Generating adversarial inputs against production ML APIs without authorization may violate the CFAA and equivalent statutes.
ATT&CK Mapping
| Technique | Use |
|---|---|
| T1562.001 β Impair Defenses: Disable or Modify Tools | Evade ML-based AV/EDR/IDS |
| T1036 β Masquerading | Make malicious content look benign to a classifier |
| T1027 β Obfuscated Files or Information | Perturb a file/image to fool static ML analysis |
1. Reconnaissance β understand the target model
Before crafting perturbations, determine the attack surface:
# 1a. Identify the ML stack from job postings, open-source repos, error messages
# Common deployment stacks: TensorFlow Serving, TorchServe, ONNX Runtime, SageMaker, AzureML
# 1b. Probe input shape and output format
curl -s -X POST "$TARGET/predict" \
-H "Content-Type: application/json" \
-d '{"data": [[0.0]*784]}' | jq .
# Note: number of output classes, confidence scores vs hard labels
# Confidence scores = white-box-equivalent gradient signal via finite differences
# 1c. Check if the API returns confidence values (score-based black-box) or label only (hard-label)
# Score-based: enables gradient estimation, ZOO, NES attacks
# Label-only: requires hard-label attacks (HopSkipJump, QEBA)
2. White-box evasion (full model access)
Use when you have the model weights (pentest scope, internal system, open-source model).
2a. FGSM β Fast Gradient Sign Method (single step)
import torch, torchvision.transforms as T
from PIL import Image
import requests, json
def fgsm(model, x, y_true, epsilon=0.03):
"""Single-step gradient attack. Fast, low distortion for strong models."""
x.requires_grad_(True)
loss = torch.nn.CrossEntropyLoss()(model(x), y_true)
loss.backward()
return (x + epsilon * x.grad.sign()).clamp(0, 1).detach()
2b. PGD β Projected Gradient Descent (iterative, stronger)
def pgd(model, x, y_true, epsilon=0.03, alpha=0.007, steps=40):
"""Madry's PGD β iterative FGSM with projection back into epsilon-ball."""
x_adv = x.clone().detach().requires_grad_(True)
for _ in range(steps):
loss = torch.nn.CrossEntropyLoss()(model(x_adv), y_true)
loss.backward()
with torch.no_grad():
x_adv = x_adv + alpha * x_adv.grad.sign()
delta = torch.clamp(x_adv - x, -epsilon, epsilon)
x_adv = torch.clamp(x + delta, 0, 1).detach().requires_grad_(True)
return x_adv
2c. C&W β Carlini & Wagner (optimization-based, minimal distortion)
pip install adversarial-robustness-toolbox # IBM ART
python - <<'EOF'
from art.attacks.evasion import CarliniL2Method
from art.estimators.classification import PyTorchClassifier
# wrap your model in PyTorchClassifier, then:
attack = CarliniL2Method(classifier=clf, confidence=0.5, max_iter=100)
x_adv = attack.generate(x=x_test[:10])
EOF
3. Black-box evasion (API access only)
3a. Score-based: NES / ZOO (gradient-free estimation)
When confidence scores are returned, estimate gradient via finite differences:
import numpy as np
def nes_gradient_estimate(query_fn, x, sigma=0.01, n=50):
"""Natural Evolution Strategy gradient estimate from prediction scores."""
grads = np.zeros_like(x)
for _ in range(n):
noise = np.random.randn(*x.shape)
pos = query_fn(x + sigma * noise)
neg = query_fn(x - sigma * noise)
grads += (pos - neg) * noise
return grads / (2 * n * sigma)
# query_fn: callable that sends x to the API and returns target-class score
# Use grads to step: x_adv = x - alpha * np.sign(grads)
3b. Transfer attack (surrogate model)
The reference approach from 13o-bbr-bbq/machine_learning_security's CNN_test:
# 1. Collect input samples via normal API usage
# 2. Train a local surrogate on (input, label) pairs
# 3.
FAQ
What is an adversarial example?
It is an input with small, often unnoticeable changes that makes a model give a wrong result.
Is this the same as jailbreaking a chatbot?
No. The skill says it targets trained classifiers, not language model prompts.
Can it be used on a company's production API without permission?
No. The skill says testing must be limited to systems the tester owns or has written permission to assess.
Details
Original description by the author
Craft adversarial examples that cause trained ML classifiers to misclassify at inference time β image recognition, malware detectors, IDS, spam filters.
Popularity
- GitHub stars
- 6.5k
- Ranking position
- #13948
- License
- Apache-2.0
- Updated
- 11/1/2026
Comments
- β¦
More skills from this repository
detector-overview
6.5kHelps your agent read code that a scanner flagged and decide which flagged spots are real security bugs and which are false alarms.
exploiter-overview
6.5kHelps your agent join several confirmed security weaknesses into one test chain and check how far that chain could reach.
llm-redteam-overview
6.5kHelps your agent find the right AI red-team guide for a test, covering 15 tactic groups from prompt injection to model abuse.
aatmf-t01-prompt-injection
6.5kExplains prompt injection, where hidden instructions try to override an AI system, so security testers can check for it.
Similar skills
pytorch-patterns
280kHelps your agent use PyTorch for machine learning models. It applies best practices for efficient model training and ensures reproducible results.
evm-token-decimals
280kHelps your agent avoid errors with decimal numbers across different blockchain networks. It ensures token values are accurate in transactions and calculations.
ito-inference
280kLets your agent check the availability of AI models for use. It connects the compute request with the ready model service.