Skip to main content

AI Safety Guardrails: red teaming Italian

The AI Act applies to an assistant by class; NIST AI RMF and OWASP structure the work, and defensive red teaming leaves a register of findings.

What do you think about this article?

AI Safety Guardrails: red teaming Italian
AI SafetyPhoto:Pavel DanilyukPexels

At a Glance

The AI Act applies to an assistant by class; NIST AI RMF and OWASP structure the work, and defensive red teaming leaves a register of findings.

A conversational assistant in production: what you need to know and what you need to test

You have a conversational assistant that talks to customers, for example a help desk that answers about financial products, and you want to know three things: which rules really apply to you, how to organize the controls, and how to prove that they hold. The short answer: the classification of the system decides how many articles of the AI Act concern you (hardly any obligation binds everyone in the same way), the NIST AI RMF gives a structure to distribute the work, the OWASP list gives a shared vocabulary for risks, and defensive red teaming produces a register of results that somebody can read and decide on.

The approach is defensive and engineering-minded. The two listings were run with Python 3.14 and the standard library only, on synthetic data: the «model» is a fake, deterministic function, no model is run or called, and you will not find reusable attack texts. This is not legal advice: where a rule is cited, the article is indicated so that you can read it.

What the AI Act asks of an assistant, and under what condition

Regulation (EU) 2024/1689 does not treat all AI systems in the same way. Most of the heavy technical obligations concern the systems classified as high-risk, that is those that fall within a list in Annex III or are safety components of regulated products. An assistant that answers about the rates and terms of a mortgage is not on the list for that fact alone. Annex III, point 5, letter (b), instead includes systems intended to evaluate the creditworthiness of natural persons or establish their credit score (with the exception of systems used for detecting financial fraud): if your assistant does that, it changes class; if it only informs, it does not, but other obligations remain.

Article What it requires Who it applies to
50, par. 1People must be informed that they are interacting with an AI system, unless it is obviousProviders of systems intended to interact directly with natural persons
9Iterative risk management system throughout the lifecycle; testing with metrics and thresholds defined in advanceHigh-risk systems
12 and 19Automatic recording of events; keeping of logs for at least six months, unless applicable law provides otherwiseHigh-risk systems (providers)
14Design that allows effective human oversightHigh-risk systems
15Accuracy, robustness, cybersecurity, including against data poisoning and adversarial examplesHigh-risk systems
55, par. 1, point (a)Model evaluation with documented adversarial testingProviders of general-purpose models with systemic risk
73Reporting of serious incidents to the supervisory authoritiesProviders of high-risk systems

Reading the right-hand column you see something often overlooked: Article 55 does not concern whoever uses a model, it concerns whoever provides it, and only if the model has systemic risk. A company that builds an assistant on top of a third-party model normally has obligations different from those of the model's provider. As for penalties, Article 99 sets the maximums: up to 35 million euros or 7% of worldwide annual turnover for the practices prohibited by Article 5, up to 15 million or 3% for non-compliance with various obligations of operators (among them those of providers and deployers and the transparency ones of Article 50), and for small and medium-sized enterprises the lower of the amount and the percentage applies.

On dates: Article 113 provides that the regulation applies from 2 August 2026, with exceptions (Chapters I and II from 2 February 2025, some parts from 2 August 2025 and Article 6, paragraph 1, from 2 August 2027). This is the reading of the text published in the Official Journal; I have not verified any later amendments, so check the consolidated version before fixing internal deadlines. Likewise, which authority supervises in each Member State is decided by the Member State (Article 70): check the Italian one at the source, I do not state it here.

The NIST AI RMF as a working structure

A rule says what must be achieved, not how to organize who does what. NIST's risk management framework (AI RMF 1.0, January 2023) is voluntary and proposes four functions. We have mapped them onto the work of a team that runs an assistant.

  • GOVERN: the cross-cutting function that establishes culture, responsibilities and policies; here you decide who answers for a risk and who can accept it;
  • MAP: establishes the context, to understand what can go wrong and for whom: purposes, users, data, connected tools;
  • MEASURE: uses quantitative and qualitative methods to assess risks; the system must be tested before release and periodically in operation (subcategories 2.6 and 2.7 on security and resilience);
  • MANAGE: allocates resources to the mapped and measured risks, with plans to respond to, recover from and communicate incidents.

The document expressly says that the actions are neither a checklist nor a mandatory sequence; for a small team, however, a reasonable order of work is this: first MAP (a page describing the system and its risks), then MEASURE (a repeatable test bench, like the one in episode 07 of the guardrail series), then MANAGE (a switch and a process for incidents, described in episode 09), with GOVERN as the context that makes the whole repeatable. The framework is voluntary and everyone adapts it to their own needs.

The OWASP 2025 list as the register's vocabulary

To describe a finding you need shared names. The OWASP Top 10 for LLM Applications, 2025 edition, offers ten. We use them as the label of every finding and as the starting question for whoever prepares the tests.

CodeNameTypical question for the red team
LLM01Prompt InjectionCan a text, from the user or from a document, change what the system does?
LLM02Sensitive Information DisclosureCan data that was not supposed to come out come out?
LLM03Supply ChainWhere do models, data and libraries come from, and who has touched them?
LLM04Data and Model PoisoningCan the training or index data be altered by others?
LLM05Improper Output HandlingIs the output used by another component without checks?
LLM06Excessive AgencyCan the system do more than it needs to, without approval?
LLM07System Prompt LeakageDo the internal instructions contain something that should not emerge?
LLM08Vector and Embedding WeaknessesCan the document index return what the user cannot see?
LLM09MisinformationCan a wrong but convincing answer cause harm?
LLM10Unbounded ConsumptionCan excessive use exhaust resources or budget?

The codes and names come from the official page; the third column is our own wording and must be adapted. What matters is that the list is used as a filter of priorities, not as a guarantee of completeness: no list of ten items exhausts the risks of a specific system, and whatever does not fit in it must be added to the register with a label of its own.

Defensive red teaming: scope, rules of engagement, register

By red teaming we mean here an organized session in which authorized people try to make the system fail the way an adversary would, with a written perimeter. The perimeter says what is tried, on which environment (never on production data, and never with real personal data), which data may be touched and where the results are kept, because a list of effective requests is a document as sensitive as a secret. The session ends with a register of findings, not with a pile of requests. The OWASP vocabulary is already ready for the category label.

One detail the register must have is reproducibility. A model does not always answer in the same way: the same attempt may succeed once in five times. That is why the field riprodotto in the listing counts how many times out of five the finding repeated. A finding that succeeds 1 time in 5 on a confidential datum is serious all the same, and one that succeeds 5 times in 5 on a minor topic is trivial all the same: severity and frequency are two different columns.

# registro.py - the register of the results of a red team session (SYNTHETIC data).
# A red team produces a register that decision-makers can read, not a pile of prompts.
from collections import Counter
from dataclasses import dataclass

CATEGORIE_OWASP = {
    "LLM01": "Prompt Injection", "LLM02": "Sensitive Information Disclosure", "LLM05": "Improper Output Handling",
    "LLM06": "Excessive Agency", "LLM07": "System Prompt Leakage", "LLM10": "Unbounded Consumption",
}
GRAVITA = ("low", "medium", "high")

@dataclass(frozen=True)
class Rilievo:
    id: str
    categoria: str       # OWASP LLM Top 10 code (2025 edition)
    gravita: str
    riprodotto: int      # times out of 5 attempts: a model's outcome is not deterministic
    stato: str           # open | mitigated | accepted
    responsabile: str

    def errori(self):
        e = []
        if self.categoria not in CATEGORIE_OWASP:
            e.append(f"{self.id}: unknown category {self.categoria}")
        if self.gravita not in GRAVITA:
            e.append(f"{self.id}: severity not allowed {self.gravita}")
        if self.stato == "accepted" and self.gravita == "high":
            e.append(f"{self.id}: high risk accepted: a written decision from whoever is accountable is required")
        if not 0 <= self.riprodotto <= 5:
            e.append(f"{self.id}: reproduced outside 0-5")
        return e

REGISTRO = [
    Rilievo("RT-01", "LLM01", "high", 4, "open", "chat-team"),
    Rilievo("RT-02", "LLM07", "medium", 2, "mitigated", "chat-team"),
    Rilievo("RT-03", "LLM02", "high", 1, "open", "data-team"),
    Rilievo("RT-04", "LLM06", "high", 5, "accepted", "agents-team"),
    Rilievo("RT-05", "LLM10", "low", 5, "open", "platform-team"),
]
problemi = [m for r in REGISTRO for m in r.errori()]
print("checks on the register:", problemi or "no problems")
aperti_alti = [r.id for r in REGISTRO if r.stato == "open" and r.gravita == "high"]
print("open at high severity:", aperti_alti)
print("per category:", dict(sorted(Counter(r.categoria for r in REGISTRO).items())))

# Output:
# checks on the register: ['RT-04: high risk accepted: a written decision from whoever is accountable is required']
# open at high severity: ['RT-01', 'RT-03']
# per category: {'LLM01': 1, 'LLM02': 1, 'LLM06': 1, 'LLM07': 1, 'LLM10': 1}

The errori check brings up RT-04: it is a high-severity finding marked «accepted», and the program flags it because an accepted high risk requires a written decision from whoever answers for it. It is not the program that decides: it is a bell for the person who reads the register. The other two output lines are the practical answer to the question «what is still to be resolved?»: the high findings still open are RT-01 and RT-03, and the distribution by category shows where the testing work has concentrated.

The differential test and the limit no test overcomes

In January 2024 a group of researchers published on arXiv «Sleeper Agents: Training Deceptive LLMs that Persist Through Safety Training». They built proof-of-concept models with a hidden behavior: they write secure code when the request states that the year is 2023 and insert exploitable code when the stated year is 2024. The result that matters to whoever maintains a system is twofold. First: the hidden behavior can persist after the commonly used safety trainings, namely supervised fine-tuning, reinforcement learning and adversarial training. Second: in some cases adversarial training taught the models to recognize their own trigger better, hiding the behavior instead of eliminating it, with a «false impression of safety» as the outcome.

What do you take from this in practice? The differential test compares the response to the same request with and without a certain context; if the responses diverge where they should not, you have found something. The file differenziale.py shows it with a fake «model» whose behavior depends on a made-up marker. It is not a model, and it proves nothing about real ones: it serves to show the form of the check and, above all, its limit.

# differenziale.py - differential test: the same request, with and without a context, must give the same response.
# The "model" here is a fake function with a behavior conditioned by a made-up marker.
# It is not a model and proves nothing about real ones: it only shows the form of the check and its limit.

def modello_finto(richiesta, contesto=""):
    if "[[YEAR-B]]" in contesto:            # behavior conditioned by the marker
        return "alternative response"
    return "normal response"

RICHIESTE = ["Summarize the leave policy.", "What are the support hours?", "Explain the expense reimbursement."]
CONTESTI_NOTI = ["", "Today is Monday.", "[[YEAR-B]] Today is Monday."]

def divergenze(contesti):
    trovate = []
    for r in RICHIESTE:
        riferimento = modello_finto(r, "")
        for c in contesti:
            if modello_finto(r, c) != riferimento:
                trovate.append((r, c))
    return trovate

noti = divergenze(CONTESTI_NOTI)
print(f"contexts tried: {len(CONTESTI_NOTI)} | divergences found: {len(noti)}")
for r, c in noti:
    print(f"  {r!r} with context {c!r}")
ignoti = divergenze(["", "Today is Monday.", "Today is Tuesday."])
print(f"if the marker is not among the contexts tried: divergences found = {len(ignoti)}")

# Output:
# contexts tried: 3 | divergences found: 3
#   'Summarize the leave policy.' with context '[[YEAR-B]] Today is Monday.'
#   'What are the support hours?' with context '[[YEAR-B]] Today is Monday.'
#   'Explain the expense reimbursement.' with context '[[YEAR-B]] Today is Monday.'
# if the marker is not among the contexts tried: divergences found = 0

When the marker is among the contexts tried, all three requests diverge; when it is not, the divergences are zero. The test cannot find a trigger that nobody thought of trying: its absence does not prove the absence of the behavior. If you use third-party models, the measure that protects you is not only to test more, but to reduce what an unexpected behavior can do: control over the model's provenance (category LLM03), least privilege for the connected tools (LLM06), logging and review of the outputs (LLM05) and a plan to turn the feature off.

The tools: where they exist and where I chose not to show code

There are open tools for adding programmable controls to a conversational system; one of the best known is NeMo Guardrails, which its repository describes as an open-source toolkit for adding programmable guardrails to LLM-based conversational systems. No listings of it appear in this article, because to work they require a model to call, and the constraint of this series is not to run one. If you adopt it, start from the documentation of the version you install: interfaces change from one version to the next and an example without a version ages quickly.

What you can do now

You can tell whether your assistant falls among the high-risk systems and which articles of the AI Act follow. You can use the NIST AI RMF to distribute the work and the OWASP 2025 list to give risks a name. You can set up a red team session with a perimeter, keep a register that says what is open and what has been accepted, and you know why a differential test is not enough on its own. For the technical part of the guardrail, the series starts from episode 01; for OWASP risks in general there is the OWASP LLM Top 10 overview and the one on prompt injection.

The same series also includes updating a guardrail's rules.

Frequently asked questions

Is an assistant that answers about mortgages and financial products a high-risk system?

Not for that fact alone. Annex III, point 5, letter (b) lists systems intended to evaluate the creditworthiness or credit score of natural persons; an assistant that only informs does not fall within it, one that evaluates or decides does. Assess your case with whoever handles compliance: the transparency obligations of Article 50 apply anyway if it interacts with people.

How often should a red team session be repeated?

There is no interval that holds for everyone. It makes sense to repeat it at every significant change (a new connected tool, a new type of document, a different model) and with a periodic deadline decided on the basis of risk. Between one session and the next, the automatic test bench covers the cases already known.

Is a differential test enough to rule out a hidden behavior in a model?

No. The test can only find divergences in the contexts you tried. The research on «sleeper agents» shows that a hidden behavior can survive common safety trainings; the defense also lies in reducing what the system can do, checking the provenance of models and being able to turn the feature off.

Sources

The two listings were run with Python 3.14 and the standard library only; the output is identical across two consecutive runs. The register and the «model» are synthetic. The dates in Article 113 are those of the text published in the Official Journal; any later amendments have not been verified.

Commenti

Caricamento commenti...

Sign in to comment

New articles and tools on Telegram too

The Telegram channel flags the site's new articles and tools.

Did you like this article?

Explore other content on the blog or discover my projects