security-and-hardening
Skill2 starsChanged 6 days agoMITView on GitHub
Hardens code against vulnerabilities in Python, PyTorch, and ML research codebases. Use when auditing data loaders, model checkpoints, weight downloading scripts, configuration parsers, API integrations, or handling untrusted training data. Use when assessing supply-chain risks, malicious model weight deserialization, or verifying compliance.
- Reads credentials
107 other projects use a version of this.
Adopted by
Most recently taken up by
- dzikrisyairozi/agent-skillstheir own version, first seen Nov 29, 2026
- jaydubya818/MissionControltheir own version, first seen Nov 29, 2026
- aakash1552005/universal-agent-skillstheir own version, first seen Nov 29, 2026
- karanmrn/karanagentskillstheir own version, first seen Nov 29, 2026
- karanmrn/kstacktheir own version, first seen Nov 29, 2026
- e-landeros/gauntlettheir own version, first seen Nov 29, 2026
Used with
Projects with it also use accessibility-engineering, observability-and-instrumentation and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
steven123397Skillaccessibility-engineering
Audits existing interfaces for WCAG 2.2 AA conformance and remediates the violations found. Use when auditing a page or component for accessibility, running axe-core or pa11y, triaging a11y violations, or checking screen reader and contrast issues before shipping.
Also in 4 projects that use this
jaydubya818Skillobservability-and-instrumentation
Add or review logs, metrics, traces, and actionable alerts.
Also in 42 projects that use this
MrCipherSmithSkillconstraint-driven-development
Use when a project needs a persistent, measurable quality bar — starting a project without documented standards, 'set up constraints', or when coverage/perf/a11y thresholds get re-debated per-PR. Produces CONSTRAINTS.md with enforceable numbers, ratchets, and a guard against silent weakening. NOT for throwaway prototypes or a one-off CI setup.
Also in 21 projects that use this
jaydubya818Skilldeprecation-and-migration
Retire APIs or migrate consumers and persistent data across releases.
Also in 46 projects that use this
HK-hubSkillsource-driven-development
Grounds every implementation decision in official documentation. Use when you want authoritative, source-cited code free from outdated patterns. Use when building with any framework or library where correctness matters.
Also in 49 projects that use this
HK-hubSkillcode-simplification
Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.
Also in 57 projects that use this
Other versions107 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 107
- addyosmani/agent-skills★ 121ksame name
- penpot/penpot★ 63ksame name
- ollaya-dev/ollaya★ 1.5ksame name
- shashankswe2020-ux/whoop-mcp★ 181same name
- enes-alatas/spool★ 49same name
- vinvcn/addyosmani-agent-skills-zh★ 46same name
- jmxt3/gitscape.ai★ 33same name
- sampleXbro/agentsmesh★ 31same name
- jaskirat1616/grok-skills★ 22same name
- ishandutta2007/Awesome-Agent-Skills★ 21same name
97 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository15 other files it gives its agents.
- research_agentAGENTS.md
- ai-checklistSkill
- anonymizationSkill
- code-reviewSkill
- competitor-analysisSkill
- conventional-commitSkill
- documentation-and-adrsSkill
- edaSkill
- github-pagesSkill
- huggingface-spaceSkill
- idea-roastSkill
- ml-experiment-launchSkill
- paper-draftingSkill
- refactorSkill
- research-notesSkill
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 4 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 103 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 42
Scan model weights: before loading them locally (pixi run -e safe scan_model <path>).
- Very specific: line 43
Scan virtual environments and dependencies: after adding packages (pixi run -e safe scan_envs).
- Very specific: line 69
Mitigation: Use safetensors format whenever possible (transformers supports use_safetensors=True).
- Very specific: line 70
Run local model weight scans: pixi run -e safe scan_model /path/to/model.
- Distinctive: line 79
Never place Hugging Face tokens, WandB API keys, or private SSH keys inside tracked files or README.md.
- Distinctive: line 83
Run environment and package scans after dependency modifications:
- Distinctive: line 92
Before signing off on a PR or model integration:
- Distinctive: line 120
After implementing security controls:
“Common” is measured: kept by at least 6 in 10 of the 103 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Security and Hardening (ML Research & Python Edition)
Overview
Security-first development practices for Machine Learning research repositories. Treat every external dataset, every downloaded model weight (.pt, .bin, .safetensors), every remote API integration, and every dependency package as a potential vector. In ML, security spans code logic, model weight integrity, supply-chain verification, and data privacy.
When to Use
- Downloading pretrained model weights or checkpoints from Hugging Face or external sources
- Building custom dataset loaders that ingest external CSVs, JSONs, audio, or image files
- Managing API keys and tokens (WandB, Hugging Face, Kaggle, GitHub)
- Integrating external services or webhooks in a research pipeline
- Auditing dependencies, lockfiles (
pixi.lock,pyproject.toml), or build scripts - Handling personal data, user annotations, or privacy compliance (GDPR/CCPA) in speech/vision datasets
Process: Threat Model First for ML
Controls bolted on without a threat model are guesses. Before hardening an ML pipeline, consider these threat vectors:
- Map the trust boundaries. Where does untrusted data cross into your system? Hugging Face model downloads, raw dataset directories, webhooks, Hugging Face Hub APIs, and untrusted command-line arguments. Model weights (
torch.load) are executable code due to Python pickle deserialization. - Name the assets. Credentials (WandB/HF API tokens), proprietary datasets, model intellectual property, and compute cluster access.
- Run STRIDE over each boundary:
- Spoofing: Can someone impersonate a dataset source or registry?
- Tampering: Can model weights or datasets be injected with poisoned samples or backdoors?
- Information disclosure: Are API tokens or private dataset samples leaked into public logs or git commits?
- Denial of service: Can malicious inputs cause infinite loops or GPU OOM crashes in data loaders?
- Elevation of privilege: Can compromised script execution break out of container boundaries?
The Three-Tier Boundary System
Always Do (No Exceptions)
- Scan model weights before loading them locally (
pixi run -e safe scan_model <path>). - Scan virtual environments and dependencies after adding packages (
pixi run -e safe scan_envs). - Parameterize and validate all inputs at data ingestion boundaries (validate dataset column schemas, audio sample rates, shape dimensions).
- Keep secrets out of version control (never commit
.env, API tokens, or SSH keys). - Use secure environment variables for all credentials.
Ask First (Requires Human Approval)
- Adding new external service integrations or APIs
- Downloading model checkpoints from unverified or non-canonical sources
- Modifying security scanner configurations or dependency rules
- Granting external access or publishing datasets containing PII/human annotations
Never Do
- Never load untrusted
.ptor.binfiles viatorch.load()without scanning (useweights_only=Trueorsafetensorswhen possible). - Never commit API tokens, secrets, or
.envfiles. - Never log sensitive data (passwords, tokens, personal identifiers in human speech/text datasets).
- Never expose internal stack traces or cluster paths in user-facing error messages.
- Never use npm or other package manager for other languages since you are working with Python package.
Hardening Controls for ML
1. Model Weight Deserialization & Supply Chain (Pickle Vulnerabilities)
- Standard PyTorch
.ptor.binfiles rely on Python'spicklemodule, which can execute arbitrary code upon deserialization. - Mitigation: Use
safetensorsformat whenever possible (transformerssupportsuse_safetensors=True). If loading.ptfiles, verify checksums and usetorch.load(..., weights_only=True)to restrict unsafe global lookups. - Run local model weight scans:
pixi run -e safe scan_model /path/to/model.
2. Dataset Ingestion & Boundary Validation
- Untrusted CSVs, JSONs, or audio files can contain path traversal attacks, malformed headers, or malformed numerical data that triggers
NaNexplosions or buffer overflows. - Mitigation: Validate all incoming dataset schemas, tensor shapes, and audio sampling rates at loading time before feeding them into training loops. Reject malformed inputs explicitly with a
ValueError.
3. Secrets Management
- Secrets must come from environment variables or secure secret managers, never hardcoded in
src/or configs. .env.exampleshould be committed with placeholders; real.envfiles must be gitignored.- Never place Hugging Face tokens, WandB API keys, or private SSH keys inside tracked files or
README.md.
4. Dependency & Environment Hardening
- Machine learning repositories pull extensive transitive dependencies (CUDA binaries, PyTorch, Hugging Face ecosystem).
- Run environment and package scans after dependency modifications:
pixi run -e safe scan_envs- Pin dependency versions strictly inside
pixi.toml/pyproject.tomlto prevent supply-chain poisoning.
Review Checklist
Before signing off on a PR or model integration:
[ ] Model weights scanned via pixi run -e safe scan_model
[ ] Virtual environment scanned via pixi run -e safe scan_envs
[ ] No secrets, API keys, or tokens present in code, configs, or git history
[ ] Dataset input loaders validate tensor shapes, dtypes, and boundary ranges
[ ] Checkpoints loaded securely (weights_only=True or safetensors)
[ ] No hardcoded paths, proxies, or GPU restrictions in tracked documentation
Common Rationalizations
| Rationalization | Reality |
| "It's just an official checkpoint from Hugging Face, no need to scan" | Even popular repositories can be targeted or compromised; scanning takes seconds and prevents arbitrary code execution. |
"PyTorch torch.load is safe because I trust the source file" | Pickle deserialization is inherently unsafe against tampering or compromised storage buckets. Use safetensors or weights_only=True. |
| "It's just a local training script, secrets don't matter" | Hardcoded tokens easily leak into shell history, error logs, or accidental public commits. |
| "Data validation slows down dataset loading" | Validating shapes and catching corrupt samples early prevents multi-hour training runs from failing halfway through due to NaN losses. |
Red Flags
- Using
torch.load()on unverified checkpoints withoutweights_only=Trueorsafetensors - Hardcoded API tokens or Hugging Face access keys in Python files or YAML configs
- Datasets loading external files without shape, schema, or type validation
- Missing lockfiles (
pixi.lock) or unpinned dependency versions - Committing
.envfiles or model weights directly into Git history
Verification
After implementing security controls:
[ ] Model weight scan passes cleanly without warnings [ ] Environment scan passes without unmitigated vulnerability flags [ ] Dataset loaders gracefully handle malformed or out-of-bound inputs [ ] All API keys and credentials successfully isolated to environment variables
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
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.

