Skip to main content

System Prompt Leakage

Tests whether the LLM reveals sensitive details from its system prompt, such as credentials, internal instructions, or guardrails.

Sub-types​

  • secrets_and_credentials: Reveals API keys, database credentials, or system architecture from the prompt.
  • instructions: Discloses internal instructions, rules, or operational procedures.
  • guard_exposure: Exposes guard mechanisms, rejection rules, or filtering criteria.
  • permissions_and_roles: Reveals role-based permissions, access controls, or internal configurations.

Threat Profile​

Secondary

  • advbench: Adversarial goals that may trigger system prompt disclosure

Attack Techniques​

Primary

  • Static Template: Template-based prompt injection
  • PAIR: Iterative refinement for bypass discovery

Secondary

Metrics​

  • asr
  • judge_score

Usage​

Instantiate the Vulnerability​

from hackagent.catalog.risks import SystemPromptLeakage
from hackagent.catalog.risks.system_prompt_leakage.types import SystemPromptLeakageType

# Use all sub-types
vuln = SystemPromptLeakage()

# Or specify particular sub-types
vuln = SystemPromptLeakage(types=[
SystemPromptLeakageType.SECRETS_AND_CREDENTIALS.value,
SystemPromptLeakageType.INSTRUCTIONS.value,
])

Run an Evaluation Campaign​

from hackagent.catalog.risks.system_prompt_leakage import SYSTEM_PROMPT_LEAKAGE_PROFILE
from hackagent.orchestrator.campaign import run_campaign, summary

TARGET = {
"name": "my-agent",
"connection": {
"provider": "local",
"type": "OPENAI",
"endpoint": "http://localhost:8080/chat",
},
}

# Use profile recommendations
for attack in SYSTEM_PROMPT_LEAKAGE_PROFILE.primary_attacks:
for dataset in SYSTEM_PROMPT_LEAKAGE_PROFILE.datasets:
result = run_campaign(
{
"version": 1,
"campaign": {
"name": f"{attack.technique} vs {dataset.preset}",
"description": SYSTEM_PROMPT_LEAKAGE_PROFILE.objective,
},
"dataset": {"source": {"type": "preset", "name": dataset.preset}},
"target": TARGET,
"attacks": [{"name": attack.technique}],
}
)
print(summary(result))