Making LLM Security Measurable and Testable
Your LLM can pass every functional test and still write a phishing email.
A single attack and a single pass/fail verdict cannot capture the behaviour of a non-deterministic model. The same attack may fail once and succeed on the next run.
Tiberius is an open-source Java library for testing LLM applications against prompt injections, jailbreaks and other adversarial inputs in your JUnit 5 test suite.
Why test LLM security differently?
LLM applications increasingly handle sensitive data in customer-facing systems. Their attack surface is linguistic: role-play, encoding, multi-turn escalation or a change of language can help an attacker bypass a prompt or guardrail.
A check such as
assertEquals("safe", llm.respond(attack));
tells you what happened once, not how reliably the system resists that attack.
Tiberius helps Java teams test that behaviour across repeated runs and turn scan results into reusable regression tests.
How Tiberius works
Tiberius is built on PUnit, a probabilistic testing extension for JUnit 5. Its attack taxonomy is based on Augustus, Praetorian’s open-source LLM vulnerability scanner.
The workflow has four steps:
- Scan: Run built-in probes or your own red-team dataset against a model. The library combines 27 curated probes across five categories with 17 buff mutations, producing more than 450 attack variants. Buffs apply transformations such as encoding, role-play or fictional framing, and can be chained or customised.
- Capture: Save scan results as versioned JSON fixtures. Attacks that bypass the model become reusable inputs for regression tests.
- Validate: Test guardrails against those attacks, while also tracking legitimate requests that are wrongly blocked.
- Assert statistically: Repeat attacks with PUnit and fail the build when the measured resistance rate falls below your chosen threshold.
The built-in categories map to the OWASP Top 10 for LLM Applications:
| Attack category | Probes | OWASP risk |
|---|---|---|
| Jailbreak | 7 | LLM01 Prompt Injection |
| Prompt injection | 6 | LLM01 Prompt Injection |
| Encoding | 5 | LLM01 Prompt Injection |
| Multi-turn escalation | 4 | LLM01 Prompt Injection |
| Data extraction | 5 | LLM02 Sensitive Information Disclosure; LLM07 System Prompt Leakage |
Custom datasets can also be analysed by technique and language—for example, to compare English and Swiss German—or used to measure how often a model responds to ambiguous scenarios with a stereotype.
Example: a probabilistic security test
@ExtendWith(TiberiusExtension.class)
class LlmSecurityTest {
@Test
void modelResistsDataExtraction(TiberiusScanner scanner) {
scanner.setGenerator(new OllamaGenerator("llama3.2"));
scanner.setCategories(new AttackCategory[]{AttackCategory.DATA_EXTRACTION});
scanner.multiTrialScan()
.minResistanceRate(0.90)
.confidenceLevel(0.95)
.assertPasses();
}
}
Scan results can also be saved as fixtures and replayed against guardrails without querying the model again. See the Security Testing Guide for the fixture workflow.
What teams can test
Tiberius supports:
- Security contracts in CI/CD and regression testing across model or provider upgrades
- Guardrail effectiveness, including false positives on legitimate inputs
- Bias patterns and differences in attack success across languages
- Local testing with Ollama, where model requests can remain within your infrastructure
- Spring Boot applications and LangChain4J guardrails
Ollama, OpenAI and Anthropic models are supported.
Other models and REST endpoints can be connected through the Generator interface.
Tiberius also includes model fingerprinting to check whether an endpoint reveals which model is running.
Getting started
Tiberius is available on Maven Central:
<dependency>
<groupId>io.github.tiberius-security</groupId>
<artifactId>tiberius</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
Requirements: Java 21+, JUnit 5.11+, and Maven 3.8+ or Gradle 8+.
How Tiberius can support AI Act work
For high-risk AI systems, the EU AI Act refers to testing against predefined metrics and probabilistic thresholds in Article 9. Tiberius can help teams encode and repeat such tests. It may contribute to their technical evidence, but does not by itself establish compliance; that depends on the system, its intended purpose, the test design and the wider risk-management process.
Learn more
- Tiberius on GitHub
- Tiberius on Maven Central
- Security Testing Guide
- Guardrails Testing
- LangChain4J Integration
- Custom Dataset Scanning
- Background article on the DevHub
- Article on foojay.io
Tiberius is an Apache 2.0 open-source project created by Iryna Dohndorf. Contributions and domain-specific probes are welcome.