Skip to main content

Overview

GaiterGuard evaluates every proxy request using a blended risk scoring model that combines:
  1. LLM intent analysis — evaluates whether agent’s stated intent matches the actual request
  2. HTTP method heuristics — baseline risk scores for different HTTP methods
  3. Fail-closed behavior — escalates risk on LLM failure to prevent silent bypass
Requests with score >= RISK_THRESHOLD are blocked and queued for human approval.
The default threshold is 0.5 (configurable via RISK_THRESHOLD environment variable). Scores range from 0.0 (no risk) to 1.0 (critical risk).

Risk Scoring Model

Blended Score Calculation

The final risk score is a weighted blend of LLM and heuristic components:
Rationale: LLM opinion is weighted higher (70%) because it analyzes intent mismatch and request context. Method heuristics provide a safety baseline (30%).

LLM Intent Analysis

The LLM assessor evaluates whether the agent’s stated intent matches the HTTP request:

System Prompt

The LLM receives this system prompt (risk.service.ts:33):

User Prompt

The LLM receives the following context (risk.service.ts:70):
Body is truncated to 500 characters to control token usage.

Response Format

The LLM must return JSON:
Invalid responses (missing fields, wrong types, malformed JSON) trigger fail-closed behavior.

HTTP Method Heuristics

Baseline risk scores by HTTP method (risk.service.ts:52):

Fail-Closed Behavior

If the LLM call fails (timeout, network error, invalid response), the gateway escalates the heuristic score by +0.3:
Example: POST request normally has heuristic score 0.3. On LLM failure, score becomes 0.6 (0.3 + 0.3), triggering approval if threshold is 0.5.
LLM unavailability never results in a lower risk score. This prevents silent bypass when the LLM service is down.

Threshold Configuration

The RISK_THRESHOLD determines which requests require approval:
Validation enforced at startup (backend/src/config/env.ts:41):

Threshold Tuning

Blocks: Most write operations (POST, PUT, PATCH, DELETE)Passes: Only GET/HEAD requests with clear intent matchUse case: High-security environments, financial transactions, production deployments

Intent Integrity Checking

The LLM compares the agent’s stated intent field against the actual request payload.

Example: Intent Match

LLM evaluation:

Example: Intent Mismatch

LLM evaluation:
Result: Request blocked with 428 status and queued for approval.

LLM Configuration

The risk assessor supports any OpenAI-compatible LLM API:

Supported Providers

Recommended model: gpt-4o-mini (fast, cost-effective)
Use a proxy that translates OpenAI format to Anthropic format, such as LiteLLM.
Requires OpenAI-compatible API wrapper.

Request Parameters

The LLM API call uses these parameters (risk.service.ts:114):
Temperature 0 ensures deterministic, consistent risk scores. The LLM should not introduce randomness into security decisions.

Risk Assessment Flow

Risk assessment runs after URL validation but before idempotency check (proxy.service.ts:399): Rationale: Risky requests are blocked before any expensive operations (credential decryption, API calls). This prevents resource exhaustion attacks.

Blocked Request Handling

When a request is blocked, the agent receives a 428 Precondition Required response:
The agent should:
  1. Extract the action_id
  2. Poll GET /status/:action_id every 5-10 seconds
  3. Wait for status to change from PENDING to APPROVED or DENIED
  4. If APPROVED, call POST /proxy/execute/:action_id to execute
See Approval Flow for the full state machine.

Dashboard Review Context

Humans reviewing blocked requests in the dashboard see:
  • Agent name — which agent made the request
  • Service name — target API being accessed
  • Intent — agent’s stated purpose
  • HTTP method — GET, POST, DELETE, etc.
  • Target URL — full URL with path and query params
  • Request headers — all headers except Authorization and Agent-Key (stripped)
  • Request body — full payload (truncated to 500 chars in LLM prompt, but stored in full)
  • Risk score — 0.0-1.0 final score
  • Risk explanation — LLM’s one-sentence justification
  • Timestamp — when request was blocked
This provides full context for informed approval decisions.

Tuning Risk Assessment

Scenario: Too Many False Positives

Symptom: Legitimate requests are frequently blocked Solutions:
  1. Increase RISK_THRESHOLD from 0.5 to 0.6 or 0.7
  2. Improve agent’s intent descriptions (be more specific)
  3. Review LLM model choice (some models are more conservative)

Scenario: Too Few Blocks

Symptom: Risky requests pass through without approval Solutions:
  1. Decrease RISK_THRESHOLD from 0.5 to 0.4 or 0.3
  2. Review method heuristics (consider custom weights per service)
  3. Add custom rules to LLM system prompt (see below)

Custom Risk Rules

You can extend the system prompt with service-specific rules. Modify RISK_SYSTEM_PROMPT in risk.service.ts:33:
Modifying the system prompt may affect LLM behavior unpredictably. Test thoroughly in a non-production environment first.

Logging and Monitoring

All risk assessments are logged at INFO level:
LLM failures are logged at WARN level:
Debug logging includes LLM response details:
Monitor these logs to tune threshold and identify LLM issues.

Approval Flow

Learn what happens after a request is blocked

Security Model

Understand intent integrity in the trust model

Architecture

See where risk assessment fits in the request lifecycle