Skip to main content

LLM defense pack

Three rule groups check code that calls an LLM: token budget, prompt leaks and rate-limit coverage. They run in every vulkro scan.

vulkro scan .
vulkro explain TOK-005

Token budget (TOK-001 to TOK-005)​

RuleCatchesSeverity
TOK-001LLM call without max_tokens (or the vendor equivalent)Medium
TOK-002System prompt over 40 KB (about 10k tokens)Medium
TOK-003tools=[...] with more than 32 entriesLow
TOK-004LLM call inside a loop with no cacheMedium
TOK-005System prompt sent in the user role instead of systemHigh

TOK-005 is the security rule: a system prompt in the user message can be pulled out with an "ignore previous instructions" request. The others are cost and denial-of-service rules.

Prompt leaks (LEAK-001 to LEAK-003)​

Follows prompt variables to output sinks in the same function.

RuleCatchesSeverity
LEAK-001Prompt returned in an error or response bodyCritical
LEAK-002Prompt written to a logHigh
LEAK-003Prompt attached to telemetry (Sentry set_extra, Datadog set_tag, OpenTelemetry set_attribute)High

LEAK-001 is the common debugging mistake: the prompt is added to a 500 response, and anyone who can trigger the error reads back the system prompt and tool definitions.

Rate limits (RATE-001 to RATE-004)​

RuleCatchesSeverity
RATE-001No limiter anywhere in the projectMedium per file; High for an anonymous route that calls a payment, LLM or SQL sink
RATE-002Rate-limit library imported but never set upHigh
RATE-003Auth route limit no stricter than other routesMedium
RATE-004Express or Fastify app with no global rateLimit middlewareMedium

Recognised limiters: flask-limiter, django-ratelimit, slowapi, express-rate-limit, @fastify/rate-limit, @nestjs/throttler, rack-attack, tollbooth, httprate.

To test which prompt-injection payloads reach each LLM call, run vulkro scan . --bruteforce-sinks --bruteforce-categories llm.

See also: Bruteforce sinks, AI-code audit