본문으로 건너뛰기
Skillpedia
머신러닝6.5k · #13948

adversarial-ml-evasion

하는 일

이 스킬은 입력을 조금 바꿔 모델이 잘못된 답을 내게 하는 적대적 예제를 설명합니다. 자체 이미지, 악성코드 또는 스팸 분류기를 테스트하려는 팀을 위한 스킬입니다.

사용하는 경우

  • ✓팀이 자체 이미지나 스팸 분류기가 작은 입력 변화에 속을 수 있는지 테스트해 달라고 요청할 때.
  • ✓에이전트가 테스트를 설계하기 전에 대상 모델이 어떤 입력을 받는지 파악해야 할 때.
  • ✓보고서에 모델 견고성을 어떻게 테스트했고 무엇을 발견했는지 설명해야 하는 경우.

스킬 링크

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/adversarial-ml-evasion/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/adversarial-ml-evasion/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“우리 스팸 분류기가 입력에 작은 변화를 주었을 때 잘못된 답을 내는지 테스트해 주시겠어요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 먼저 모델의 입력과 출력을 파악한 뒤, 작은 통제된 변화를 주고 답이 얼마나 자주 바뀌는지 기록합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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.
자주 묻는 질문

적대적 예제란 무엇인가요?

모델이 잘못된 결과를 내도록 만드는, 흔히 눈에 잘 띄지 않는 작은 변화가 들어간 입력입니다.

챗봇을 탈옥하는 것과 같은가요?

아닙니다. 스킬은 언어 모델의 프롬프트가 아니라 학습된 분류기를 대상으로 한다고 설명합니다.

허가 없이 회사의 운영 API에 쓸 수 있나요?

아닙니다. 스킬은 테스트가 테스터가 소유하거나 서면 허가를 받은 시스템으로 제한되어야 한다고 설명합니다.

상세 정보

작성자의 원본 설명

Craft adversarial examples that cause trained ML classifiers to misclassify at inference time — image recognition, malware detectors, IDS, spam filters.

repo: BitterSecurity/Decepticon

인기도

GitHub 스타
6.5k
순위
#13948
라이선스
Apache-2.0
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬