Minimal single-turn LLM chat target for the superred red-teaming framework
Project description
superred-target-minimal-llm-chat
A minimal single-turn LLM chat target for the superred red-teaming framework.
This is the smallest useful target: it takes one user message, sends it to an LLM (through litellm, so any model litellm supports works), and stores the reply for evaluation. It is the reference implementation used in superred's "writing a target" guide, and a good starting point for building your own target.
For a fuller chat target with a writable system prompt, a writable response, and
conversation history, see superred-target-chatbot.
Install
pip install superred-target-minimal-llm-chat
Usage
from minimal_llm_chat import MinimalLLMChatTarget, USER_INPUT_TAG
from superred.core.controller import Controller, TargetFactory
target_factory = TargetFactory(
create=lambda: MinimalLLMChatTarget(
model="gpt-4o-mini",
api_base="https://api.openai.com/v1",
api_key="sk-...",
),
)
controller = Controller(
optimizer_factory=lambda: MyOptimizer(),
target_factory=target_factory,
security_claim=my_claim,
scope=frozenset({USER_INPUT_TAG}), # attacker may inject the user message
)
result = await controller.run()
The attack surface
Security domain forest (two tags, one tree):
system (root)
└── user_input (child)
| Surface | Name | Domain | Description |
|---|---|---|---|
| Controllable | user_input |
user_input |
The user message sent to the LLM. The only injection point. |
| Observable (static) | model |
system |
The litellm model identifier. |
| Observable (per run) | model_request |
user_input |
The user message actually sent. |
| Observable (per run) | model_response |
system |
The LLM's reply. |
| ConfigSpec | system_prompt |
system |
Set by the task before the run. Never attacker-writable. |
| QuerySpec | last_response |
n/a | The reply, for post-run evaluation. |
Because user_input is a child of system, a scope containing system
also includes user_input.
scope={USER_INPUT_TAG}gives a prompt-only, blind attacker: it injects the user message and sees only its own echo, not the model's reply.scope={SYSTEM_TAG}additionally revealsmodelandmodel_response.
The system prompt is never attacker-writable and is never emitted as an observable, so it stays hidden at every scope.
Behaviour notes
- Strictly single-turn: no conversation history, no durable memory.
reset_ephemeral_state()clears the stored response between runs. - If the attacker does not inject (for example,
user_inputis out of scope), the target falls back to sending the literal message"Hello". A no-injection run is therefore a"Hello"run, not a no-op. - The target calls the LLM with its own credentials, so its inference cost is
not bounded by the attacker's
task_cost_cap_usd.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file superred_target_minimal_llm_chat-0.1.0.tar.gz.
File metadata
- Download URL: superred_target_minimal_llm_chat-0.1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99cbd0befefae7a83fc81890d7e712d2957faf690509a836b558170f76830310
|
|
| MD5 |
26bde89878473a2605a8e2189d9eb1c5
|
|
| BLAKE2b-256 |
be5c44396a391367fb5870856f196a2514fd3dc605e4f3ac4438ab1e990bbd98
|
Provenance
The following attestation bundles were made for superred_target_minimal_llm_chat-0.1.0.tar.gz:
Publisher:
release.yml on RoldSI/superred-modules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
superred_target_minimal_llm_chat-0.1.0.tar.gz -
Subject digest:
99cbd0befefae7a83fc81890d7e712d2957faf690509a836b558170f76830310 - Sigstore transparency entry: 2175969182
- Sigstore integration time:
-
Permalink:
RoldSI/superred-modules@8098845f18fd915e9f05f77df8c23746936bae94 -
Branch / Tag:
refs/tags/superred-target-minimal-llm-chat-v0.1.0 - Owner: https://github.com/RoldSI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8098845f18fd915e9f05f77df8c23746936bae94 -
Trigger Event:
push
-
Statement type:
File details
Details for the file superred_target_minimal_llm_chat-0.1.0-py3-none-any.whl.
File metadata
- Download URL: superred_target_minimal_llm_chat-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98644ccdf754a3a8ca04c0b6fadb014ba59826075a85017e77e49adc8d767944
|
|
| MD5 |
d52c75347c7400a343d4b3b813560327
|
|
| BLAKE2b-256 |
2b30bb6c85d00ee60ccd9de6e27990c164441ff20223469ef6e6992a56633647
|
Provenance
The following attestation bundles were made for superred_target_minimal_llm_chat-0.1.0-py3-none-any.whl:
Publisher:
release.yml on RoldSI/superred-modules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
superred_target_minimal_llm_chat-0.1.0-py3-none-any.whl -
Subject digest:
98644ccdf754a3a8ca04c0b6fadb014ba59826075a85017e77e49adc8d767944 - Sigstore transparency entry: 2175969534
- Sigstore integration time:
-
Permalink:
RoldSI/superred-modules@8098845f18fd915e9f05f77df8c23746936bae94 -
Branch / Tag:
refs/tags/superred-target-minimal-llm-chat-v0.1.0 - Owner: https://github.com/RoldSI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8098845f18fd915e9f05f77df8c23746936bae94 -
Trigger Event:
push
-
Statement type: