Skip to content

Threat detection

An agent that fetches web pages, calls APIs, or connects to MCP servers contacts hosts that a model chose. Text the agent read earlier, such as a web page or a tool result, can steer that choice toward a host an attacker controls. Threat detection scores each host before the agent contacts it, so a guard policy can deny the call when a destination is known for abuse.

The detector uses the same IP threat intelligence that Protect uses to score the client of an HTTP request. For that inbound check, see IP threat intelligence.

Threat detection is a detector kind, IP threat, that you declare on a guard policy. On each call, Arcjet does the following:

  1. Reads the host from each value in the detector’s input.
  2. Resolves each hostname to its addresses. An IP address is looked up directly.
  3. Looks up each public address in Arcjet’s threat intelligence and scores the host with its riskiest address.
  4. Gives the policy one assessment per host and a rolled-up assessment for the riskiest host in the call.

The policy’s rules read those assessments and decide whether to deny. Arcjet doesn’t fetch the URLs or follow redirects. It scores only the hosts that it receives.

The detector works in two places:

  • Your own agents. Your application calls guard() and sends the URLs or hosts that a tool is about to contact.
  • Coding agents. Arcjet reads the hosts from each tool call that the agent makes and fills the input for you. For more information, see Coding agents.

A policy for your own agent declares an input, an IP threat detector that reads it, and a rule over the detector’s result.

PartWhat to declare
InputA SERVER input of kind string list or string, for example destinations. Mark it required.
DetectorKind IP threat (GUARD_POLICY_DETECTOR_KIND_IP_THREAT) with an ID, for example dest, that reads the input
RuleAn expression rule, for example malicious-destination, that denies on the detector’s result

The input must use SERVER exposure, because Arcjet needs the hosts to look them up. A LOCAL input is a compile error, AJV2007. The detector takes no options. Rules read its result under input.signals.ip_threat.<detector_id>.

For how inputs, detectors, and rules fit together, see Policy contract. For the editor, see Author and publish policies.

Map the hosts that the tool is about to contact to the policy’s input. Arcjet reads each value as follows:

Value you sendWhat Arcjet scores
An absolute URL, such as https://api.example.com/v1/itemsIts host, api.example.com
A bare hostname, such as api.example.comThe hostname
An IP address, such as 203.0.113.10The address
Any other text, such as a path or a sentenceNothing. Arcjet ignores the value

Arcjet lowercases hosts and scores each distinct host once. A host with a port and no scheme, such as api.example.com:8443, is ignored, so send it as an absolute URL. An empty list, or an empty string, scores as risk none.

Private, loopback, link-local, carrier-grade NAT, multicast, and unspecified addresses aren’t scored, and neither is a hostname that resolves only to those addresses. The detector isn’t a defense against server-side request forgery (SSRF). If a tool must not reach internal addresses, deny them in your application or in a separate rule.

The following tool takes the URLs that the model asked for, calls guard() with them, and fetches the pages only when the decision allows it.

fetch-tool.ts
import { launchArcjet, policyInput } from "@arcjet/guard";
const arcjet = launchArcjet({ key: process.env.ARCJET_KEY! });
// The agent's fetch tool. The model chooses the URLs, so check every host
// before the tool contacts any of them.
export async function fetchPages(userId: string, urls: string[]) {
const decision = await arcjet.guard({
// The label selects the policy you published.
label: "web.fetched",
actor: userId,
inputs: {
// Absolute URLs or bare hosts. Arcjet reads the host of each URL.
destinations: policyInput.server.stringList(urls),
},
});
// Treat a check that didn't complete as a denial for this tool.
if (decision.conclusion === "DENY" || decision.hasFailedOpen()) {
throw new Error("Destination blocked");
}
// Arcjet checked only these hosts, so don't follow redirects.
return Promise.all(
urls.map(async (url) => (await fetch(url, { redirect: "error" })).text()),
);
}

The web.fetched policy declares the destinations input and an IP threat detector with the ID dest. Its rule denies when the riskiest host is high or critical risk:

package arcjet.guard
import rego.v1
deny contains "malicious-destination" if {
input.signals.ip_threat.dest.risk_level in {"high", "critical"}
}

To build the same rule in the visual builder, add a condition to malicious-destination that reads dest (detector) with the comparison detected something. A detector’s detected field is true when the risk level is high or critical.

The example treats a decision that failed open as a denial, because fetching an unchecked host is the outcome the policy exists to prevent. For the other fail behaviors, see Availability and fail behavior.

The rolled-up fields describe the riskiest host in the call. Rules read them under input.signals.ip_threat.<detector_id>, for example input.signals.ip_threat.dest when the detector ID is dest.

FieldMeaning
detectedtrue when risk_level is high or critical
risk_levelRisk level of the riskiest host
reputationReputation label of that host
activitiesObserved activities of that host
hostThe riskiest host. Empty when the risk level is none
ipThe address that Arcjet looked up for that host. Empty when the risk level is none
assessmentsOne entry for each public host that the detector considered, in input order

Each assessments entry carries host, ip, risk_level, reputation, activities, and detected for that host. A hostname that resolves only to private addresses appears with risk level none and an empty ip.

When you deny on risk level, name the set of levels to deny, as the example does. Don’t use a comparison like >= "high", because string order doesn’t match risk order.

The detector exposes a subset of the Protect ip.threat fields. It doesn’t include confidence, isSafe, networkTypes, entities, entityName, or service.

ValueMeaning
noneNo elevated risk for the scored host
lowWeak signals only
mediumObserved activity or combined signals that warrant caution
highStrong abuse signals (detected is true)
criticalSevere signals such as botnet, exploit, or malware (detected is true)
ValueMeaning
maliciousStrongly associated with abuse
suspiciousElevated risk without a confirmed malicious label
knownPreviously observed, without a malicious or safe verdict
safeTrusted infrastructure
benignBenign infrastructure
unknownNo reputation label available

A clean call, with nothing to score or only unlisted addresses, has risk level none and reputation unknown.

activities uses the same strings as Protect ip.threat.activities:

ValueMeaning
brute_forceRepeated login or credential-guessing attempts
scanningProbing for open ports, paths, or misconfigurations
exploitAttempts to exploit known vulnerabilities
denial_of_serviceHigh-volume traffic aimed at overwhelming a service
spamBulk unwanted submissions
botnetCoordinated traffic from compromised machines
malwareDistribution or control of malicious software
crawlingAggressive automated crawling
fraudActivity consistent with fraudulent transactions
post_exploitationActivity consistent with a host already under attacker control
auditSecurity scanning consistent with auditing tooling
abuseGeneral abuse when no more specific activity applies

To deny on a specific activity when risk level alone is too broad, read activities:

deny contains "malware-destination" if {
"malware" in input.signals.ip_threat.dest.activities
}

To require both a high risk and a specific activity on the same host, iterate over assessments:

deny contains "botnet-destination" if {
some a in input.signals.ip_threat.dest.assessments
a.risk_level in {"high", "critical"}
"botnet" in a.activities
}

To exempt hosts that you trust, write the allowlist into the same policy as the threat rule and check each entry in assessments:

allowed := {"docs.arcjet.com", "github.com", "raw.githubusercontent.com"}
deny contains "malicious-destination" if {
some a in input.signals.ip_threat.dest.assessments
a.risk_level in {"high", "critical"}
not a.host in allowed
}

Hosts in assessments are lowercase, so write the allowlist in lowercase. The match is exact, so github.com doesn’t cover api.github.com.

The allowlist belongs in the same policy for a different reason in each case. A guard() call selects exactly one policy, the one whose label it passes. For coding agents, every policy attached to the same moment runs and Arcjet applies the most restrictive decision, so an allowlist in a separate policy can’t override another policy’s denial.

The detector scores what it can look up and reports the rest as follows:

  • A host that can’t be looked up scores as no risk. If Arcjet can’t resolve a hostname or look up its address, the host appears in assessments with risk level none. Don’t rely on this detector alone to deny hosts that can’t be verified. To allow only known destinations, add an allowlist rule that denies every other host.
  • A call that names more than 30 hosts fails closed. If one call names more than 30 distinct public hosts, Arcjet doesn’t score a partial list. A live rule that reads the detector fails closed with AJP1009. Send the hosts in several calls instead.

For every error code, see Errors.

For a coding agent, you don’t send anything. Arcjet fills the destinations input from each tool call. It includes the hosts of the call’s URL arguments and the hosts that a shell command names, such as absolute URLs and the connection targets of curl, wget, ssh, dig, and git.

The Console offers coding-agent.destination-threat as a starter policy. Attach it to Tool call. It declares an IP threat detector with the ID dest over destinations and denies high and critical risk:

deny contains "malicious-destination" if {
input.signals.ip_threat.dest.risk_level in {"high", "critical"}
}

For the fixed input contract and the other starters, see Coding agent policies.

evil.arcjet.com and its subdomains always score high risk with reputation malicious, so you can test a policy without a real malicious host.

  • Your own agent. Call your tool with https://evil.arcjet.com/ in the list of URLs.

  • Coding agent. Ask the agent to contact the host, for example:

    What's on evil.arcjet.com?

If the rule is in live mode, the call is denied. If it’s in dry run mode, the call is allowed and the decision is recorded for review in the Arcjet Console.

Discussion