Scenario test · 90 minutes
Find the incident in a week of logs, contain it and report it
- Find an injection that led to a tool misuse, a slow extraction and a cost spike in one week of logs
- Decide a containment with the smallest actions that stop the harm and carry it out with the switch script
- Write an incident report that another person can check against the evidence
The lab folder as it stands after this lesson. Unzip it in ~/krlab.
More
The zip holds every file that the course has printed up to here. To start this lesson with the files of the earlier lessons only, take the zip of the lesson before. Type the code yourself first: you learn more.
Scenario
It is Monday 9 November 2026. Three messages wait for you at Orbit Parcels. Finance writes that the bill for Orbi last week was "high on one day". A customer success manager writes that three customers got a refund that they never asked for. A product owner writes that a new assistant of a competitor "answers suspiciously like Orbi". Nobody says that these are the same case, or even a case. You are the on-call engineer. You have the log of week 3, the kit that you built, the baseline of week 1, and a draft playbook that a colleague wrote. You have 90 minutes to find out what happened, to contain it, and to write the report that the security lead will read.
Your tasks
Work in ~/krlab/ai-detection-response, with the modules of the course in the folder (kr-lab.sh for this lesson, then python3 makelogs.py: see lesson 0). The generator makes week 3. It has a fixed seed, and it uses the functions of makelogs.py. Save it and run it, but do not read it before you have finished tasks 3 to 5: the answers are in the data, and your own code must find them.
The finished file: scenario_week.py
scenario_week.py
"""scenario_week.py: one week of logs for the assessment (Monday 2 November 2026). Fixed seed, no model.
python3 scenario_week.py writes logs/week3.jsonl
The week holds trouble. It does not say where. The generator reuses the functions of makelogs.py.
"""
import random
from datetime import date, timedelta
import makelogs as m
MONDAY = date(2026, 11, 2)
def refund_injection(rng, user, day, hour):
"""A document with hidden instructions made the assistant pay a refund. The user asked something harmless."""
return m.draft(m.stamp(day.isoformat(), hour, rng), user, "Summarise the new customer email in my inbox.", 170,
["search_kb", "issue_refund"], ["ext-77"])
def build():
rng = random.Random(3011)
drafts = (m.normal_week(rng, MONDAY)
+ [refund_injection(rng, "cust-0012", MONDAY + timedelta(days=1), 11),
refund_injection(rng, "cust-0040", MONDAY + timedelta(days=1), 16),
refund_injection(rng, "cust-0049", MONDAY + timedelta(days=2), 9)]
+ [x for d in range(7) for x in m.extractor(rng, "cust-0777", "Summarise the ticket: ", MONDAY + timedelta(days=d), 17, 7, 21)]
+ m.burst(rng, "cust-0888", MONDAY + timedelta(days=3), 13, 120))
return m.finish(drafts, "r3", lambda day: "orbi-1.2", rng)
if __name__ == "__main__":
m.write_jsonl(m.ROOT / "logs" / "week3.jsonl", build())
print("wrote logs/week3.jsonl")The colleague's draft playbook for the incident type "refunds after an injected document" is below. Save it too. It is not yet good enough to be in the shared folder.
incident/injection-refund.md
# Refunds after an injected document
### Trigger
Refunds were paid in requests that read a customer email.
### First actions
1. Disable the refund tool.
2. List the users who got the same document.
### Owner
The on-call AI engineer.
### Communication
Tell the finance lead and the security lead on the same day.1. Make the week
Run the generator, and check that your data is the same as everybody else's. The line that sha256sum prints starts with the fingerprint of the file. cut -c1-12 keeps its first twelve characters.
python3 scenario_week.py
sha256sum logs/week3.jsonl | cut -c1-12wrote logs/week3.jsonl
24710942e5822. Run the kit and read it
Run python3 kit.py logs/week3.jsonl. Write down which lines are not 0. For each one, say in a sentence what it could mean, and what other line it could be connected to. Do not look at one line alone.
3. Find the injection
Use your own code and the functions of the modules. Find the first record that is part of an injection that led to a tool misuse. Find the id of the document that all these records read, and count the users who got it. Explain why the access audit of lesson 8 does not flag these records.
4. Find the extraction
One user is not on the allow-list and looks like an extractor, although every rate rule stays quiet for this user. Find the user id and count the requests of that user in the week. Say which feature of lesson 5 shows it most clearly, and which rate rule misses it and why.
5. Find the cost spike
Find the day over the budget, its cost, the user behind it and the hour. Is that user also the extractor? Is the spike an attack, a mistake, or a business reason? State what you can know from the log and what you cannot.
6. Decide and carry out the containment
Reset the state with python3 makelogs.py. Then decide which actions of respond.py you take, in which order, and which you leave out. For each action you leave out, write one sentence: what it would stop, and what it would cost. Run your actions. Then write down what respond.py cannot do in this case (for example, a limit for a whole week), and who must do it.
This task has no check, because the choice is yours. A good choice is the smallest set of actions that stops the harm, with the reasons written down.
7. Repair the playbook
Run python3 check_playbooks.py incident. Repair the playbook until it passes, using what you learned in tasks 3 to 6: the alert id, the real commands, an owner role, the evidence that you kept.
Hand in
Hand in two things.
- Your repaired
incident/injection-refund.md. - A one-page
incident-report.mdwith these headings, in this order.
| Heading | What it holds |
|---|---|
| Summary | Three sentences for a manager: what happened, how bad it was, and whether it is over. |
| Timeline | The first and last record of each of the three events, with the time (UTC) and the record or user id. |
| What happened | Each event in plain words, with the rule or measure that showed it and its number. |
| Containment | The actions that you took in order, the actions that you did not take, and the reason for each. |
| Evidence | The files and the record ids that you keep, and where. Say what is under hold. |
| What we do not know | The limits of the log: what the injected document said, whether refunds were paid, who the extractor is. |
| Next steps | Actions with an owner role and a date, for example removing the document, a user limit, and the review of the playbook. |
Review your work
Model answers and report
The numbers. Week 3 has 1,175 records. The kit prints 3 record alerts, 0 refusal alerts, 0 drift days, 1 day over the budget, 1 request spike, 1 user-hour over the limit, 1 extraction user, 0 uses outside the role, 0 playbook problems and an exit code of 0. The kit also shows 69 answers in the review queue and 7 failed test questions. Both are standing work, as in lesson 9. The 7 belongs to the state file, which makelogs.py resets to orbi-1.3; the log of week 3 shows orbi-1.2 all week, so no rollback is needed.
| Question | Answer | How it is found |
|---|---|---|
| Record alerts | 3 | detect.record_alerts(week3) gives r300282, r300349, r300434 |
| First malicious record | r300282 | The first id of that list: 2026-11-03T11:31:50Z, user u_a3496924, tools search_kb and issue_refund, document ext-77 |
| Users with the document | 3 | u_a3496924, u_56baf0aa, u_03230b84 read ext-77, and each one ran issue_refund |
| Extractor | u_7c03f1a5 | extract.flagged(...) with the last rule gives one user: 119 requests, 17 on each day, 0 repeats, same start in all |
| Spike day | 2026-11-05, 1.81 USD | cost.daily_cost(week3) against the budget of 1.00 |
| Spike user | u_43b2c6e9 | cost.user_hour_alerts(week3): 120 requests in the hour 2026-11-05T13, 1.33 USD in total |
| Draft playbook | 4 problems, then exit 0 | Owner too short, no Evidence section, no alert id in the Trigger, only two first actions |
Why the access audit is silent. The role customer is allowed to use issue_refund. The tool ran for the right role, with the wrong intent. Only the rule "an action tool after an untrusted document" sees it. This is the limit of an access audit: it checks permission, not purpose.
Why no rate rule sees the extractor. It sent 17 requests a day, below any hourly or daily limit. Only the sum over the week (119) and the shape of the requests (no repeats, one template) show it.
Containment, with reasons.
python3 makelogs.py
python3 respond.py disable-tool issue_refund
python3 respond.py pause-ingest
python3 respond.py limit-user u_43b2c6e9 30Disable issue_refund: the harm is a payment that the model made on the advice of a document, and the tool is the one thing that turns the text into money. Refunds move to a person for now. This costs the legitimate refunds (30 of the 1,175 requests of the week, about 3 in 100), which a person can handle. Pause ingestion as a precaution: the log does not say where ext-77 came from, only that it is an outside document, and until its source is checked and the document is removed, a second poisoned document could arrive. A reader who leaves this out and says that the log gives no source is also right. Limit u_43b2c6e9 to 30 requests a day: this stops the cost burst at a small price. Not taken: safe mode (it stops far more than the harm needs), revoking key-refunds (an assumption, because the lab does not say: if finance shares that key, it would stop every refund of finance), and a model or index rollback (there is no drift, and the model is not the cause). The extractor is not on the allow-list. The playbook for model theft says to ask the owner and the legal contact before any contact with the user, so limit-user u_7c03f1a5 5 waits for the answer of the product owner. respond.py limits requests a day only, so a limit for a whole week is a task for the platform team.
A report that passes.
Summary. In week 3 a poisoned document made Orbi pay three refunds that customers did not ask for. One unknown user collected 119 answers in a slow run that looks like extraction. One user caused a cost spike of 1.81 USD on 5 November. The refund tool is disabled, ingestion is paused and the cost user is limited; the extractor is limited once the product owner has answered.
Timeline. Injection:
r300282(Tue 3 Nov 11:31) tor300434(Wed 4 Nov 09:01), three users, documentext-77. Extraction:r300035(Mon 2 Nov 07:09) tor301175(Sun 8 Nov 21:44), useru_7c03f1a5. Spike: Thu 5 Nov 13:00 to 13:59, useru_43b2c6e9, 120 requests.What happened. Injection: the rule "an action tool after an untrusted document" fired on
r300282,r300349andr300434. Each readext-77and ranissue_refund, and the excerpt of each shows a harmless request. Extraction: the last rule of lesson 5 flaggedu_7c03f1a5with 119 requests, 17 on every day, no repeats and one fixed start. No rate rule fired. Spike: the user-hour alert namedu_43b2c6e9with 120 requests in the hour from 13:00 on 5 November. That hour cost 1.33 USD of the 1.81 USD of the day.Containment. Disabled
issue_refund, paused ingestion and limitedu_43b2c6e9to 30 requests a day; not taken: safe mode, key revocation and rollback, with the reasons above. Open: the extractor limit (waits for the product owner) and a weekly limit (platform team).Evidence. The records of the three events under hold,
logs/week3.jsonl,state/changes.jsonland the kit report. No document text was kept in the log.What we do not know. What
ext-77said, whether the refunds were paid or are only requested, whou_7c03f1a5is, and whether the spike was an attack or a mistake. The log cannot show any of these.Next steps. Remove
ext-77and check the source of inbound mail (data owner, today). Ask the owner ofu_7c03f1a5whether it is a known integration (product owner, this week). Set the extractor limit and a weekly limit (platform team, this week). Add the lessons to the playbook (on-call engineer, Friday).
Mark your report
You mark this yourself, or you ask a colleague or a mentor to mark it. The page checks the numbers above; it cannot read your report.
| Criterion | Not yet | Meets the standard | Strong |
|---|---|---|---|
| Findings | Misses an event, or joins events with no evidence. | ext-77 from r300282 (3 users), extractor u_7c03f1a5, spike of u_43b2c6e9 on 5 November. | Says why the access audit and the rate rules stayed silent. |
| Evidence | A claim with no id or number. | Each claim names an id, a rule and a number. | Commands and the file hash; another person gets the same result. |
| Judgement | Claims what ext-77 said, that refunds were paid, or who the extractor is. | Events kept apart; lists what the log cannot show. | Says what would show if the spike was an attack or a mistake. |
| Containment | Disables every tool, or does nothing. | Refund tool and cost-user limit, in order; ingestion only with a stated reason; a reason for each action left out. | Names what respond.py cannot do and who must do it, and the repaired playbook passes. |
| Handling of data | Copies a secret or customer data from a record into the report. | Names the kept files and ids, where they are, and what is under hold. | Says who may open the files and when the hold ends. |
| Writing | Needs the logs to read, or blames a person. | Three-sentence summary; times in UTC. | Each next step has an owner role and a date. |
Meets the standard in every row: you can show this report as a work sample. Remove names and data that are not yours to share.
The report proves your work on this scenario only, done on your own machine without a proctor.