langchain-middleware-patterns

Pass

Audited by Gen Agent Trust Hub on Sep 9, 2026

Risk Level: SAFE
Full Analysis
  • [SAFE]: The skill provides comprehensive security-focused middleware patterns for LangChain 1.0. The code snippets follow defensive programming best practices, such as using unit separators in cache keys to prevent collision attacks.
  • [PROMPT_INJECTION]: The static analysis hits for prompt injection ('Ignore previous instructions') are false positives. These strings appear strictly within regex patterns and test cases meant to detect and defend against injection attacks, rather than as attempts to override agent behavior.
  • [INDIRECT_PROMPT_INJECTION]: The skill explicitly mitigates indirect prompt injection by recommending guardrails and user-input wrapping (using <user_input> tags) for data processed from external sources like RAG systems.
  • Ingestion points: Data enters the chain via inputs['input'] in the middleware stack.
  • Boundary markers: Uses XML-style tags (<user_input>) and explicit regex detection.
  • Capability inventory: The skill provides logic for token budget enforcement and PII redaction to limit the impact of potential injections.
  • Sanitization: Includes regex-based filtering and Presidio-based NER for sensitive data removal.
  • [CREDENTIALS_UNSAFE]: Regex patterns for detecting API keys and JWTs are provided specifically for redaction and leakage prevention, not for harvesting credentials.
  • [EXTERNAL_DOWNLOADS]: The skill references well-known and trusted third-party libraries including presidio-analyzer, presidio-anonymizer, and langchain-redis for its functionality.
Audit Metadata
Risk Level
SAFE
Analyzed
Sep 9, 2026, 03:46 AM
Security Audit — agent-trust-hub — langchain-middleware-patterns