
Security Ai Keys
- 92 installs
- 125 repo stars
- Updated February 4, 2026
- igorwarzocha/opencode-workflows
Audit code for leaked AI API keys across OpenAI, Anthropic, Gemini, and other providers, and enforce server-side redaction.
About
A security-audit skill for detecting exposed AI provider API keys and leak paths. A developer uses it to scan for client-side key exposure, unredacted logging, and to enforce key rotation.
- Detects patterns like sk- and ant- keys and client-side exposure
- Rules: keys stay server-side, redact before logging, rotate on suspicion
Security Ai Keys by the numbers
- 92 all-time installs (skills.sh)
- +3 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #1,035 of 2,203 Security skills by installs in the Skillselion catalog
- Data as of Aug 2, 2026 (Skillselion catalog sync)
npx skills add https://github.com/igorwarzocha/opencode-workflows --skill security-ai-keysAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 92 |
|---|---|
| repo stars | ★ 125 |
| Last updated | February 4, 2026 |
| Repository | igorwarzocha/opencode-workflows ↗ |
What it does
Audit code for leaked AI API keys across OpenAI, Anthropic, Gemini, and other providers, and enforce server-side redaction.
Files
<overview>
Security audit patterns for AI API key leakage in applications integrating AI providers.
</overview>
<rules>
Core Principles
- MUST treat AI API keys as secrets and keep them server-side.
- MUST NOT ship keys to browsers or mobile clients.
- SHOULD avoid logging keys; redact before logging or error reporting.
- MUST rotate keys immediately if exposure is suspected.
</rules>
<vulnerabilities>
Common Leak Paths
1) Client-Side Exposure
NEXT_PUBLIC_*/VITE_*env vars containing AI keys- Direct calls to AI provider endpoints from browser code
2) Build Artifacts
- Keys embedded in bundles (
dist/,build/,.next/) - Source maps exposing server code containing keys
3) Logs and Telemetry
console.log/ logger statements that include key values- Error tracking payloads (Sentry, Datadog) with headers included
</vulnerabilities>
<commands>
Quick Audit Commands
# Env files: AI keys accidentally exposed to client
rg -n "(NEXT_PUBLIC_|VITE_).*(OPENAI|OPENROUTER|ANTHROPIC|GEMINI|GOOGLE|VERTEX|BEDROCK|AWS|AZURE|MISTRAL|COHERE|GROQ|PERPLEXITY|TOGETHER|REPLICATE|FIREWORKS|HUGGINGFACE|HF_)" . -g "*.env*"
# Client code calling AI APIs directly (check for browser use)
rg -n "api\.openai\.com|openrouter\.ai|api\.anthropic\.com|generativelanguage\.googleapis\.com|aiplatform\.googleapis\.com|bedrock.*amazonaws\.com|api\.mistral\.ai|api\.cohere\.ai|api\.groq\.com|api\.together\.xyz|api\.perplexity\.ai|api\.replicate\.com|api\.fireworks\.ai|openai\.azure\.com" . -g "*.js" -g "*.ts" -g "*.jsx" -g "*.tsx" -g "*.vue"
# Scan build outputs for likely keys (heuristic)
rg -a "sk-[A-Za-z0-9]{20,}|sk-ant-[A-Za-z0-9-]{20,}|sk-or-[A-Za-z0-9-]{20,}|AIza[0-9A-Za-z_-]{35}|hf_[A-Za-z0-9]{20,}" dist/ build/ .next/ 2>/dev/null
# Service account credentials and cloud auth files
rg -n "\"type\"\s*:\s*\"service_account\"|GOOGLE_APPLICATION_CREDENTIALS|AWS_ACCESS_KEY_ID|AWS_SECRET_ACCESS_KEY|AZURE_OPENAI_API_KEY" . -g "*.env*" -g "*.json"</commands>
<checklist>
Hardening Checklist
- [ ] AI provider keys only in server runtime (never in browser)
- [ ]
.env.localand.env.*.localare gitignored - [ ] Logs redact or omit secrets (request headers, env values)
- [ ] Build artifacts scanned before deploy
- [ ] Keys rotated if exposure suspected
</checklist>
<scripts>
Scripts
scripts/scan.sh- First-pass AI key leakage scan
</scripts>
#!/usr/bin/env bash
# AI API Key Leakage Scanner - First-pass automated detection
# Usage: ./scan.sh [directory]
set -euo pipefail
DIR="${1:-.}"
FOUND=0
echo "=== AI API KEY LEAKAGE SCAN ==="
echo "Directory: $DIR"
echo "Timestamp: $(date -Iseconds)"
echo ""
if ! command -v rg &> /dev/null; then
echo "[ERROR] ripgrep (rg) required"
exit 1
fi
report() {
local severity="$1"
local title="$2"
local details="${3:-}"
echo "[$severity] $title"
[[ -n "$details" ]] && echo " $details"
echo ""
FOUND=$((FOUND + 1))
}
echo "=== CRITICAL: Client-Exposed Env Vars ==="
echo ""
# NEXT_PUBLIC_ / VITE_ with AI key names
if rg -q "(NEXT_PUBLIC_|VITE_).*(OPENAI|OPENROUTER|ANTHROPIC|GEMINI|GOOGLE|VERTEX|BEDROCK|AWS|AZURE|MISTRAL|COHERE|GROQ|PERPLEXITY|TOGETHER|REPLICATE|FIREWORKS|HUGGINGFACE|HF_)" "$DIR" -g "*.env*" 2>/dev/null; then
report "CRITICAL" "AI keys appear in client-exposed env vars" "Remove from NEXT_PUBLIC_/VITE_ and move to server"
fi
echo "=== HIGH: AI API Endpoints in Client Code ==="
echo ""
if rg -q "api\.openai\.com|openrouter\.ai|api\.anthropic\.com|generativelanguage\.googleapis\.com|aiplatform\.googleapis\.com|bedrock.*amazonaws\.com|api\.mistral\.ai|api\.cohere\.ai|api\.groq\.com|api\.together\.xyz|api\.perplexity\.ai|api\.replicate\.com|api\.fireworks\.ai|openai\.azure\.com" "$DIR" -g "*.js" -g "*.ts" -g "*.jsx" -g "*.tsx" -g "*.vue" 2>/dev/null; then
report "HIGH" "AI API endpoint used in client code" "Verify calls are server-side and keys are not exposed"
fi
echo "=== HIGH: Cloud AI Credentials in Repo ==="
echo ""
if rg -q "\"type\"\s*:\s*\"service_account\"|GOOGLE_APPLICATION_CREDENTIALS|AWS_ACCESS_KEY_ID|AWS_SECRET_ACCESS_KEY|AWS_SESSION_TOKEN|AZURE_OPENAI_API_KEY|AZURE_OPENAI_ENDPOINT" "$DIR" -g "*.env*" -g "*.json" 2>/dev/null; then
report "HIGH" "Cloud AI credentials found" "Verify files are not committed and rotate if exposed"
fi
echo "=== HIGH: Possible AI Keys in Repo (Heuristic) ==="
echo ""
if rg -q "sk-[A-Za-z0-9]{20,}|sk-ant-[A-Za-z0-9-]{20,}|sk-or-[A-Za-z0-9-]{20,}|AIza[0-9A-Za-z_-]{35}|hf_[A-Za-z0-9]{20,}" "$DIR" 2>/dev/null; then
report "HIGH" "Possible AI API keys detected (heuristic)" "Rotate keys immediately if real"
fi
echo "=== MEDIUM: Build Artifacts Present ==="
echo ""
if [[ -d "$DIR/dist" || -d "$DIR/build" || -d "$DIR/.next" ]]; then
report "MEDIUM" "Build artifacts found" "Scan bundles for embedded secrets"
fi
echo "=== SUMMARY ==="
if [[ $FOUND -gt 0 ]]; then
echo "[!] Found $FOUND potential issues. Review above."
exit 1
else
echo "[✓] No obvious AI key leakage issues detected"
exit 0
fi