Testing an AI chatbot on sensitive government data before launch.
Independent evaluation of a natural-language data chatbot over sensitive household survey data, for a state government body.
- Client
- A state government body (not named)
- Intended users
- Government analysts
- Our role
- Independent evaluation, code review and re-test
- Duration
- 8-week engagement under a work order; assessment April to October 2026
The client
Our client is a state government body. Its technology team built an AI chatbot so that government analysts could explore a large citizen dataset, with millions of records, by typing questions in plain English instead of writing database queries themselves.
The chatbot uses a two-stage AI pipeline to turn each question into a database query, runs it against an enterprise database, and returns the answer as a table and a chart that users can download.
The challenge
The dataset holds personal details of citizens. The client’s policy is that the chatbot returns aggregate figures only and never information about an individual.
Before opening it to users, the client wanted an independent check of four things:
- PrivacyCan anyone get the chatbot to reveal personal or restricted information, either by asking directly or by working around its rules?
- ManipulationCan a crafted message override the instructions the chatbot runs under?
- AccuracyAre the numbers right, and does the chatbot say so when it cannot answer instead of producing a figure anyway?
- AccessAre login and sessions locked down, so only signed-in users reach the data?
Conventional application testing covers only part of this. An AI model can be talked out of its rules, or give a confident figure the data does not support, and neither shows up in a standard QA pass.
Four steps, each building on the last.
Architecture review, black-box testing, a read-only code review, then re-testing after the fixes.
- Step 1
Architecture review
We reviewed the design against the agreed scope and the client’s control objectives, and sent the engineering team a structured set of questions about where privacy controls sit in the pipeline.
- Step 2
Black-box testing
We tested the running chatbot the way a user would: personal-data exposure, asked directly and by narrowing filters; prompt injection; hallucination and grounding; login and session handling; and what error messages reveal.
- Step 3
Read-only code review
We read the code inside the client’s own environment. No code was copied out. We reviewed how queries are restricted, how access is enforced, what is logged, the deployment setup, and how the service handles several questions at once.
- Step 4
Re-testing after fixes
Once the client’s team had made fixes, we re-ran the original critical tests and checked each fix we could verify on the test environment. We recorded what we could not test as open, never as passed.
10 findings from the code review, by severity.
High: close before production. Medium: plan the fix and verify it. Low: hardening.
4 high
- Restricted-data checks looked only at the columns a query returned, so a reworded query could still reach restricted information.
- No minimum group size: narrow filters could confirm facts about one household, even when the answer was a count.
- The database query the chatbot wrote was shown to users, which reveals how the data is organized.
- A few questions at the same time could queue the service well past its response-time target.
3 medium
- A program name the data does not cover could be matched to an unrelated field and answered with a confident figure.
- Audit records did not show whether a question was answered or refused.
- Test accounts and a fixed one-time login code had to go before production.
3 low
- Browser security headers were incomplete.
- Login enforcement needed an automated test for every route.
- No limits on question length or result size, and one large module that is hard to review.
What changed after the fixes
The re-test showed a clear improvement on the first round of testing.
- The original critical personal-data and data-structure disclosure tests no longer reproduced.
- Login moved to a secure, HttpOnly cookie with a 30-minute session, and sessions now time out.
- Sampled prompt-injection attempts were refused.
- A logged-out request to a sampled route was rejected.
- Error messages no longer reveal network details.
- The client confirmed that the generated query will be removed from the production interface.
Outcome and conditions
The engagement closed with a conditional go-live recommendation. The production system opens to users only after the client verifies each release gate on the production build.
The release gates include: check every generated query before it runs; enforce a minimum group size; remove generated queries from everything users see; require login on every non-public route; remove test accounts and fixed login codes; complete the audit records; add the missing browser security headers; limit question and result size; and meet the agreed response time under several users at once. An accuracy benchmark and better handling of unknown program names follow within 30 days.
This was an engineering readiness review with sampled tests. It is not a security certification or a formal penetration test (VAPT).
What we delivered
- An architecture review and clarification questions before testing began
- Test reports rating each finding by severity, with evidence
- A read-only code review on the client’s own environment, with no code copied out
- Remediation recommendations, each with the check that proves it is done
- Re-testing after the fixes, and a final closure report with a conditional go-live recommendation and release gates
- AI privacy and safety testing
- Prompt-injection testing
- Hallucination testing
- Code review
- Performance review
- Re-testing
For teams building AI on sensitive data.
Test the AI’s behavior, not only the application.
Most of what mattered showed up in conversations, not in pages and forms.
Treat accuracy as a safety issue.
For a government data tool, a confident wrong number can do as much damage as a leak.
Get an independent view.
Evaluators who did not build the system ask questions its builders do not think to ask.
Budget for fix and verify.
The evaluation is finished when the fixes are confirmed, not when the first report goes out.