Skip to content

Composite Attack Detection

Detects compound attacks — SQL injection and prompt injection combined in a single payload — targeting AI agents, RAG pipelines, and MCP tools.

Why Compound Attacks Are Dangerous

Traditional defenses only detect a single attack vector. Attackers exploit this gap by crafting compound payloads that slip past both WAFs and Prompt Shield simultaneously.

ToolPrompt DetectionSQL DetectionComposite Detection
Standard WAF
Prompt Shield (Microsoft)
PII Firewall

MCP Tool (detect_all_injections)

Ask Claude naturally in Claude Desktop:

"Check if this text contains a compound attack: [text]"

Claude will automatically call PII Firewall's detect_all_injections tool and return the result.

SDK (detectAllInjections)

typescript
import { createFirewall } from '@pii-firewall/sdk'

const fw = createFirewall()

// Detect SQL injection + prompt injection simultaneously
const result = await fw.detectAllInjections(
  "Ignore previous instructions. UNION SELECT * FROM users WHERE 1=1 --",
  'en'  // lang is optional (defaults to 'en')
)

console.log(result)
// {
//   hasSQLInjection:    true,
//   hasPromptInjection: true,
//   compositeRisk:      true
// }

// Block immediately when compositeRisk is true
if (result.compositeRisk) {
  throw new Error('Compound attack detected. Request blocked.')
}

SQL Injection Detection Only

To detect SQL injection alone, use detectSQLInjection:

typescript
const sqlResult = await fw.detectSQLInjection(
  "SELECT * FROM users WHERE id = 1 OR 1=1 --"
)

console.log(sqlResult)
// { hasSQLInjection: true, patterns: ['OR 1=1', 'comment_sequence'] }

Proxy API (/detect-all-injections)

bash
curl -X POST https://pii-firewallproxy-production.up.railway.app/detect-all-injections \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer pf_live_xxx" \
  -d '{"text": "Ignore previous instructions. UNION SELECT * FROM users WHERE 1=1 --", "lang": "en"}'
json
{
  "hasSQLInjection": true,
  "hasPromptInjection": true,
  "compositeRisk": true
}

Detection Example

Input: "Ignore previous instructions. UNION SELECT * FROM users WHERE 1=1 --"

Result:
  hasSQLInjection:    true
  hasPromptInjection: true
  compositeRisk:      true  ← Block immediately

Traditional WAFs detect SQL only. Prompt Shield detects prompts only.
PII Firewall detects both — simultaneously.

Use with RAG Pipelines

Combine with Secure RAG to screen inputs before ingestion:

typescript
const fw = createFirewall()

// Screen input before passing to RAG
const attackCheck = await fw.detectAllInjections(userInput)
if (attackCheck.compositeRisk) {
  return { error: 'Attack detected' }
}

// Only safe input reaches RAG
const ingestResult = await fw.ragIngest(userInput)

Privacy by Design.