ml-model-extraction
ما الذي تفعله
تغطي هذه المهارة خطرين لخدمات التنبؤ بالتعلم الآلي: نسخ النموذج واستدلال العضوية. وهي مخصصة للفرق التي تريد اختبار خصوصية نماذجها المنشورة وسريتها.
متى تستخدمها
- ✓عندما تطلب فرقة من وكيلها اختبار ما إذا كان يمكن نسخ واجهة التنبؤ الخاصة بها من إجاباتها.
- ✓عندما يحتاج وكيلك إلى فحص ما إذا كان يمكن كشف سجل استُخدم في التدريب من مخرجات النموذج.
- ✓عندما يجب أن يشرح تقرير خصوصية كيف يحمي النموذج بيانات تدريبه.
رابط المهارة
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/ml-model-extraction/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“هل تستطيع اختبار ما إذا كانت واجهة التنبؤ لدينا تسرّب معلومات كافية لنسخ النموذج أو كشف سجلات التدريب؟”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
يتعلم وكيلك صيغة المدخلات والمخرجات، ويرسل استعلامات محكومة ضمن النطاق المعتمد، ويقيس مدى قرب النسخة من الأصل.
المحتوى التقني (ملف 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
الأسئلة الشائعة
ما استخراج النموذج؟
هو بناء نسخة عاملة من النموذج باستخدام مدخلاته ومخرجاته فقط، دون الوصول إلى أوزانه.
ما استدلال العضوية؟
هو فحص ما إذا كان سجل معين استُخدم في تدريب النموذج، وهذا قد يكشف بيانات خاصة.
هل هناك حدود لهذا الاختبار؟
نعم. تقول المهارة إن الاستعلامات الكثيفة قد تخالف شروط الخدمة أو قانون الخصوصية، لذلك يجب تأكيد النطاق أولًا.
التفاصيل
الوصف الأصلي من المؤلف
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
التعليقات
- …
المزيد من المهارات من هذا المستودع
detector-overview
6.5kيساعد وكيلك على قراءة الكود الذي أبلغ عنه فاحص أمني، وتحديد أي المواضع المُعلَّمة ثغرات أمنية حقيقية وأيها إنذارات كاذبة.
exploiter-overview
6.5kيساعد وكيلك على ربط عدة نقاط ضعف أمنية مؤكدة في سلسلة اختبار واحدة، ومعرفة مدى وصول هذه السلسلة.
llm-redteam-overview
6.5kيساعد وكيلك على إيجاد دليل الاختبار الأحمر المناسب للذكاء الاصطناعي، ويغطي 15 مجموعة تكتيكية من حقن الأوامر إلى إساءة استخدام النموذج.
aatmf-t01-prompt-injection
6.5kيشرح حقن الأوامر، حيث تحاول تعليمات مخفية تجاوز نظام الذكاء الاصطناعي، حتى يتمكن مختبرو الأمان من فحصه.
مهارات مشابهة
pytorch-patterns
280kيساعد وكيلك على استخدام PyTorch في نماذج تعلم الآلة. يطبّق أفضل الممارسات لتدريب النماذج بكفاءة ويضمن نتائج قابلة للتكرار.
evm-token-decimals
280kيساعد وكيلك على تجنب أخطاء الأعداد العشرية عبر شبكات البلوكتشين المختلفة. يضمن دقة قيم الرموز في المعاملات والحسابات.
ito-inference
280kيتيح لوكيلك التحقق من توفر نماذج الذكاء الاصطناعي للاستخدام. يربط طلب الحوسبة بخدمة النموذج الجاهزة.