- Purpose: Sanitized web search with PII stripping and injection detection
- Port: 8485
- Language: Python
- Systemd unit: secure-ai-search-mediator.service
- Default state: Disabled
The Search Mediator allows the LLM to perform web searches while maintaining user privacy. All queries are sanitized, routed through Tor, and results are scanned for injection attacks before being fed back to the model as context.
LLM generates query
|
v
PII stripped from query
|
v
Query routed through Tor
|
v
SearXNG meta-search engine
|
v
Results cleaned and normalized
|
v
Injection detection scan
|
v
Safe results injected as LLM context
- The LLM generates a search query as part of its reasoning.
- The Search Mediator strips any PII (names, emails, addresses, etc.) from the query before it leaves the appliance.
- The sanitized query is sent to a local SearXNG instance, which routes the request through Tor.
- SearXNG aggregates results from privacy-respecting search engines.
- Returned results are cleaned (HTML stripped, normalized) and scanned for prompt injection patterns.
- Clean results are injected into the LLM's context window for the current conversation.
All search traffic is routed through the Tor network. The search engines never see the appliance's real IP address.
SearXNG is configured to query only privacy-respecting sources:
- DuckDuckGo (DDG)
- Wikipedia
- Stack Overflow (SO)
- GitHub
Google, Bing, and other tracking-heavy engines are excluded.
To prevent traffic analysis and query correlation:
- Decoy queries: The mediator periodically issues plausible but meaningless queries to mask real search patterns.
- K-anonymity: Queries are generalized to reduce uniqueness before submission.
- Batch timing: Multiple queries are batched and submitted together to prevent timing correlation.
- Query padding: All queries are padded to a uniform length to prevent length-based fingerprinting.
- Timing randomization: Random delays are added between queries to break timing patterns.
Search results are scanned for prompt injection patterns before being injected into the LLM context. Detected patterns include:
- Instructions embedded in result text (e.g., "ignore previous instructions")
- Encoded payloads (base64, URL-encoded instructions)
- Excessive special characters or formatting designed to break context boundaries
Results containing detected injection patterns are filtered out and logged.
Submit a search query.
Request body:
{
"query": "how to configure nftables firewall rules",
"max_results": 5
}Response: 200 OK
{
"results": [
{
"title": "nftables wiki - Quick reference",
"url": "https://wiki.nftables.org/wiki-nftables/index.php/Quick_reference",
"snippet": "This page provides a quick reference for nftables rule syntax..."
}
],
"query_sanitized": true,
"results_filtered": 0
}Response (disabled): 503 Service Unavailable
{
"error": "search mediator is disabled"
}The Search Mediator is disabled by default. To enable it:
- Set
search.enabled: trueinpolicy.yaml. - Ensure the Tor service is running.
- Restart the search-mediator service.
Enabling search introduces a privacy trade-off: even with Tor and differential privacy, the act of searching reveals that the appliance is active and interested in certain topics.