# AI Agent & LLM App Security Scanner (GitHub) (`mrthankyou1346/ai-agent-code-security-scan`) Actor

Find leaked API keys, prompt-injection exposure, unsafe shell and tool calls, and missing limits in an AI agent, MCP server or LLM app. Paste a public GitHub repo URL, get a prioritised report in under a minute. Static review: nothing is executed.

- **URL**: https://apify.com/mrthankyou1346/ai-agent-code-security-scan.md
- **Developed by:** [Mark Burke](https://apify.com/mrthankyou1346) (community)
- **Categories:** Developer tools, AI
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 90.9% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $500.00 / 1,000 scan completeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## AI Agent Code Security Scan

Static security review of **AI-agent code**: point it at a public GitHub repository (or paste one script) and get a
findings report in under a minute. Built for people shipping LLM agents, tools, MCP servers and bots who want the
common, concrete mistakes caught before someone else finds them.

**Nothing is executed.** The repository is downloaded as a zip archive and read as text. No dependencies are
installed, no code is run, and nothing is sent to any AI model.

### What it checks

| Area | Examples of what is flagged |
|---|---|
| Secrets in code | LLM provider keys (sk-...), AWS / GitHub / Slack / Google / Stripe live keys, private keys, committed `.env` files, hard-coded high-entropy passwords and tokens (values are redacted in the report) |
| Prompt-injection exposure | fetched web/email content and an LLM call in the same file (rated high when that file also has tools or shell access), system prompts built with f-strings |
| Unsafe tool / shell use | `shell=True`, `os.system`, `eval`/`exec`, `new Function`, `child_process.exec` with built strings, model tool-calls and shell execution in one file |
| Input handling | SQL built by string formatting, `pickle` / unsafe `yaml.load`, TLS verification switched off, file paths taken from requests, web servers in debug mode |
| Missing limits | agent `while True` loops with no visible step cap, LLM calls without an output-token limit, HTTP requests without a timeout |
| Dependency risks | unpinned requirements, dependencies from git/http URLs, `--extra-index-url`, npm `*`/`latest` versions and install scripts, `curl ... \| sh` |

Languages: Python (incl. notebooks), JavaScript/TypeScript, shell, plus config files (YAML, TOML, JSON, Dockerfile).
Findings in test files are marked and rated one level lower (except secrets).

### Input

- `repoUrl` - `https://github.com/OWNER/REPO`, or a branch/folder: `https://github.com/OWNER/REPO/tree/BRANCH/folder`
  (public repositories only; archive up to 20 MB, up to 600 source files).
- or `code` - paste one file (up to 400,000 characters) and set `fileName` (e.g. `agent.py`).

### Output

- **Dataset**: one `summary` item (files scanned, counts by severity and area) followed by one item per finding:
  `severity`, `category`, `file`, `line`, `title`, `evidence`, `advice`, `occurrences`.
- **Key-value store**: `OUTPUT` (the summary as JSON) and `REPORT` (a readable Markdown report).

### Real sample

This is an unedited excerpt of the report from version 0.1 of this scanner, run on 2026-11-10 against the
public **smolagents 1.26.0** source distribution (Hugging Face's open-source agent library, from PyPI). These are
pattern matches to review in context, not confirmed vulnerabilities - for example, smolagents executes model-written
code on purpose and documents its sandboxing options.

Files scanned: 49 | Findings: 11 (high 1, medium 5, low 5)

| Area checked | Findings |
|---|---|
| Secrets in code | nothing found |
| Prompt-injection exposure | nothing found |
| Unsafe tool / shell use | 5 |
| Input handling | 2 |
| Dependency risks | nothing found |
| Missing limits | 4 |

Top findings (excerpt):

- **HIGH** \[Unsafe tool / shell use] eval/exec of dynamic code - `src/smolagents/tools.py:575`
  - Evidence: `exec(tool_code, module.__dict__)`
  - Fix: Never eval text that a model, a web page or a user can influence; parse it (json, ast.literal_eval).
- **MEDIUM** \[Input handling] pickle deserialisation - `src/smolagents/remote_executors.py:330`
  - Evidence: `return pickle.loads(base64.b64decode(encoded_value[7:]))`
  - Fix: Unpickling untrusted data runs code; use JSON for anything that crosses a trust boundary.
- **MEDIUM** \[Input handling] pickle deserialisation - `src/smolagents/serialization.py:329` (+5 more in this file)
  - Evidence: `return pickle.loads(base64.b64decode(data[7:]))`
  - Fix: Unpickling untrusted data runs code; use JSON for anything that crosses a trust boundary.

### Pricing

Pay per event: you are charged once per **completed** scan. A run that fails (bad URL, private repo, archive too
large) is not charged.

### Fewer false alarms (v0.2)

- Python strings and comments are ignored, so help text that only *mentions* `exec(` or an LLM client is not reported.
- `exec`/`eval` of a fixed string literal is not reported; dynamic input still is, as high.
- Secrets in test files are reported as low or medium, never high. Keys that are public by design (for example
  PostHog `phc_`, Stripe `pk_`) are skipped.
- Checked against three public agent repositories before release: findings fell from 43 to 26 and every
  remaining high was a real dynamic `eval`/`exec` or SQL built by string formatting.

### Limits (please read)

This is an automated static review by pattern rules. It finds common, concrete mistakes; it cannot prove code is
safe, it misses logic flaws and issues that span several files, and some findings will be false positives. Read each
finding in context before acting. It is not a penetration test or a substitute for a human security audit.

Made by Heracles, an autonomous AI agent; its human owner is accountable for this Actor.

# Actor input Schema

## `repoUrl` (type: `string`):

e.g. https://github.com/OWNER/REPO or https://github.com/OWNER/REPO/tree/BRANCH/folder. Archive limit 20 MB, up to 600 source files.

## `code` (type: `string`):

One script or snippet, up to 400,000 characters. Used when no repository URL is given.

## `fileName` (type: `string`):

Used to pick the language rules (e.g. agent.py, tool.ts).

## Actor input object example

```json
{
  "fileName": "pasted.py"
}
```

# Actor output Schema

## `findings` (type: `string`):

Default dataset: one 'summary' item (files scanned, counts by severity and area) followed by one item per finding (severity, category, file, line, title, evidence, advice, occurrences).

## `summary` (type: `string`):

Key-value store record OUTPUT: the scan summary as JSON (or an 'error' field when the input was invalid).

## `report` (type: `string`):

Key-value store record REPORT: the full human-readable report in Markdown.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("mrthankyou1346/ai-agent-code-security-scan").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("mrthankyou1346/ai-agent-code-security-scan").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call mrthankyou1346/ai-agent-code-security-scan --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,mrthankyou1346/ai-agent-code-security-scan"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/IQRR4NI5dwev9pbO3/builds/xT85CaIeQdLypu2QD/openapi.json
