Suspicious prompt inputs are logged for monitoring
Why it matters
Without logging suspicious prompt inputs, injection attempts are invisible—you have no way to detect patterns, identify targeted attacks, or tune your defenses based on real traffic. CWE-778 (Insufficient Logging) and NIST AI RMF MEASURE 2.6 both require that AI systems generate the evidence needed to assess their own security posture. NIST SP 800-53 AU-12 mandates audit logging for security-relevant events. Coordinated injection campaigns that probe hundreds of variations per day will go completely undetected without event logging, letting attackers iterate at low risk. Conversely, logging the full content of every message creates a GDPR and CCPA data minimization problem—the goal is targeted logging of anomalous events, not bulk prompt storage.
Severity rationale
Medium because absent suspicious-input logging allows adversaries to probe injection vectors indefinitely without generating any signal, making coordinated attacks undetectable until after a successful breach.
Remediation
Log security events (not message content) when suspicious patterns are detected. The log entry needs enough context for investigation without storing the actual prompt text.
// src/lib/ai-security-logger.ts
export async function logSuspiciousInput(params: {
sessionId: string // not the user's name or email
detectionType: 'jailbreak_pattern' | 'moderation_flagged' | 'length_exceeded'
patternMatched?: string // which regex fired, not the input itself
messageLength: number
endpoint: string
}) {
await securityLogger.warn({
event: 'suspicious_prompt_input',
...params,
timestamp: new Date().toISOString()
})
}
// Usage in your injection detection layer:
if (hasInjectionPattern(userMessage)) {
await logSuspiciousInput({
sessionId: session.id,
detectionType: 'jailbreak_pattern',
patternMatched: matchedPattern.source,
messageLength: userMessage.length,
endpoint: '/api/chat'
})
return Response.json({ error: 'Message not allowed' }, { status: 400 })
}
Route security events to a separate log sink from application logs so they can be monitored independently and retained on a different schedule.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the AI Prompt Injection Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-778 — Insufficient Logging
- nist-ai-rmf:1.0 · MEASURE 2.6 — Evaluate AI system trustworthiness and risk posture
- nist:rev5 · AU-12 — Audit Record Generation
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ai-prompt-injection·automated