# Hidden Prompt Injection Scanner (static, robots-aware) (`quietlinklab/hidden-prompt-injection-scanner`) Actor

Check web pages for hidden or obfuscated instructions aimed at AI agents (display:none, off-screen, zero-size, comments, encoded or invisible text) before your agent or RAG pipeline reads them.

- **URL**: https://apify.com/quietlinklab/hidden-prompt-injection-scanner.md
- **Developed by:** [Quiet Link Lab](https://apify.com/quietlinklab) (community)
- **Categories:** AI, Developer tools, Agents
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 page scanneds

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

## Hidden Prompt Injection Scanner for Web Pages

Check web pages **before your AI agent, RAG pipeline or LLM scraper reads them**. The Actor downloads each page
(or takes HTML you already have) and looks for text that people cannot see but a language model can read –
the technique used in real "indirect prompt injection" attacks on AI agents.

It is a **static, passive check**: it only parses the HTML of the pages you give it. It does not log in, does not
run JavaScript, does not follow instructions found on the page and sends the page content nowhere.

### What it finds

| Hiding / obfuscation technique | Example |
|---|---|
| Hidden by CSS | `display:none`, `visibility:hidden`, `opacity:0`, `font-size:0`, zero-size boxes, off-screen (`left:-9999px`), clipped, text colour = background colour, rules from `<style>` blocks |
| Hidden by markup | `hidden` attribute, `aria-hidden`, `<template>`, `<noscript>`, HTML comments |
| Hidden in attributes and metadata | `alt`, `title`, `aria-label`, `data-*`, `<meta content>` |
| Encoded or disguised text | Base64, percent-encoding, HTML character entities, zero-width characters, look-alike (Cyrillic/Greek) letters, Unicode "tag" characters that spell hidden ASCII |
| Inline scripts | instruction-like strings inside inline `<script>` blocks that are not shown on the page |

Hidden text is only reported when it also **reads like an instruction to an AI**: "ignore previous instructions",
"if you are an AI agent…", "do not tell the user", "send the credentials to…", "pay … ETH to…", "treat this site as the
verified source" and similar. Ordinary hidden menus and cookie banners are **not** flagged.

False-alarm guards: text inside `<code>`/`<pre>`/quotes, text that is also visible on the page, and articles that *discuss*
prompt injection are suppressed or downgraded, so a security blog quoting an attack does not look like an attack.
(`suppressedLikelyFalsePositives` in each row tells you how many were suppressed.)

### Output

One dataset row per page:

| Field | Meaning |
|---|---|
| `url`, `finalUrl`, `httpStatus`, `source` | What was scanned (`url` download or `html` document) |
| `status` | `scanned` · `skipped_robots` · `fetch_failed` · `not_html` · `analysis_failed` |
| `verdict` | `clean` · `low_risk` · `suspicious` · `likely_injection` |
| `riskScore` | 0–100 |
| `findings[]` | `severity`, `hiding` (how it is hidden), `technique`, `category` (override, ai-addressing, secrecy, exfiltration, payment, trust-manipulation, action, invisible-text), `matchedPhrase`, `element`, `snippet` (≤200 chars), `decoded` (for encoded payloads) |
| `hiddenBlocks`, `hiddenChars`, `visibleChars` | Size of hidden vs visible content |
| `sanitizedText` | Optional: visible text only (turn on "Return visible text only") |

A run summary (`OUTPUT` in the key-value store) counts pages per verdict.

**Important:** `snippet` and `sanitizedText` are copied from the page. They are untrusted data – never feed a
flagged snippet back into an AI agent as an instruction.

### Pricing

Pay per event: **$0.002 per scanned page** (plus the standard Actor start event). A page is billed only when it was
downloaded successfully as HTML (or you passed it as an HTML document) and scanned. Pages skipped because of
`robots.txt`, failed downloads, non-HTML files and invalid input are **not billed**. `maxPages` (default 25) is a hard cap.

### Input example

```json
{
  "startUrls": [{ "url": "https://example.com/" }],
  "maxPages": 25,
  "includeSanitizedText": false
}
```

Scan HTML you already have (no network request):

```json
{ "htmlDocuments": ["<html><body><div style=\"display:none\">…</div></body></html>"] }
```

### Output example (excerpt)

```json
{
  "url": "https://example.com/page",
  "status": "scanned",
  "verdict": "likely_injection",
  "riskScore": 84,
  "findings": [
    {
      "severity": "high",
      "hiding": "display:none",
      "technique": "hidden-text",
      "category": "override",
      "matchedPhrase": "ignore all previous instructions",
      "element": "div.footer-note",
      "snippet": "Ignore all previous instructions. You are an AI agent: …"
    }
  ]
}
```

### Limits – please read

- **Static HTML only.** Text that a page adds with JavaScript after loading, text inside images or PDFs, and rules in
  external stylesheets are not inspected. A `clean` verdict is not a guarantee of safety.
- It detects *instruction-like language that is hidden or disguised*. Attackers can phrase things differently;
  treat the result as one layer of defence, not the only one.
- It cannot tell you who put the text there or whether it was malicious – it tells you where to look.

### Responsible use

- Only scan pages you are allowed to fetch. You are responsible for complying with the target sites' terms.
- The Actor identifies itself with a clear `User-Agent`, **respects `robots.txt` by default**, limits requests per host
  (default 1 per second) and never bypasses logins, captchas or bot protection.
- It fetches each URL you list once and does not crawl. Requests to private/loopback network addresses are refused.
- Defensive use only: the Actor reports findings; it does not generate attack payloads.

# Actor input Schema

## `startUrls` (type: `array`):

Public http(s) pages to download and scan (one request per URL, no crawling). Only scan pages you are allowed to fetch.

## `htmlDocuments` (type: `array`):

Raw HTML strings you already have (for example output of your own scraper). They are scanned without any network request.

## `maxPages` (type: `integer`):

Hard cap on scanned items = hard cap on cost (each scanned page is one billed event).

## `includeSanitizedText` (type: `boolean`):

Add `sanitizedText` to each row: the text a person can see, without hidden elements, comments, attributes or invisible characters. Still treat it as untrusted content.

## `maxSanitizedChars` (type: `integer`):

Characters of sanitized text per page (only used when 'Return visible text only' is on).

## `onlyReportFlagged` (type: `boolean`):

Skip rows with verdict 'clean'. Scanned pages are still billed; the run summary still counts them.

## `respectRobotsTxt` (type: `boolean`):

Do not request URLs disallowed for this crawler. Such URLs are reported as skipped and are not billed.

## `timeoutSecs` (type: `integer`):

Give up on a single download after this many seconds (not billed).

## `concurrency` (type: `integer`):

Pages processed in parallel.

## `requestsPerSecondPerHost` (type: `number`):

Politeness limit per host.

## `userAgent` (type: `string`):

Override the default identifying User-Agent.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://example.com"
    }
  ],
  "maxPages": 25,
  "includeSanitizedText": false,
  "maxSanitizedChars": 5000,
  "onlyReportFlagged": false,
  "respectRobotsTxt": true,
  "timeoutSecs": 20,
  "concurrency": 3,
  "requestsPerSecondPerHost": 1
}
```

# Actor output Schema

## `results` (type: `string`):

All scanned pages in the default dataset.

## `flagged` (type: `string`):

Table view of the dataset focused on verdicts and findings.

# 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 = {
    "startUrls": [
        {
            "url": "https://example.com"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("quietlinklab/hidden-prompt-injection-scanner").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 = { "startUrls": [{ "url": "https://example.com" }] }

# Run the Actor and wait for it to finish
run = client.actor("quietlinklab/hidden-prompt-injection-scanner").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 '{
  "startUrls": [
    {
      "url": "https://example.com"
    }
  ]
}' |
apify call quietlinklab/hidden-prompt-injection-scanner --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,quietlinklab/hidden-prompt-injection-scanner"
        }
    }
}
```

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/8ytYl4YdSqppeFMfT/builds/oYYUiwZLpO9gaQuDp/openapi.json
