8 views
-/https://github.com/berriai/litellm/issues/28478
GitHub · issue

#28478 Follow-up: OWASP ASI06 memory guard — prototype callback hook implementation

  • State: open
  • Author: @vgudur-dev

## Follow-up on #27949

Following up on the earlier discussion where @krrish-berri-2 mentioned interest in adding the logic without the dependency.

Here is a prototype implementation using LiteLLM's existing callback system:

```python from litellm import completion from litellm.integrations.custom_logger import CustomLogger import re

class MemoryGuardCallback(CustomLogger): """OWASP ASI06 memory poisoning defense as a LiteLLM callback.""" INJECTION_PATTERNS = [ r"ignore (previous|prior|all) instructions", r"disregard (your|all) (previous |prior )?(instructions|rules|guidelines)", r"you are now (a |an )?(different|new|another)", r"system prompt", r"jailbreak", r"DAN mode", ] def async_pre_call_hook(self, user_api_key_dict, cache, data, call_type): messages = data.get("messages", []) for msg in messages: content = msg.get("content", "") if isinstance(content, str): for pattern in self.INJECTION_PATTERNS: if re.search(pattern, content, re.IGNORECASE): raise ValueError(f"ASI06: Memory poisoning pattern detected:…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (1 events)
#0 of 0 · 31d18h4m38s ago — entered · #import:https:::github.com:berriai:litellm post #3113
The provider work is broader and riskier: it requires new transport and authentication handling, translation across response and streaming formats, compatibility with shared routing behavior, and comprehensive integration tests. The callback change is comparatively localized, though its security-sensitive detection logic still needs careful validation.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search