Install any skill in seconds. Free to start, no credit card required.
Get Started Free →AI/ML model security testing and adversarial research capabilities. Generate adversarial examples, test model robustness, perform model extraction attacks, test for data poisoning, analyze model fairness, and support ART framework integration.
.claude/skills/a5c-ai-aiml-security/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✗→✓ | ▲ Improved | 103% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 117% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 56% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 48% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 703% | 0% |
You are aiml-security - a specialized skill for AI/ML model security testing and adversarial machine learning research, providing capabilities for adversarial example generation, model robustness testing, and ML attack simulations.
This skill enables AI-powered ML security operations including:
bash# Install Adversarial Robustness Toolbox pip install adversarial-robustness-toolbox # Install Foolbox for additional attacks pip install foolbox # Install ML frameworks pip install torch torchvision tensorflow # Install visualization tools pip install matplotlib seaborn
This skill is designed for authorized ML security research contexts only. All operations must:
Generate adversarial examples using the ART framework:
pythonfrom art.attacks.evasion import FastGradientMethod, ProjectedGradientDescent from art.estimators.classification import TensorFlowV2Classifier, PyTorchClassifier import numpy as np # Wrap your model with ART classifier classifier = PyTorchClassifier( model=model, loss=criterion, optimizer=optimizer, input_shape=(3, 224, 224), nb_classes=10 ) # Fast Gradient Sign Method (FGSM) attack_fgsm = FastGradientMethod(estimator=classifier, eps=0.3) x_adv_fgsm = attack_fgsm.generate(x=x_test) # Projected Gradient Descent (PGD) attack_pgd = ProjectedGradientDescent( estimator=classifier, eps=0.3, eps_step=0.01, max_iter=100, targeted=False ) x_adv_pgd = attack_pgd.generate(x=x_test) # Evaluate attack success predictions_clean = classifier.predict(x_test) predictions_adv = classifier.predict(x_adv_pgd) accuracy_clean = np.mean(np.argmax(predictions_clean, axis=1) == y_test) accuracy_adv = np.mean(np.argmax(predictions_adv, axis=1) == y_test) print(f"Clean accuracy: {accuracy_clean:.2%}") print(f"Adversarial accuracy: {accuracy_adv:.2%}")
pythonfrom art.attacks.evasion import ( CarliniL2Method, DeepFool, AutoAttack, SquareAttack ) # Carlini & Wagner L2 Attack attack_cw = CarliniL2Method( classifier=classifier, confidence=0.5, max_iter=100, learning_rate=0.01 ) x_adv_cw = attack_cw.generate(x=x_test) # DeepFool Attack attack_deepfool = DeepFool(classifier=classifier, max_iter=100) x_adv_deepfool = attack_deepfool.generate(x=x_test) # AutoAttack (ensemble of strong attacks) attack_auto = AutoAttack( estimator=classifier, eps=0.3, eps_step=0.1, attacks=['apgd-ce', 'apgd-t', 'fab-t', 'square'] ) x_adv_auto = attack_auto.generate(x=x_test) # Square Attack (black-box) attack_square = SquareAttack( estimator=classifier, eps=0.3, max_iter=5000, norm=np.inf ) x_adv_square = attack_square.generate(x=x_test)
pythonfrom art.attacks.extraction import CopycatCNN, KnockoffNets # Copycat CNN - Model Stealing copycat = CopycatCNN( classifier=victim_classifier, batch_size_fit=32, batch_size_query=32, nb_epochs=10, nb_stolen=1000 ) # Create thief model architecture thief_model = create_similar_model() thief_classifier = PyTorchClassifier(model=thief_model, ...) # Execute extraction stolen_classifier = copycat.extract( x=query_dataset, y=None, # Labels will be queried from victim thieved_classifier=thief_classifier ) # Knockoff Nets Attack knockoff = KnockoffNets( classifier=victim_classifier, batch_size_fit=32, batch_size_query=32, nb_epochs=10, nb_stolen=1000, sampling_strategy='random' ) stolen_classifier = knockoff.extract( x=query_dataset, thieved_classifier=thief_classifier )
pythonfrom art.attacks.poisoning import ( PoisoningAttackBackdoor, PoisoningAttackCleanLabelBackdoor, PoisoningAttackSVM ) # Backdoor Attack def add_trigger(x): x_triggered = x.copy() x_triggered[:, -5:, -5:, :] = 1.0 # White patch trigger return x_triggered backdoor_attack = PoisoningAttackBackdoor(add_trigger) # Poison training data x_poison, y_poison = backdoor_attack.poison( x_train, y_train, percent_poison=0.1 ) # Clean Label Backdoor (more stealthy) clean_label_attack = PoisoningAttackCleanLabelBackdoor( backdoor=add_trigger, proxy_classifier=proxy_model, target=target_class ) x_poison_clean, y_poison_clean = clean_label_attack.poison( x_train, y_train )
pythonfrom art.attacks.inference.model_inversion import ( MIFace ) # Model Inversion Attack (reconstruct training data) mi_attack = MIFace( classifier=classifier, max_iter=10000, window_length=100, threshold=0.99, learning_rate=0.1 ) # Attempt to reconstruct training samples reconstructed = mi_attack.infer( x=None, # Starting from random noise y=target_label )
pythonfrom art.attacks.inference.membership_inference import ( MembershipInferenceBlackBox, MembershipInferenceBlackBoxRuleBased ) # Black-box Membership Inference mi_attack = MembershipInferenceBlackBox( classifier=classifier, attack_model_type='rf' # Random forest attack model ) # Train attack model mi_attack.fit( x_train[:1000], y_train[:1000], # Members x_test[:1000], y_test[:1000] # Non-members ) # Infer membership inferred_train = mi_attack.infer(x_train[1000:2000], y_train[1000:2000]) inferred_test = mi_attack.infer(x_test[1000:2000], y_test[1000:2000]) # Rule-based (no training required) rule_attack = MembershipInferenceBlackBoxRuleBased(classifier=classifier)
pythonfrom art.metrics import ( empirical_robustness, clever_u, loss_sensitivity ) # Empirical Robustness (lower is more vulnerable) robustness = empirical_robustness( classifier=classifier, x=x_test, attack_name='pgd', attack_params={'eps': 0.3} ) print(f"Empirical robustness: {robustness}") # CLEVER Score (certified lower bound on robustness) clever_score = clever_u( classifier=classifier, x=x_test[0:1], nb_batches=100, batch_size=100, radius=0.3, norm=2 ) print(f"CLEVER score: {clever_score}")
pythonfrom art.defences.preprocessor import ( FeatureSqueezing, JpegCompression, SpatialSmoothing ) from art.defences.trainer import AdversarialTrainer # Adversarial Training attack_for_training = ProjectedGradientDescent( classifier, eps=0.3, eps_step=0.05, max_iter=10 ) trainer = AdversarialTrainer(classifier, attacks=attack_for_training) trainer.fit(x_train, y_train, nb_epochs=10) # Input Preprocessing Defenses feature_squeeze = FeatureSqueezing(clip_values=(0, 1), bit_depth=8) jpeg_compress = JpegCompression(clip_values=(0, 1), quality=75) spatial_smooth = SpatialSmoothing(clip_values=(0, 1), window_size=3) # Apply defenses x_defended = feature_squeeze(x_test)[0] x_defended = jpeg_compress(x_defended)[0]
pythonimport foolbox as fb import torch # Wrap model with Foolbox fmodel = fb.PyTorchModel(model, bounds=(0, 1)) # Run multiple attacks attacks = [ fb.attacks.FGSM(), fb.attacks.PGD(), fb.attacks.DeepFoolAttack(), fb.attacks.CarliniWagnerL2Attack(), ] epsilons = [0.01, 0.03, 0.1, 0.3] for attack in attacks: raw, clipped, is_adv = attack(fmodel, images, labels, epsilons=epsilons) success_rate = is_adv.float().mean(axis=-1) print(f"{attack.__class__.__name__}: {success_rate}")
yamlevasion_attacks: white_box: - FGSM (Fast Gradient Sign Method) - PGD (Projected Gradient Descent) - C&W (Carlini & Wagner) - DeepFool - AutoAttack black_box: - Square Attack - HopSkipJump - Boundary Attack - SimBA - Transfer Attacks physical_world: - Adversarial Patches - Adversarial T-shirts - 3D Adversarial Objects
yamlprivacy_attacks: membership_inference: - Shadow model attacks - Label-only attacks - Metric-based attacks model_inversion: - Gradient-based reconstruction - GAN-based reconstruction attribute_inference: - Infer sensitive attributes from model behavior
This skill can leverage the following tools:
| Tool | Description | URL | |------|-------------|-----| | Adversarial-Spec | Multi-model security threat modeling | https://github.com/zscole/adversarial-spec | | ART Framework | IBM Adversarial Robustness Toolbox | https://github.com/Trusted-AI/adversarial-robustness-toolbox | | Foolbox | Python toolbox for adversarial attacks | https://github.com/bethgelab/foolbox |
This skill integrates with the following processes:
ai-ml-security-research.js - AI/ML security research workflowssupply-chain-security.js - ML model supply chain verificationWhen executing operations, provide structured output:
json{ "attack_type": "evasion", "attack_name": "PGD", "target_model": "ResNet50", "dataset": "ImageNet", "parameters": { "epsilon": 0.03, "eps_step": 0.005, "max_iter": 100 }, "results": { "clean_accuracy": 0.92, "adversarial_accuracy": 0.15, "attack_success_rate": 0.84, "average_perturbation_l2": 1.23, "average_perturbation_linf": 0.03 }, "samples_generated": 1000, "adversarial_examples_path": "./adversarial/pgd_eps0.03/", "recommendations": [ "Consider adversarial training with PGD", "Add input preprocessing defense", "Implement certified defenses for critical applications" ] }
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 40,898 | 26,754 | -35% | 1 | 1 | 0% | 4,910 | 6,486 | +32% | 0 | 0 | — |
case-02 | fail→fail | 21,852 | 30,849 | +41% | 1 | 1 | 0% | 1,934 | 6,876 | +256% | 0 | 0 | — |
case-03 | fail→pass | 16,495 | 16,332 | -1% | 1 | 1 | 0% | 3,458 | 7,019 | +103% | 0 | 0 | — |
case-04 | fail→pass | 19,429 | 16,111 | -17% | 1 | 1 | 0% | 2,537 | 5,504 | +117% | 0 | 0 | — |
case-05 | fail→fail | 6,183 | 13,885 | +125% | 1 | 1 | 0% | 1,065 | 5,019 | +371% | 0 | 0 | — |
case-06 | fail→pass | 19,515 | 23,386 | +20% | 1 | 1 | 0% | 3,985 | 6,210 | +56% | 0 | 0 | — |
case-07 | fail→pass | 31,521 | 25,172 | -20% | 1 | 1 | 0% | 4,251 | 6,301 | +48% | 0 | 0 | — |
case-08 | fail→pass | 44,777 | 14,545 | -68% | 1 | 1 | 0% | 788 | 6,329 | +703% | 0 | 0 | — |
case-09 | fail→pass | 31,412 | 21,993 | -30% | 1 | 1 | 0% | 3,333 | 5,624 | +69% | 0 | 0 | — |
case-10 | fail→pass | 24,444 | 20,799 | -15% | 1 | 1 | 0% | 3,976 | 7,469 | +88% | 0 | 0 | — |
case-11 | fail→pass | 12,422 | 15,445 | +24% | 1 | 1 | 0% | 2,444 | 6,733 | +175% | 0 | 0 | — |
case-12 | fail→pass | 27,186 | 12,942 | -52% | 1 | 1 | 0% | 4,406 | 5,917 | +34% | 0 | 0 | — |
case-13 | fail→fail | 14,104 | 14,614 | +4% | 1 | 1 | 0% | 2,777 | 5,241 | +89% | 0 | 0 | — |
case-14 | pass→pass | 15,805 | 14,861 | -6% | 1 | 1 | 0% | 2,031 | 6,374 | +214% | 0 | 0 | — |
case-15 | fail→pass | 24,734 | 21,056 | -15% | 1 | 1 | 0% | 4,132 | 6,779 | +64% | 0 | 0 | — |
case-16 | fail→fail | 30,025 | 18,956 | -37% | 1 | 1 | 0% | 5,161 | 7,317 | +42% | 0 | 0 | — |
case-17 | pass→pass | 13,984 | 17,102 | +22% | 1 | 1 | 0% | 1,878 | 5,801 | +209% | 0 | 0 | — |
case-18 | fail→fail | 14,773 | 20,206 | +37% | 1 | 1 | 0% | 2,747 | 5,827 | +112% | 0 | 0 | — |
case-19 | pass→pass | 14,639 | 6,708 | -54% | 1 | 1 | 0% | 1,839 | 4,660 | +153% | 0 | 0 | — |
case-20 | pass→pass | 14,090 | 11,685 | -17% | 1 | 1 | 0% | 2,841 | 5,747 | +102% | 0 | 0 | — |
case-21 | pass→pass | 18,566 | 12,250 | -34% | 1 | 1 | 0% | 2,828 | 4,809 | +70% | 0 | 0 | — |
case-22 | pass→pass | 17,540 | 10,168 | -42% | 1 | 1 | 0% | 2,328 | 5,272 | +126% | 0 | 0 | — |
case-23 | pass→pass | 21,475 | 14,997 | -30% | 1 | 1 | 0% | 3,590 | 5,578 | +55% | 0 | 0 | — |
case-24 | pass→pass | 17,461 | 12,285 | -30% | 1 | 1 | 0% | 2,799 | 5,759 | +106% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 24 cases were attempted, and 23 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +42 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.