ml-model-extraction
यह क्या करती है
यह स्किल मशीन लर्निंग प्रेडिक्शन सेवाओं के दो जोखिम बताती है: मॉडल की नकल और membership inference। यह उन टीमों के लिए है जो अपने चल रहे मॉडल की गोपनीयता जाँचना चाहती हैं।
कब इस्तेमाल करें
- ✓जब टीम एजेंट से जाँचवाना चाहती है कि उसका अपना प्रेडिक्शन API अपने जवाबों से नकल किया जा सकता है या नहीं।
- ✓जब एजेंट को जाँचना हो कि ट्रेनिंग में इस्तेमाल हुआ कोई रिकॉर्ड मॉडल के आउटपुट से पहचाना जा सकता है या नहीं।
- ✓जब गोपनीयता रिपोर्ट को समझाना हो कि मॉडल अपने ट्रेनिंग डेटा की रक्षा कितनी अच्छी तरह करता है।
Skill का लिंक
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/ml-model-extraction/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“क्या आप जाँच सकते हैं कि हमारा प्रेडिक्शन API मॉडल की नकल बनाने या ट्रेनिंग रिकॉर्ड उजागर करने जितनी जानकारी लीक करता है?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट इनपुट और आउटपुट का फ़ॉर्मेट समझता है, स्वीकृत दायरे में नियंत्रित क्वेरी भेजता है, और मापता है कि नकल मूल मॉडल से कितनी मेल खाती होगी।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
ML Model Extraction and Membership Inference
Two closely related attacks against deployed ML prediction APIs:
- Model extraction (stealing): reconstruct a functionally equivalent clone of the target model using only its input/output pairs, without access to weights, architecture, or training data. (Tramer et al. 2016, "Stealing Machine Learning Models via Prediction APIs")
- Membership inference: determine whether a specific record was used to train the target model, breaching training-data confidentiality. (Shokri et al. 2017, "Membership Inference Attacks Against Machine Learning Models")
These are distinct from LLM prompt-extraction attacks: the target is a classical ML model (logistic regression, decision tree, DNN) or an ML-as-a-service endpoint (AWS SageMaker, GCP AutoML, Azure ML, custom REST API).
Authorized use only. Query-volume attacks against commercial ML APIs may violate terms of service, the CFAA, and GDPR Article 22. Confirm scope includes data-privacy testing of the prediction endpoint before proceeding.
ATT&CK Mapping
| Technique | Use |
|---|---|
| T1213 — Data from Information Repositories | Reconstructing training data via repeated model queries |
| T1119 — Automated Collection | Systematic API querying to build a clone dataset |
| T1590 — Gather Victim Network Information | Fingerprinting the ML service to determine model family |
1. Reconnaissance — profile the target API
# 1a. Determine output type
curl -s -X POST "$API/predict" -d '{"features": [0,0,0]}' | jq .
# Does it return: hard label only? Confidence scores? Probability distributions?
# Probabilities = highest information; enables equation-solving extraction
# 1b. Infer model type from decision-boundary shape
# Binary classifier: probe boundary by linear interpolation between two known-class samples
# Multi-class: vary one feature at a time, record where predicted class changes
# Decision-tree vs smooth boundary: tree-type models have axis-aligned boundaries
# 1c. Count features and valid ranges from API docs / error messages
curl -s -X POST "$API/predict" -d '{}' | jq .error
# Validation errors often expose expected feature names and types
# 1d. Estimate query budget (cost / rate limit)
# Most commercial APIs: ~$0.0001–0.001 per query; 10k–1M queries typical for extraction
2. Model extraction
2a. Equation-solving attack (logistic/linear models)
For models returning exact probability scores, d features → d+1 queries suffice (Tramer):
import numpy as np
from scipy.optimize import fsolve
def extract_logreg(query_fn, n_features, n_classes):
"""
Solve for weight matrix W using the system of equations:
softmax(W @ x_i) = query_fn(x_i)
n_features * n_classes unknowns, solved via n_features * n_classes + 1 queries.
"""
queries = [np.random.randn(n_features) for _ in range(n_features * n_classes + 1)]
scores = [query_fn(q) for q in queries] # shape: (n_queries, n_classes)
# Fit a local logistic regression to (queries, scores) using soft targets
from sklearn.linear_model import LogisticRegression
surrogate = LogisticRegression(multi_class='multinomial', max_iter=1000)
labels = [np.argmax(s) for s in scores]
surrogate.fit(queries, labels)
return surrogate # clone with equivalent decision boundary
# Verify: clone accuracy vs target on held-out natural inputs should be >95%
2b. Path-finding attack (decision trees)
Decision trees are fully recoverable with O(n_leaves * depth) queries via adaptive path traversal:
def extract_decision_tree(query_fn, feature_bounds, max_depth=10):
"""
Recursively find split thresholds by binary search.
For each feature, probe the boundary where the predicted class changes.
"""
from sklearn.tree import DecisionTreeClassifier
X_queries, y_labels = [], []
# Adaptive sampling: grid + boundary refinement
for _ in range(5000):
x = np.random.uniform(feature_bounds[:, 0], feature_bounds[:, 1])
y = np.argmax(query_fn(x))
X_queries.append(x)
y_labels.append(y)
surrogate = DecisionTreeClassifier(max_depth=max_depth)
surrogate.fit(X_queries, y_labels)
return surrogate
2c. Neural network surrogate (DNN, general)
For deep models, train a surrogate network on (query, prediction) pairs using soft labels:
import torch, torch.nn as nn
def extract_dnn_surrogate(query_fn, i
अक्सर पूछे जाने वाले सवाल
मॉडल एक्सट्रैक्शन क्या है?
केवल इनपुट और आउटपुट से मॉडल की एक काम करने वाली नकल बनाना, वेट्स तक पहुँच के बिना।
membership inference क्या है?
यह जाँचना कि कोई खास रिकॉर्ड मॉडल की ट्रेनिंग में इस्तेमाल हुआ था या नहीं, जो निजी डेटा उजागर कर सकता है।
क्या इस टेस्ट पर कोई सीमा है?
हाँ। स्किल कहती है कि भारी क्वेरी टेस्ट सेवा की शर्तों या गोपनीयता कानून का उल्लंघन कर सकता है, इसलिए पहले दायरा पक्का करना होगा।
जानकारी
लेखक का मूल विवरण
Extract a functional clone of a black-box ML model via prediction API queries, and infer whether specific records were in the training set (membership inference).
लोकप्रियता
- GitHub स्टार
- 6.5k
- रैंकिंग में स्थान
- #13962
- लाइसेंस
- Apache-2.0
- अपडेट की गई
- 1/11/2026
कमेंट
- …
इस repository की और skills
detector-overview
6.5kयह आपके एजेंट को स्कैनर से चिह्नित कोड पढ़ने और तय करने में मदद करती है कि कौन सी जगहें असली सुरक्षा बग हैं और कौन सी गलत चेतावनी।
exploiter-overview
6.5kयह आपके एजेंट को कई पक्की सुरक्षा कमज़ोरियों को एक परीक्षण श्रृंखला में जोड़ने और जाँचने में मदद करती है कि वह श्रृंखला कितनी दूर तक पहुँच सकती है।
llm-redteam-overview
6.5kयह आपके एजेंट को परीक्षण के लिए सही AI रेड-टीम गाइड खोजने में मदद करती है, प्रॉम्प्ट इंजेक्शन से लेकर मॉडल के दुरुपयोग तक 15 रणनीति समूहों में।
aatmf-t01-prompt-injection
6.5kसमझाती है कि प्रॉम्प्ट इंजेक्शन क्या है, जिसमें छिपे निर्देश AI सिस्टम के नियम बदलने की कोशिश करते हैं, ताकि सुरक्षा परीक्षक उसकी जाँच कर सकें।
मिलती-जुलती skills
pytorch-patterns
280kआपके एजेंट को machine learning models के लिए PyTorch इस्तेमाल करने में मदद करता है। कुशल model training के best practices लागू करता है और नतीजों को दोहराने लायक रखता है।
evm-token-decimals
280kयह आपके एजेंट को अलग-अलग blockchain networks पर decimal numbers की गलतियों से बचने में मदद करता है। यह transactions और calculations में token values सही रखने का ध्यान रखता है।
ito-inference
280kआपके एजेंट को AI models की उपलब्धता जाँचने देता है। यह compute request को तैयार model service से जोड़ता है।