SSZcreate/Pentab_server / .agents/skills/cybersecurity/skills/implementing-api-key-security-controls
implementing-api-key-security-controls
VerifiedImplements secure API key generation with sufficient entropy, server-side hashing (SHA-256/bcrypt) instead of plaintext storage, per-key scoping to endpoints/IPs/rate limits, zero-downtime rotation, and automated leak monitoring across GitHub repos, logs, and client-side code. Use when designing API key formats, building key rotation or revocation workflows, or protecting server-to-server API credentials from leakage, brute force, and abuse.
| File | Kind | Size |
|---|---|---|
| LICENSE | other | 11.0 KB |
| SKILL.md | skill md | 15.4 KB |
| references/api-reference.md | markdown | 1.3 KB |
| scripts/agent.py | script | 5.9 KB |
references/api-reference.md
View on GitHub# API Reference: Implementing API Key Security Controls
## Secure Key Generation
```python
import secrets, hashlib
key = f"sk_{secrets.token_hex(32)}"
key_hash = hashlib.sha256(key.encode()).hexdigest() # Store hash only
```
## Leaked Key Patterns
| Pattern | Service |
|---------|---------|
| `sk_live_[a-zA-Z0-9]{24,}` | Stripe |
| `AKIA[0-9A-Z]{16}` | AWS |
| `AIza[0-9A-Za-z_-]{35}` | Google |
| `ghp_[a-zA-Z0-9]{36}` | GitHub PAT |
| `sk-[a-zA-Z0-9]{48}` | OpenAI |
## Key Rotation Policy
| Criteria | Threshold | Severity |
|----------|-----------|----------|
| Key age > 90 days | Rotation required | HIGH |
| Unused > 30 days | Revocation candidate | MEDIUM |
| Wildcard scope | Scope reduction needed | HIGH |
| Shared across IPs | Possible leak | HIGH |
## TruffleHog Scanning
```bash
trufflehog filesystem --directory /path/to/code --json
trufflehog git https://github.com/org/repo --json
```
## GitHub Secret Scanning API
```bash
curl -H "Authorization: token $TOKEN" \
https://api.github.com/repos/OWNER/REPO/secret-scanning/alerts
```
### References
- GitHub Secret Scanning: https://docs.github.com/en/code-security/secret-scanning
- TruffleHog: https://github.com/trufflesecurity/trufflehog
- OWASP API Key Management: https://cheatsheetseries.owasp.org/cheatsheets/API_Security_Cheat_Sheet.html
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 465k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 465k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 465k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |