# Security Audit for AI-Built Apps: Leaked Keys & AI Risks

> Finds the security holes vibe-coded and LLM apps actually ship with (leaked keys, keys in the browser bundle, model output reaching eval/shell/SQL, prompt injection, missing auth checks) and verifies each one before reporting it.

Security Audit for AI-Built Apps: Leaked Keys & AI Risks is a free AI agent skill on Agensi by Abhineet Sharma, in Security. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Abhineet Sharma](https://www.agensi.io/creators/abhineet-sharma)
- Category: [Security](https://www.agensi.io/skills/security)
- Version: 1.0
- Last updated: 2026-11-29
- Security: scan passed (2026-11-28); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/security-audit-for-ai-built-apps-leaked-keys-ai-risks
- Tags: security, code-quality-review, llm-ops

## What it does

- Finds API keys and passwords hidden in your code or git history
- Flags secrets that were accidentally sent to the user's web browser
- Identifies when AI output can trick your app into running bad commands
- Checks if user data is properly protected from other logged-in users
- Verifies every security hole with a safe test to prove it is real
- Proposes the exact code changes needed to fix confirmed bugs

## Who it's for

- **Founders of AI startups and apps:** Catch leaked keys and prompt injection holes before they cost you money. Try: "Audit my new AI chatbot repo for security risks."
- **Developers using AI to write code (vibe-coding):** Find the common security bugs that AI often introduces into your app. Try: "Check if this code is safe to make public on GitHub."
- **Small business owners with custom web tools:** Ensure your customer data isn't exposed through your API or database. Try: "Do a security review of my customer portal code."

## About this skill

AI-built apps fail security in predictable ways: an OpenAI key in a `VITE_` variable, a `.env` committed in week one, model output piped into `exec()`, a text-to-SQL endpoint with a write-capable DB user, an `/api/orders/:id` that never checks whose order it is. This skill finds those, and then verifies them, so you get a short list of real problems instead of 80 regex hits.

**The scanner** (`sec_scan.py`, stdlib only, read-only, no network)
- **Secrets**: OpenAI, Anthropic, AWS, GitHub, Stripe live, Slack, Google, Hugging Face, SendGrid, private keys, DB URLs with passwords, plus high-entropy literals assigned to secret-looking names. Committed `.env` files. **Secrets buried in git history** (`--history N`), which are still exposed even after you delete them. Values are always masked in output.
- **Keys shipped to the browser**: `NEXT_PUBLIC_` / `VITE_` / `REACT_APP_` / `EXPO_PUBLIC_` variables that look like LLM keys, service-role keys or secrets.
- **LLM-specific sinks**: model output into `eval`/`exec`, a shell, SQL, or raw HTML (`dangerouslySetInnerHTML`); user input interpolated into the system prompt.
- **Classic bugs** in Python and JS/TS: SQL via f-strings/templates, `shell=True`, `child_process.exec` with interpolation, `pickle`/`torch.load`/`yaml.load`, TLS verification off, JWT without signature checks, weak password hashing, `random`/`Math.random` for tokens, path traversal, SSRF, open redirects, debug mode, CORS `*` with credentials.
- **Config**: Dockerfiles running as root or baking secrets into layers; GitHub Actions "pwn requests" (`pull_request_target` + PR checkout), script injection via `${{ github.event.issue.title }}`, unpinned third-party actions, `write-all` tokens.
- Tells you which dependency audit to run (pip-audit, npm/pnpm audit, govulncheck, cargo audit) for your lockfiles.
- Calibrated against real code: test files are downgraded, env-var and header *names* aren't flagged as secrets, and SQL that only interpolates column names (with values parameterised) is marked low-confidence.

**The audit workflow**
1. Map the attack surface: routes, who the attacker is, where untrusted input enters (including retrieved documents and model output).
2. Scan, then a **manual checklist** for what regex can't see: IDOR / missing ownership checks, Supabase RLS and Firebase rules, admin/debug routes, unauthenticated paid-LLM endpoints (cost abuse), RAG cross-tenant leaks, agent tools without human approval, unsigned webhooks, uploads.
3. **Verify every candidate**: trace source to sink, check reachability, and add a minimal safe proof (a unit test, not an attack on production). Each finding ends up Confirmed, Likely, or Dismissed with a reason.
4. Fix: rotate leaked secrets first, then patches with regression tests, in priority order.

Free. Defensive use on your own code only.

## Requires

- Python 3.9+
- pip-audit
- uv (Python tool runner)
- Optional: Git (history and tracked-file checks)
- Optional: pip-audit / npm audit (dependency CVEs)

## Known limitations

Pattern-based scanning finds candidates, not proof: the workflow verifies them, but it can miss bugs that need deep data-flow analysis. Code rules cover Python and JS/TS; other languages get secret and config checks only. Dependency vulnerability checks need you to run the suggested audit tools (they need network). Not a penetration test, not a compliance audit, and not for systems you don't own.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Security Audit for AI-Built Apps: Leaked Keys & AI Risks skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### Will it dump my secrets into the chat?

No. The scanner masks every value (first 4 characters plus length) and the skill tells the agent never to print full secrets.

### I deleted the leaked key from the file. Am I safe?

No. It's still in git history and may already have been scraped. The fix is to rotate or revoke the key at the provider. The --history option finds keys like this.

### Won't it flood me with false positives?

The scanner is tuned against real code (test files downgraded, env-var names and header names ignored, parameterised SQL marked low-confidence), and the workflow verifies every candidate. You get Confirmed, Likely and Dismissed lists, with reasons.

### Does it handle AI agents and RAG apps?

Yes, that's the focus: model output reaching eval/shell/SQL/HTML, prompt injection via system prompts and retrieved documents, agent tool permissions, RAG tenant isolation, and cost abuse of paid model endpoints.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
