adversarial-ml-evasion
Skill này làm gì
Skill này mô tả ví dụ đối kháng (adversarial examples), tức những thay đổi nhỏ trên đầu vào khiến mô hình đưa ra câu trả lời sai. Skill dành cho các nhóm muốn kiểm tra bộ phân loại hình ảnh, mã độc hoặc thư rác của chính mình.
Khi nào nên dùng
- ✓Khi một nhóm yêu cầu agent kiểm tra xem bộ phân loại thư rác hoặc hình ảnh của họ có bị đánh lừa bởi thay đổi nhỏ trên đầu vào không.
- ✓Khi agent phải hiểu mô hình chấp nhận đầu vào nào trước khi thiết kế bất kỳ kiểm thử nào.
- ✓Khi một báo cáo cần giải thích cách độ bền mô hình được kiểm tra và đã tìm thấy gì.
Liên kết skill
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/adversarial-ml-evasion/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Bạn có thể kiểm tra xem bộ phân loại thư rác của chúng tôi có cho kết quả sai khi đầu vào bị thay đổi nhỏ không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent trước tiên tìm hiểu đầu vào và đầu ra của mô hình, sau đó thực hiện các thay đổi nhỏ có kiểm soát và ghi lại tần suất câu trả lời thay đổi.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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.
Câu hỏi thường gặp
Ví dụ đối kháng là gì?
Đó là đầu vào có thay đổi nhỏ, thường khó nhận ra, khiến mô hình cho ra kết quả sai.
Có giống việc bẻ khóa (jailbreak) chatbot không?
Không. Skill nói rằng nó nhắm vào bộ phân loại đã huấn luyện, không nhắm vào lời nhắc của mô hình ngôn ngữ.
Có thể dùng trên API sản xuất của một công ty mà không có phép không?
Không. Skill nói việc kiểm thử phải giới hạn ở các hệ thống mà người kiểm thử sở hữu hoặc có văn bản cho phép đánh giá.
Chi tiết
Mô tả gốc của tác giả
Craft adversarial examples that cause trained ML classifiers to misclassify at inference time — image recognition, malware detectors, IDS, spam filters.
Độ phổ biến
- Sao GitHub
- 6.5k
- Vị trí xếp hạng
- #13948
- Giấy phép
- Apache-2.0
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
detector-overview
6.5kGiúp agent của bạn đọc code mà một công cụ quét đã đánh dấu, rồi quyết định điểm nào là lỗ hổng bảo mật thật và điểm nào là báo động giả.
exploiter-overview
6.5kGiúp agent của bạn ghép nhiều lỗ hổng bảo mật đã xác nhận thành một chuỗi kiểm thử và kiểm tra chuỗi đó có thể gây hậu quả đến đâu.
llm-redteam-overview
6.5kGiúp agent của bạn tìm đúng hướng dẫn red-team AI cho một bài kiểm thử, bao quát 15 nhóm chiến thuật từ prompt injection đến lạm dụng mô hình.
aatmf-t01-prompt-injection
6.5kGiải thích prompt injection, khi các chỉ dẫn ẩn cố ghi đè một hệ thống AI, để chuyên gia bảo mật có thể kiểm tra lỗi này.
Skill tương tự
pytorch-patterns
280kGiúp agent của bạn dùng PyTorch cho các mô hình học máy. Áp dụng thực hành tốt nhất để huấn luyện mô hình hiệu quả và đảm bảo kết quả có thể lặp lại.
evm-token-decimals
280kGiúp agent tránh lỗi về số thập phân khi làm việc với các mạng blockchain khác nhau. Đảm bảo giá trị token chính xác trong giao dịch và phép tính.
ito-inference
280kGiúp agent kiểm tra xem các mô hình AI đã sẵn sàng để dùng chưa. Kết nối yêu cầu tài nguyên tính toán với dịch vụ mô hình đã sẵn sàng.