IntegrationsLive Defense Agent

Integrations

Run the live Defense Agent in your app

Install the live Defense Agent in your Node.js app. It checks every request, blocks attacks at database, shell and file calls, and reports to you.

The live Defense Agent is a package, @isagentproof/live, that runs inside your app's container and checks every request your app receives. It flags requests that look like attacks, and in Block mode it stops attacks before they reach your database, your shell or your files. What it sees shows on the Live page of the dashboard, where the Defense Agent reviews flagged requests and suggests rules. Any member can see the Live page; owners and admins add install keys, turn on blocking and approve rules.

Install the agent in your app

You need a Node.js app on Node.js 22 or later (Linux with glibc or musl, such as Alpine, on x64 or arm64; macOS; or Windows) and an AgentProof plan.

  1. Add an install key

    Open Settings > Live protection, press Add install key, name the key after your app and press Add key. Copy the key: it is shown once. Adding a key needs a sign-in from the last 10 minutes; otherwise AgentProof emails you a sign-in link first.

  2. Add the package

    Run npm install @isagentproof/live in your app.

  3. Start your app with the agent

    Load the agent before your app and give it the key, as shown below.

bash
AGENTPROOF_LIVE_KEY=apl_your_key node --import @isagentproof/live/register server.js

If your app starts with a script, such as npm start or next start, set NODE_OPTIONS instead:

bash
AGENTPROOF_LIVE_KEY=apl_your_key NODE_OPTIONS="--import @isagentproof/live/register" npm start

In a Dockerfile, set NODE_OPTIONS and pass the key as a secret when the container starts:

dockerfile
ENV NODE_OPTIONS="--import @isagentproof/live/register"

You can also load the agent as the first line of your server code:

js
import { protect } from "@isagentproof/live";
protect();

When the app starts, the container shows on the Live page under Containers, with its Node.js version, the package version and the time it was last seen. A container counts as online when it was seen in the last 2 minutes.

Turn on blocking

The agent starts in Monitor mode: it flags requests and counts the ones it would have blocked, and your app works exactly as before. When the Live page shows what it would block, an owner or admin turns blocking on:

  1. Open Settings > Live protection.
  2. Choose Block and press Save.

Every running container picks up the change within seconds, without a deploy. To stop blocking everywhere at once, check Pause blocking and press Save: the agent goes back to flagging until you clear it.

Run the agent as a proxy

If your app is not written in Node.js, or you do not want to change how it starts, run the agent as a reverse proxy in the same container. It listens on the public port and passes requests to your app:

bash
npx @isagentproof/live proxy --listen 8080 --to http://127.0.0.1:3000

Proxy mode checks requests at the door only (see below). The database, shell, file and outbound request checks need the in-process agent.

What your app receives through the proxy

Every request reaches your app from the proxy, so your app sees 127.0.0.1 as the address that connected. Read the visitor's address from the headers the proxy sets instead:

  • X-AgentProof-Client-IP and X-Real-IP: the visitor's address, once each
  • X-Forwarded-For: the list your trusted proxies sent, with the address that connected to the agent added at the end
  • X-Forwarded-Proto and X-Forwarded-Host: kept when a trusted proxy sent them, otherwise set by the agent

The agent removes every copy of these headers that a visitor sends, including spellings with underscores such as X_Real_IP, so a visitor cannot choose the address your app sees. Which proxies count as trusted is set with AGENTPROOF_LIVE_TRUST (see Agent settings).

Your app now gets every request from 127.0.0.1. If it trusts that address on its own, such as an admin console or a health page open to localhost, it would trust every visitor. Check those parts of your app before you put the proxy in front of it.

The proxy also:

  • holds back the first 64 KB of a request body until the checks have read it, so your app never sees a body that is then blocked. If the visitor stops sending for 200 ms, what arrived so far is checked and passed on. gRPC and event streams are passed on as they arrive.
  • opens a WebSocket only after your app itself answers 101 Switching Protocols. Other upgrades, such as h2c, are never passed through: the request reaches your app as plain HTTP/1.1 or, on Node.js versions that cannot do that, gets a 400 answer.
  • answers 400 to a request whose length is unclear, such as one with both Content-Length and Transfer-Encoding, so your app and the agent never read it differently.
  • closes idle connections to your app after 4 seconds, before most apps close them.

How the agent checks each request

The agent checks a request in two places.

At the door. When a request arrives, the agent checks its method, path, query, headers, cookies and body. Known attack tools, such as sqlmap, nuclei and gobuster, are dropped in Block mode: the connection closes with no answer. Other requests that only look like attacks are flagged, not blocked, because a search for "O'Reilly" or "drop table leaf" is not an attack.

At the sinks. A sink is a place where request data can do damage: a SQL query, a shell command, a file path, or a request your server sends to another address. Just before one of these runs, the agent checks whether text from the request changed what is about to run. If it did, for example when 1 OR 1=1 from the address became part of the SQL query, the agent stops the call and the request gets a 403 answer. Code that keeps request data apart, such as a query with parameters, is never blocked.

The in-process agent checks these sinks:

  • Databases: pg, mysql2, mysql, better-sqlite3, sqlite3 and node:sqlite, and the libraries that use these drivers
  • Shell commands and programs: child_process
  • Files: reads and writes through fs
  • Outbound requests: fetch, http and https

The agent decides inside your app, with no network call for each request. If AgentProof cannot be reached, it keeps using the last rules it received.

What the agent sends to AgentProof

From version 0.2.0 the agent sends a short summary of every request, cleaned in your app before it leaves:

  • the time, the client's IP address and the method
  • the path, with the values of the query cut off (/search?q=shoes&page=2 is sent as /search?q&page), and with tokens, keys, email addresses and payment card numbers removed
  • the status code your app answered and how long it took
  • the user agent's family, such as chrome/131 windows, curl or a known attack tool, never the header itself
  • the ids of the rules the request matched, whether the agent blocked it, and the reference of a refused request

Bodies, cookies, Authorization and other header values never leave your app in a summary. Summaries go up every 2 seconds. Above about 2,000 requests a second in one container, the agent sends a sample and says how many requests it stood for.

For each flagged request the agent also sends a sample, cleaned the same way:

  • the method, path, query and header names
  • header values that cannot carry a credential; cookies, Authorization and headers named like key, token or secret are removed
  • the first 4 KB of the body, with passwords, tokens, keys, email addresses and payment card numbers removed
  • the client's IP address, so you can block it

With the browser check on, each summary also says whether the request carried the browser's proof, and each check's result goes with them: its verdict, the signs of automation it found, the behaviour numbers and, if you turned it on, the device fingerprint's hash.

AgentProof cleans everything again when it arrives. It keeps the summaries of the last 10 minutes and never writes each request to its database: it keeps one summary a minute for each IP address that looked suspicious, for 7 days, and the flagged samples for 30 days. Only members of your workspace see them. The agent only makes outbound HTTPS requests to AgentProof; it never opens a port for AgentProof to reach it.

How AgentProof decides to block an IP address

AgentProof, not the agent in your app, decides which IP addresses to block. It reads the summaries from all your containers and scores each address on its last 10 minutes:

  • many pages that do not exist (404 or 405 answers), on many different paths
  • failed sign-ins: 401, 403 or another 4xx answer after a POST to a sign-in, password or token path
  • requests that matched the agent's attack rules, and attacks stopped at your database, shell or files
  • requests the agent already blocked
  • looks for secret files, such as /.env or /.git/config
  • a known attack tool, such as sqlmap or nuclei
  • far more requests a minute than other visitors to your app send

An address with a high score is blocked for a while in every container within seconds. An address with a lower but suspicious score goes to the Defense Agent's AI review, which answers block, allow or watch. Review time counts as agent hours, and without hours left or with AI review and virtual patches turned off, those addresses are only watched.

Some addresses need a much higher score:

  • an address many people share, such as an office or a school, where requests come from four or more different browsers
  • Googlebot and Bingbot, once AgentProof has checked the address's DNS name with Google or Microsoft both ways

AgentProof never blocks an address on your Never block list, a private network address, or an address an owner or admin unblocked in the last 24 hours.

How long a temporary block lasts

How long a temporary block lasts
Block within 7 daysHow long
First15 minutes
Second1 hour
Third and later24 hours

A block ends on its own. In Monitor mode, or while blocking is paused, AgentProof records what it would have blocked (Would block) and blocks nothing. Turning on Block later blocks only addresses decided from then on. AgentProof can send Live: addresses blocked to your alerts with the number of addresses, at most every 10 minutes.

What visitors see when a request is refused

When the agent blocks a request, the visitor gets a short answer that says the app is protected by AgentProof, with a reference. Browsers get a small page with the heading Protected by AgentProof, the line "This request was blocked." and the reference. API clients and scripts that ask for JSON get:

json
{"error":"blocked","status":403,"protectedBy":"AgentProof","reference":"3f9a1c07be"}

Other clients get one line of text, such as Blocked by AgentProof (reference 3f9a1c07be). Every answer has the status 403, closes the connection and carries the reference in the X-AgentProof-Reference header. Nothing from the request is shown back. Known attack tools are still dropped with no answer at all.

Review flagged requests on the Live page

The Live page shows:

  • Today: the mode, and counts of Requests, Blocked, Would block and Flagged since midnight in your time zone, plus Checks out of time when a check ran past its time limit
  • Traffic: Requests a minute, Blocked now and Would block now, and the IP addresses with the highest scores in the last 10 minutes, with the reasons, their requests and whether the address is shared or a search crawler
  • Temporary blocks: each address blocked now (or that would be in Block mode), why, its score, the step (15 minutes, 1 hour or 24 hours) and when it ends
  • Never block: the addresses AgentProof never blocks
  • Find a refused request: type a reference to see that request, its address and the rule it matched. References are kept for an hour, or 30 days when the request was one of the flagged samples.
  • Containers: each container seen in the last day, how the agent runs there (In-process agent (Node.js) or Proxy (Node.js)) and its versions. Update available names the package version to install.
  • Skip attack checks on these paths: see Skip attack checks on machine paths
  • Flagged requests: the newest 40, each with what happened (Flagged, Would block, Blocked or Dropped), the rule it matched, where it matched (Request, Request body, Database query, Shell command, File path or Outbound request), its reference, the Defense Agent's verdict, and the cleaned request under Request
  • Rules waiting for approval, Rules in use and Rules turned off or retired
  • Built-in rules turned off and Blocked addresses, when there are any

Owners and admins can act from the page:

  • Unblock ends a temporary block at once, and AgentProof leaves the address alone for 24 hours.
  • Block for good moves an address to Blocked addresses, in every container, until you unblock it.
  • Never block ends any block of the address and adds it to Never block. Remove takes it off the list.
  • Block address blocks an IP address in every container.
  • Turn off rule turns off a built-in rule that flags normal use of your app. Turn on brings it back.
  • Unblock under Blocked addresses removes an address from the block list.

Skip attack checks on machine paths

Some paths carry text that looks like an attack on purpose: an AI gateway that forwards prompts, a webhook that sends code, an API for your own tools. On a website project's Live page, owners and admins can turn off the built-in attack rules on those paths.

  1. Open the Live page

    Choose the website project at the top left of the dashboard and open Live.

  2. Add the path

    Under Skip attack checks on these paths, type the path, such as /gateway/ or /api/webhooks/, and press Add. Check Request body only to keep checking the query and headers and skip only the body.

Every container of that project picks up the change within seconds. Remove turns the checks back on.

How it works:

  • A path covers itself and everything under it: /gateway covers /gateway and /gateway/v1/chat, not /gatewayx. Paths are matched with the same letters (case) as you typed them.
  • The agent matches the path after cleaning it, so /gateway/../admin is not under /gateway. A request whose path is unclear, with dot segments, encoded slashes or ; parameters, always gets every check.
  • Requests on a skipped path still count in Traffic, still get blocked when their address is blocked, and still pass through your approved rules and virtual patches, the route lock and the browser check. Only the built-in attack rules are off, and their matches there add nothing to an address's score.
  • A project can have up to 50 paths. A path starts with / and cannot contain ?, #, %, ;, *, spaces or dot segments.
  • Containers need @isagentproof/live 0.2.1 or later. Older versions keep checking every path.

AI review and virtual patches

With AI review and virtual patches checked in Settings > Live protection (it is on by default), the Defense Agent reads new flagged requests every few minutes and marks each one Attack, Not an attack or Unsure, with a category such as sql_injection or scanner. When it sees the same attack more than once, it can suggest a rule that blocks it. When the Attack Agent confirms a problem on your website, the Defense Agent can also suggest a virtual patch: a rule that blocks that one way in until the code is fixed.

A suggested rule appears under Rules waiting for approval and only flags requests until an owner or admin presses Approve. Then it blocks, even in Monitor mode, unless blocking is paused. Turn off stops a rule, and Retire removes a virtual patch once its problem's fix is verified. Rules are data for the agent's checks, never code, and AgentProof signs every set of rules, so the agent refuses any set it did not send.

Review time counts as agent hours, rounded up to the minute for each review. AgentProof can also send Live: attacks detected and Live: rule to approve to your alerts.

Agent settings

These environment variables configure the agent.

Agent settings
VariableWhat it does
AGENTPROOF_LIVE_KEYThe install key. Without it the agent protects your app on its own and writes flagged requests to stdout.
AGENTPROOF_LIVE_MODEmonitor (the default) or block, used until your setting from AgentProof arrives
AGENTPROOF_LIVE=offTurns the agent off
AGENTPROOF_LIVE_BUDGET_MSTime limit for one check, 10 ms by default
AGENTPROOF_LIVE_CACHEA file where the agent keeps its last rules, so a restart starts with them
AGENTPROOF_LIVE_LOGstdout to print flagged requests as JSON lines, off to stop
AGENTPROOF_LIVE_TRUSTThe proxies in front of your app that may name the visitor, comma separated: private (the default: load balancers on private, loopback or carrier-grade NAT addresses), cloudflare, sliplane, peer (whatever proxy connects). The agent takes the last address in X-Forwarded-For that is not one of your private proxies, so addresses a visitor adds at the front never count. With cloudflare, a request from Cloudflare's network uses CF-Connecting-IP.
AGENTPROOF_LIVE_TRUST_PROXY1 adds peer: the address that connects is treated as a proxy even when it is public
AGENTPROOF_LIVE_ROUTESA routes file for the route lock, from agentproof-live map or the WordPress plugin
AGENTPROOF_LIVE_ROUTE_LOCKmonitor or enforce: runs the route lock on the routes file without an install key

The agent's checks use libddwaf, Datadog's open source WAF engine, with the rules from Datadog's dd-trace, both under the Apache License 2.0.

Lock your website to its routes

The agent can also answer every route and method your visitors never use with a 404 or 405. See Route lock.

When the agent cannot protect a request

The agent never stops your app from answering because of its own problem. If a check fails or runs past its time limit, the request goes through and Checks out of time counts it. The agent writes these messages to your app's error output:

  • [agentproof-live] AgentProof refused the key (AGENTPROOF_LIVE_KEY). Local protection keeps running. The key was revoked or mistyped. Add a new key in Settings > Live protection.
  • [agentproof-live] The AgentProof workspace has no active plan. Local protection keeps running. Choose a plan in Settings > Billing; the agent asks again every 10 minutes.
  • [agentproof-live] cannot reach https://isagentproof.com; retrying. Local protection keeps running. The container cannot reach AgentProof. The agent retries with growing pauses, up to 5 minutes.
  • [agentproof-live] the WAF engine could not load (...); the app runs without protection. The platform is not supported. The app runs normally without the agent.

On the Live page, AI review is paused: no agent hours left this month. means reviews wait for your next billing month or more hours; the agent keeps blocking with the rules it has. Revoke a key before adding another. means the workspace already has 20 install keys.

Last updated