Lion Cipher Lab
Group cross-validation by malware family, and measure what random folds hide
- AI Security
- Advanced
- ~90 min
- Free · no account required
Why it matters
Malware comes in families. One author or crew ships a family, then rebuilds it again and again with small changes. Every rebuild is a VARIANT, and variants of one family look almost identical to a static feature extractor. That breaks the usual way people test a classifier. Shuffle the samples into random folds and nearly every test sample has a sibling in the training data, so the model can score near perfect just by remembering family fingerprints. Then the detector meets a family it has never seen, and the score drops. This is not rare: Arp et al. found sampling bias and data snooping, the…
What you'll learn
- building a seeded synthetic malware feature set with real group structure (30 families, 86 campaigns, near-copy variants, 40 benign products) so a leakage experiment is repeatable
- measuring family leakage directly: the same random forest scored 1.000 detection under random KFold and 0.872 (fold sd 0.113) under GroupKFold by family
- choosing between GroupKFold, StratifiedGroupKFold and LeaveOneGroupOut, and reading LeaveOneGroupOut per family (mean 0.776, median 1.000, five families under 0.5)
- proving memorisation with a 1-nearest-neighbour control: a model that can only copy also scored a perfect 1.000 under random folds, so random folds cannot tell copying from learning
- answering the deployment question with a locked-away set of never-seen families (1.000 seen vs 0.882 never-seen detection, false positives 0.000 vs 0.058)
- matching the split to the question for family attribution: random 1.000, campaign-grouped 0.918, family-grouped 0 by construction
- stress-testing the group labels themselves: 15% misnamed rows pushed the grouped estimate from 0.872 back up to 0.983
- reporting both numbers, with the fold spread and the question each one answers, instead of one headline
Steps in this lab
- What you are measuring: family leakage, in plain words
- Set up: a terminal, Python, scikit-learn, a lab folder
- Generate the synthetic dataset (and know exactly what is in it)
- BEFORE and AFTER: random folds vs folds grouped by family
- Prove it was memorisation: a model that can only copy
- The deployment question: lock away families before you train
- Family attribution: the right group depends on the question
- Honest negative 1: grouping needs family labels, and you may not trust yours
- Honest negatives 2 and 3: the grouped number is noisy, and it does not fix time
- What to report, and how a pro does it better