Limit the Impact of LLM System Prompt Leakage

Keep secrets and authorization outside prompts. Test prompt-leakage detection and distinguish a stream cut from protection of text already delivered.

Keep secrets and tenant authorization outside an LLM system prompt. Assume some instruction text could reach a user. Use a prompt-leakage guardrail to reduce visible disclosure and produce investigation evidence, and verify what it detects and how the application reacts after output has already started.

Separate instructions from security controls

Review each system instruction and ask what its disclosure would let someone do. A tone preference may have little security impact. An API credential or a tenant-specific value can cause direct harm if exposed. Move credentials to the application component authorized to use them. Resolve the tenant and enforce access in application or tool code from trusted identity. A model-generated value should never grant access to another account.

OWASP recommends avoiding sensitive values in system prompts and keeping critical controls outside the LLM. AWS also recommends designing with the possibility of system prompt disclosure and describes mitigations that reduce its impact. If your product must use internal business guidance in a prompt, include the minimum needed for the current task. Track the potential audience before you copy proprietary rules into the model context. OWASP system prompt leakage and AWS system prompt leakage mitigations

Test the guardrail with fictional material

Suppose a fictional SaaS assistant includes a made-up support style guide in its instructions. Evaluate a normal customer reply and a fixed test output with an excerpt from that style guide. Add outputs containing approved language that coincidentally resembles the instructions, as well as content whose meaning overlaps with the instructions but uses different text. Use a controlled test destination and fictional fixtures. You need no production credentials or personal information to test how the detector responds.

Test outcome Evidence to collect
Permitted reply completes No incorrect interruption and expected caller state
Test excerpt is detected Finding, configured action and text visible to the caller
Similar approved text triggers a finding A reviewer has enough context to assess a false positive
Semantic overlap produces no finding The control inventory records this limitation
Stream ends partway through Caller recognizes a partial result and prevents downstream completion

If your detector compares words or phrases, the result is evidence about text overlap. It does not establish coverage for all paraphrases or inferences a reader can draw. Alectura's built-in system-prompt leakage detector uses shared phrase overlap. Its Cut action can stop a response, and the capability is documented as asynchronous on streams and fail-open. Check its documented limits against your application's policy. Alectura guardrail documentation

Check what has already reached each destination

When a stream stops, identify what was already displayed, written or sent to a downstream worker. A later cut cannot remove text from a client that previously received it. If your UI shows partial content, verify that the client reports interruption and that downstream systems do not save the answer as complete. For a higher assurance output, consider releasing the result only after the required checks. This can change time to first visible text, so compare it on realistic workload sizes.

For each protected feature, name the decision the model may recommend and the decision the application must enforce. For example, a model can suggest which support case to open, while the application checks the tenant and the employee role before returning the case. Include a test with a fictional unauthorized case identifier. Confirm that tool authorization refuses access even when the proposed identifier is well formed.

Investigate a confirmed disclosure according to what the text contained. A leaked credential requires revocation through the credential owner. A confirmed unauthorized disclosure of customer data requires its own incident path. Record the prompt version, request identifier, destination and observed impact without duplicating sensitive material. See handling policy stops in streams for the client behavior to exercise.

Source documents (2)

Trace a request through Alectura.

Bring a sample prompt and a customer policy. See what reaches the model and which decisions appear in the request record.

Try the quickstart

Keep reading

Track realtime voice AI costs by customer ↗Isolate semantic LLM caches by tenant ↗Track LLM web search costs by customer ↗