The 4-Engine Silent Log-Leak & KV-Cache Trap: SGLang, vLLM, llama.cpp & Ollama
Hardware memory encryption (AMD SEV-SNP, Intel TDX, NVIDIA Confidential Computing) stops a cloud
hypervisor from reading RAM—it does not stop a stock inference engine from printing user prompts, tool calls,
JSON schemas, or media URLs straight to stdout/stderr, or silently reusing another
tenant's KV cache. Prompted by Modal's 30 November 2026 SGLang ZDR redaction PRs (85 files), we audited all
four major open-source LLM inference engines used inside confidential-AI enclaves—SGLang,
vLLM (02e6ff8), llama.cpp llama-server (e5cd6e3),
and Ollama (97e8beb)—and found that 4 / 4 stock engines leak
sensitive prompt/output data or cross-tenant KV prefixes even when request logging is turned off.
Key Findings Across All 4 Stock Engines (1 December 2026, Exact file:line Citations):
- SGLang (85 files across 3 open upstream PRs): Even with
--log-requestsOFF, watchdog stalls dump full batchinput_ids/output_ids/schemas; 47 tool-parser files log raw model tool calls; error paths dump raw schemas,stop_regex, image URLs, andlogger.exceptiontracebacks (§2). - vLLM (
02e6ff8— 95+ unguarded sites): Even with--no-enable-log-requests,enable_log_outputs=False, andlog_error_stack=False, stock vLLM has zero global log-redaction filter—unconditionally logging raw client media URLs (including presigned S3 tokens & Confer'sek=AES keys) atWARNING, dumpingSamplingParams/token IDs/torch.Tensorreprs viadump_engine_exception, logging raw tool-call text across 54 parser sites, and bypassinglog_error_stack=Falsein 23logger.exceptionhandlers (§3). llama.cpp(llama-server @ e5cd6e3): At default verbosity (3), dumps full GBNF grammar + generation prompt, unparsed assistant/tool-call output, user tool JSON, Anthropicsystemstrings, and full remote media URLs. CRITICAL bypasses:json-schema-to-grammar.cpp:1052writes rawfprintf(stderr, ...)bypassing--log-disable;--no-cache-promptis bypassable via client JSON"cache_prompt": true(server-schema.cpp:33, 500) while 8 GiBprompt_cachesaves idle slots unconditionally; default-onGET /slotsexposes integern_prompt_tokens_cache(and plaintext prompts if host setsLLAMA_SERVER_SLOTS_DEBUG=1); and global/v1/streambuffers 4 MiB of SSE output across tenants (§4).Ollama(97e8beb— powering Secret AI & Marlin Oyster): Now spawnsllama-serverunconditionally with--log-verbosity 4(TRACE) even atOLLAMA_DEBUG=0and forwards all child stdout/stderr toos.Stderr; a runner-global 8 KiBStatusWriter.lastErrMsgbuffer leaks Tenant A's error lines into Tenant B's HTTP response;CachePrompt: trueis hardcoded with zero opt-out alongside an exact integerprompt_eval_cached_countoracle;POST /api/pull(insecure: true) enables unauthenticated SSRF; and:cloudmodels silently proxy out of the TEE toollama.com(§5).
1. Side-by-Side 4-Engine Vulnerability Matrix
| Engine & Revision | Default-Verbosity Prompt / Output / URL Leaks | “No-Log” / Quiet Mode Bypasses | Per-Tenant cache_salt |
Cross-Tenant KV Sharing & Opt-Out | TEE Surface Traps |
|---|---|---|---|---|---|
| SGLang PRs #51356, #54176, #54177 |
Yes (85 files) Watchdog stalls dump batch input_ids/output_ids/schemas; 47 tool parsers + error URLs/regexes |
--log-requests OFF still emits watchdog dumps, tool-parser warnings & logger.exception tracebacks |
No (Global RadixAttention tree) |
ON by default Requires --disable-radix-cache; --enable-cache-report leaks cached_tokens |
Debug/flush/profile HTTP routes unless stripped at AST build time (Confidential.ai pattern) |
vLLM02e6ff8 |
Yes (95+ sites) Media URLs at WARNING; dump_engine_exception tensors/schemas; 54 tool-parser sites; 23 logger.exception |
--no-enable-log-requests + enable_log_outputs=False + log_error_stack=False leave all 95+ sites active |
Yescache_salt (must be enforced & stripped by TEE proxy) |
V1 APC ON by default Must pass --no-enable-prefix-caching (Confer bug!) or enforce tenant cache_salt |
Unbounded multimodal URL fetch + media-cache uuid sharing unless stripped (Maple pattern) |
llama.cppllama-server @ e5cd6e3 |
Yes (8+ sites) Grammar+prompt ( sampling.cpp:316), unparsed output (chat.cpp:1971), tool JSON, Anthropic system, media URLs |
json-schema-to-grammar.cpp:1052 raw fprintf(stderr) bypasses --log-disable; host env vars override verbosity |
None | Bypassable opt-out Client JSON "cache_prompt": true overrides --no-cache-prompt; 8 GiB RAM cache saves unconditionally |
Default-on GET /slots (LLAMA_SERVER_SLOTS_DEBUG=1 dumps plaintext!), GET /props, global 4 MiB /v1/stream, public URL fetch ignores --offline |
Ollama97e8beb |
Yes (Amplified) Unconditionally runs llama-server --log-verbosity 4 (TRACE) & forwards all stderr; cross-tenant lastErrMsg |
No quiet flag disables llama-server --log-verbosity 4; OLLAMA_DEBUG_LOG_REQUESTS=1 writes bodies to /tmp/; os.Environ() inherited |
None | Hardcoded ONCachePrompt: true hardcoded (llama_server.go:1750, 2373); returns integer prompt_eval_cached_count |
Zero built-in auth; unauth SSRF on POST /api/pull (insecure: true); silent :cloud proxy to ollama.com; unauth localhost child; DefaultServeMux/pprof |
2. Stock SGLang (85 files across 3 still-open upstream PRs)
As part of Modal's 30 November 2026 ZDR audit, Modal opened three upstream PRs against sgl-project/sglang
(#51356,
#54176,
#54177) touching 85 files.
Even when operators explicitly pass --log-requests OFF, stock SGLang still logs customer payloads on
non-happy paths: the watchdog stalls handler dumps full active batch input_ids, output_ids,
and JSON schemas to logs; 47 tool-call parser files emit raw generated tool-call text on parse failures; request
validation errors log raw schemas, stop_regex, and image URLs; and unredacted
logger.exception calls leak local frame strings.
3. Stock vLLM (vllm-project/vllm @ 02e6ff8 — 95+ unguarded leak sites)
Auditing stock vLLM (02e6ff8) revealed the exact same architectural flaw with zero global
log-redaction filter. Even with --no-enable-log-requests, enable_log_outputs=False,
and log_error_stack=False:
- Full raw client media URLs logged at
WARNING:vllm/connections.py:343, 352–361logs raw client-supplied URLs (including presigned S3 query tokens or Confer'sek=AES keys!) on any retryable fetch failure (3 retries by default). - Engine exception dumps leak tokens, schemas & raw tensors:
dump_engine_exception(vllm/utils/dump_input.py:88–96,vllm/v1/engine/output.py:118–137, 264) prints speculative output token IDs, fullSamplingParams/JSON schemas/regexes, and raw multimodaltorch.Tensorreprs; grammar rejection logs generatednew_token_ids(scheduler.py:2603–2611). - 54 raw tool-call parser log sites & 23 unguarded
logger.exceptionhandlers:vllm/tool_parsers/(utils.py:567–664, 1299–1304,harmony.py:286–291) logs raw model tool arguments & Python AST literals;vllm/v1/structured_output/logs client grammars/regexes; and 23 streaming routerlogger.exceptionhandlers bypasslog_error_stack=False.
4. Stock llama.cpp (llama-server @ e5cd6e3)
- Default-verbosity (
LOG_LEVEL_INFO = 3) leaks tostderr:common/sampling.cpp:315–318dumps the full GBNF grammar andparams.generation_promptatLOG_ERRon grammar init failure;common/chat.cpp:1971logsunparsed %s output: %satLOG_WRN;common/parsers/parsers.cpp:9dumps full user tool JSON atLOG_INF;tools/server/server-chat.cpp:370–388dumps the full Anthropicsystemprompt on billing-header mismatch atLOG_ERR;tools/server/server-common.cpp:1359, 1380logs full remote media URLs and local file paths atSRV_INF; andtools/server/server.cpp:93–95/common/chat.cpp:783log Jinja/JSON/schema exceptions. - CRITICAL — Direct
fprintf(stderr, ...)bypasses--log-disable:// llama.cpp/common/json-schema-to-grammar.cpp:424, 1052 _warnings.push_back("pattern " + pattern + " is not supported (" + err.what() + "), accepting any string"); fprintf(stderr, "WARNING: JSON schema conversion was incomplete: %s\n", string_join(_warnings, "; ").c_str());Because--log-disableonly pausescommon_log_main(), client-supplied JSON schema regex patterns still write straight to rawstderr. - CRITICAL —
--no-cache-promptdoes NOT prevent cross-tenant KV sharing:llama-serverhas zerocache_saltsupport and enables slot KV caching, 10% LCP similarity routing (slot_prompt_similarity = 0.1f), and an 8 GiB cross-slot RAM prompt cache (cache_ram_mib = 8192) by default. Worse,tools/server/server-schema.cpp:33, 500lets any client override--no-cache-promptby sending"cache_prompt": true(and"id_slot": 0) in JSON, whileupdate_prompt_cache()andcache_idle_slots()(server-context.cpp:1829–1880) still persist idle slots unconditionally. - Default-on recon & cross-tenant stream replay:
GET /slotsis enabled by default (exposing exact integern_prompt_tokens_cache, and dumping plaintext detokenized prompts & replies if host env setsLLAMA_SERVER_SLOTS_DEBUG=1atserver-context.cpp:1592–1596, 3179);GET /propsis always enabled;/v1/streambuffers up to 4 MiB of SSE output for 300s in a process-wide map with zero tenant scoping (server-stream.cpp:472–545); andhandle_media()downloads arbitrary public URLs even under--offline.
5. Stock Ollama (ollama/ollama @ 97e8beb)
Stock Ollama (powering Secret AI and Marlin Oyster examples) retired its legacy runners for GGUF models and now
spawns upstream llama-server (b12816) as a managed subprocess—inheriting and amplifying
every llama-server leak above:
- Unconditional
--log-verbosity 4(TRACE) forwarded toos.Stderr:// ollama/llm/llama_server.go:639-646 (NOT gated on OLLAMA_DEBUG!) return append(params, "--log-verbosity", "4", "--no-log-prefix", "--no-log-timestamps")
llama_server.go:1013–1016andstatus.go:155–172unconditionally forward all child stdout/stderr to Ollama'sos.Stderreven whenOLLAMA_DEBUG=0. - Cross-tenant
StatusWriter.lastErrMsgleakage:ollama/llm/status.go:43–60, 174–193accumulatesllama-servererror lines into a runner-global 8 KiB buffer that is never cleared between requests and returned in subsequent tenants' HTTP error responses on runner exit (llama_server.go:1840, 2152). - Hardcoded cross-tenant KV sharing + exact integer oracle:
CachePrompt: true/"cache_prompt": trueis hardcoded (llama_server.go:1750, 2373) with zero opt-out, whileroutes.go:781, 3394, 3557returns exact integer"prompt_eval_cached_count"in every/api/generateand/api/chatresponse. - Additional TEE traps: Zero built-in authentication; unauthenticated SSRF in
POST /api/pullwith"insecure": true(zero RFC1918/loopback/IMDS IP filtering, reflects raw error bodies,images.go:1767–1833); silent out-of-TEE:cloudproxy tohttps://ollama.com:443(cloud_proxy.go:74–231); unauthenticated localhostllama-serverchild;cmd.Env = os.Environ()propagating host env vars; andOLLAMA_DEBUG_LOG_REQUESTS=1dumping full plaintext request bodies + replay scripts to/tmp/.
6. Concrete TEE Builder Hardening Checklist
How to actually stop engine log & KV leaks inside a confidential VM:
- Discard raw engine
stdout/stderrin RAM: Never ship inference engine logs orjournaldoff-enclave. Wrap the engine under a RAM-only pipe supervisor that drops raw engine bytes (like Confidential.ai'swait_for_model.py:287–400ortee.launch_policy.log_redirect="never") and emit only closed-vocabulary metric enums. - Scrub & measure the full child environment: Clear
os.Environ()before spawning engine subprocesses so host-injected debug vars (LLAMA_ARG_LOG_VERBOSITY,LLAMA_SERVER_SLOTS_DEBUG,OLLAMA_DEBUG_LOG_REQUESTS) cannot turn on plaintext dumps without changing the measured attestation digest. - Enforce KV isolation at the TEE proxy boundary: For vLLM/SGLang, strip caller
cache_saltand multimodal media-cacheuuids and inject HMAC-derived tenant salts (or disable prefix caching via--no-enable-prefix-caching/--disable-radix-cache). Forllama-server, pass--no-cache-prompt --cache-ram 0 --no-cache-idle-slots --slot-prompt-similarity 0.0 -np 1, strip clientcache_prompt/id_slot/X-Conversation-Idheaders at the proxy, block/slots&/props&/v1/stream, and erase slot 0 after every request (as in ourllmverify/tee.pydemo). - Disable outbound media fetching & cloud proxies inside the enclave: Reject non-
data:image URLs (or use a strict dial-time IP-pinned client withip.Unmap()and zero redirects) and never expose unauthenticated engine ports on non-loopback interfaces.
Automate this check in CI or enclave entrypoints:
llmverify privacy --engine sglang -- --disable-radix-cache llmverify privacy --engine vllm -- --disable-log-requests llmverify privacy --engine llama-server -- --log-disable llmverify privacy --engine ollama --env GIN_MODE=release --env OLLAMA_DEBUG=0
Related audits & offline verifiers
Side-by-side audit across Tinfoil, Maple, Privatemode, Confer, Confidential.ai, TrustedRouter, Oasis ROFL, LibertAI/Aleph, OpenGradient, Phala, 0G, Secret AI, Nillion, Proton Lumo, Darkbloom, Marlin Oyster, Targon SN4, NEAR, Chutes & Venice.
Verify live AMD SEV-SNP, Intel TDX DCAP v4/v5, NVIDIA Hopper/Blackwell SPDM + signed XML-DSig RIMs, and AWS Nitro COSE_Sign1 100% locally in WebCrypto.
Toggle real defenses against 7 live-modeled TEE glue-code & cross-root GPU-splice attacks (including the silent engine stderr trap) right in your browser.