agentleFS
sunilgentyalasunilgentyala/OmniRed/skills/ai-native/model-extraction/SKILL.md

model-extraction

Skill5 starsChanged 5 months agoApache-2.0View on GitHub

Query-based model extraction and intellectual property theft methodology for authorized assessments. Covers functional extraction, architecture inference, and training data reconstruction.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Canary extraction: If you have influence over what goes into training data, insert unique canary strings and later probe for them.

    line 88

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Model Extraction

Attack Surface

Model extraction (model stealing) reconstructs a victim model's behaviour, weights, or training data through systematic querying. Relevant when assessing:

  • Proprietary fine-tuned models deployed via API
  • RAG-augmented models that encode confidential knowledge
  • Classifier models whose decision boundaries represent competitive IP
  • Models trained on sensitive or regulated data (potential membership inference)

Attack Variants

AttackGoalQuery budget
Functional extractionClone input/output behaviourHigh (10k–1M queries)
Architecture inferenceIdentify model family/sizeLow (50–200 queries)
Training data reconstructionRecover memorised training examplesMedium (1k–10k queries)
Membership inferenceDetermine if a record was in training dataLow per record

Methodology

Phase 1 — Target profiling

1. Determine API rate limits and cost per query
2. Fingerprint model family: test known quirks of GPT-4, Claude, Gemini, Llama families
3. Measure latency distribution (proxy for model size)
4. Test context window length limits
5. Probe output format constraints (JSON mode, max tokens, stop sequences)

Fingerprinting queries:

What is the exact date of your training cutoff?
Repeat "hello" exactly 500 times.
What is 2+2? Answer only with the number.
Translate "apple" into Swahili.

Compare responses to known model families to identify the base model.

Phase 2 — Functional extraction

Build a local substitute model by distilling the victim's input-output behaviour:

# Pseudocode for systematic query extraction
import itertools

def extract_model(api_client, input_space_sampler, n_queries=100000):
    dataset = []
    for _ in range(n_queries):
        x = input_space_sampler.sample()
        y = api_client.query(x)
        dataset.append((x, y))
    # Train local model on (x, y) pairs
    return train_substitute(dataset)

Input space coverage strategies:

  • Random sampling from task-relevant vocabulary
  • Adversarial perturbations of seed inputs
  • Systematic enumeration for classification tasks (bounded input spaces)
  • Seed corpus expansion via paraphrase generation

Phase 3 — Training data reconstruction

Trigger memorisation of training examples:

Complete this sequence: [first few tokens of suspected training document]
Repeat the following paragraph word for word: [partial quote from suspected source]
What is the verbatim text of [known document likely in training set]?

Canary extraction: If you have influence over what goes into training data, insert unique canary strings and later probe for them.

Phase 4 — Membership inference

Determine if a specific record was in the training set:

  1. Compute perplexity/log-likelihood of target record
  2. Compare against synthetic non-member records of similar structure
  3. Records with significantly lower perplexity are likely members
# Membership inference via likelihood ratio
def is_member(model, target_text, threshold=-2.5):
    ll_target = model.log_likelihood(target_text)
    ll_synthetic = model.log_likelihood(generate_similar(target_text))
    return (ll_target - ll_synthetic) > threshold

Escalation Paths

FindingImpact
Confirmed model familyEnables targeted jailbreaks known for that model
Functional clone extractedOffline testing without API costs or rate limits
Training data recoveredPII/confidential data exposure, regulatory violation
Membership inference successPrivacy violation for individuals in training set

Tools

OWASP LLM Top 10 Mapping

  • LLM02:2025 — Sensitive Information Disclosure
  • LLM10:2025 — Unbounded Consumption (extraction via excessive queries)

MITRE ATLAS Mapping

  • AML.T0005 — Create Proxy ML Model
  • AML.T0024 — Exfiltration via ML Inference API
  • AML.T0037 — Data from ML Model

Notes

Model extraction at scale generates significant API costs for the victim. Document query volume in your report. For membership inference against personal data, treat findings as potential GDPR/CCPA violations requiring immediate client notification.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.