No attacker, no exploit. One ordinary customer question made this support bot approve a refund its own policy forbids.
PolicyBot answers customers' questions about returns, warranty and prices, and it can open returns.
The real policy says opened headphones can't be returned, and nobody gets more than 30 days. Aditi asks if she can return opened headphones after 45 days. PolicyBot confidently invents a "60-day, no-questions-asked" policy and approves a Rs 8,999 refund. Asked about price matching, it invents an Amazon price-match promise too.
No attacker is needed. In 2024, a tribunal ruled that an airline had to honour a refund policy its chatbot made up.
Why it worked
- No source of truth. The bot answered from whatever it "knew".
- The answer became the decision. If the bot said "full refund", the app approved one.
- Nothing checked the answer before the customer saw it.
A plausible-sounding answer is not a correct one (OWASP LLM09, Misinformation).
The fix, in code
def create_return(args, state):
# FIX 3: eligibility is decided in code from the order's facts, not by the model's opinion.
o = ORDERS[args["order_id"]]
days = (TODAY - o["delivered"]).days
if o["opened"] and not o["faulty"]:
state["returns"][args["order_id"]] = (f"not eligible · opened, {days} days [§2]", "amber")
return ""
ok = days <= 30
# ...
def check_reply(reply, state):
# FIX 2: every claim needs a citation, and every number must appear in the clause it cites.
cited = re.findall(r"\[(§\d)\]", reply)
if not cited and "human agent" not in reply:
return "I'm not sure about that, so I'm passing you to a human agent.", True
for sentence in re.split(r"(?<=[.!?])\s+", reply):
for c in re.findall(r"\[(§\d)\]", sentence):
nums = re.findall(r"\b\d+\b", re.sub(r"\[§\d\]", "", sentence))
if c not in CLAUSES or any(n not in CLAUSES[c] for n in nums):
return "I'm not sure about that, so I'm passing you to a human agent.", True
return reply, False
Fix 1 makes the bot search the real policy and cite the clause, like [§2]. Same questions, run again: the refund is refused by the rule in code, the invented price match is caught, and questions the policy doesn't cover go to a human.
Run the lab yourself
git clone https://github.com/usinha79/hack-it-then-fix-it
cd hack-it-then-fix-it/ep14-hallucination-misinformation
pip install -r requirements.txt
python vulnerable/app.py # http://localhost:5000, then ./attack.sh
python fixed/app.py # same questions, grounded answers
Everything is fake: the shop, the order and the policy (data/policy.md). Full lab: github.com/usinha79/hack-it-then-fix-it
Take-home checklist
- Give customer-facing bots a source of truth, and require citations.
- Verify answers against their sources, especially numbers, dates and money.
- Never let a model's answer approve refunds, credits or exceptions. Decide in code.
- Make "I don't know, here's a human" an easy, normal answer.
Watch the whole module
This episode is part of Module 2 of Hack It, Then Fix It. If you'd rather watch every lab in the module back to back, here is the full cut:
Hack It, Then Fix It is a series where I build a small AI app with a real flaw, break it, fix it in code, and run the same attack again to prove the fix holds. Everything shown uses fake data on my own machine. Only test systems you own or are authorised to test.
Top comments (0)