Blog / 16 October 2026

Industry series · Hospitals & pharma · 16 October 2026 · 4 min read

AI Agents in Hospitals & Pharma: Security Risks and Practical Controls

A single mis‑typed line of code in an AI‑generated discharge summary can expose an entire patient chart to the internet before a human ever sees it.

AI agents in hospitals and pharmahospitals and pharma AI securitysecure AI agents for hospitals and pharma

01Where AI agents touch the patient record

In a typical hospital, agents are deployed to draft clinical documentation, fill prior‑authorization forms, scan research datasets and even generate scripts for laboratory information systems. Each of those tasks writes to an electronic health record or a regulated trial database, meaning the underlying data is PHI that falls under HIPAA, GDPR and GxP expectations.

The agent’s workspace often lives on a shared server where other services run. If the agent can reach beyond its intended folder, it may read or write files belonging to unrelated patients, corrupt audit trails, or leak keys that grant access to downstream APIs.

02A plausible failure: unchecked network egress

Imagine an agent that pulls a public model for language generation, then contacts a third‑party code‑completion service to speed up a research script. Without a network allow‑list, the request traverses the hospital’s internet gateway, exposing a PHI snippet in the URL query string. The external service logs that request, creating an unsecured copy of protected data.

Similarly, a rogue script could attempt to download a ransomware payload. If the host’s firewall is not restricted to known endpoints, the agent can silently fetch the payload, store it in the workspace and later execute it during a routine batch job.

Fit map · Hospitals & pharmaWhat hospitals & pharma needs, and what kosa8 does about it
  1. isolated execution for each agenteach agent runs in its own sealed microVM with its own kernel
  2. workspace confinementthe agent's machine sees one folder (the workspace) and nothing else on the host
  3. restricted network egressthe network is closed except for hosts on an allow‑list you write
  4. secure handling of API keysAPI keys stay on the host; an egress broker injects them on the way out, and the sandbox holds only a placeholder
  5. rapid recovery from misstepsa checkpoint saves the whole running machine in about 0.7 seconds; a rewind puts it back, still running, in about half a second
  6. tamper‑evident activity logevery action is written to a hash‑chained, tamper‑evident audit log, marked human or agent

03Control points that turn a risk into a manageable process

Isolate each agent in its own sealed microVM so the kernel, file system and network stack are separate from the host. The microVM only sees a single folder that you explicitly mount as the workspace, eliminating accidental cross‑tenant reads.

Apply a strict allow‑list for outbound connections. Any destination not on the list is refused, which blocks accidental data exfiltration and limits calls to vetted services such as the hospital’s internal FHIR gateway.

Keep API secrets on the host, not inside the sandbox. An egress broker injects the real key when a request is allowed, while the sandbox only holds a placeholder. This prevents a compromised agent from stealing the secret.

Use checkpoint and rewind to capture a full machine snapshot before a risky operation—such as executing a new data‑analysis library. If the operation misbehaves, rewind restores the environment in about 0.7 seconds, preserving the original state.

  • Seal each agent in its own microVM (kernel isolation).
  • Mount only the designated workspace folder (bind‑mount with explicit read/write flags).
  • Enforce outbound allow‑list (no internet by default).
  • Store API keys on host; inject via egress broker.
  • Checkpoint before risky steps; rewind on failure.

04How kosa8 builds the guardrails

kosa8 provides the sealed microVM model described above, giving every agent its own kernel and a single visible folder. Network traffic is blocked unless you add an allow rule with kosa8 sandbox create sealed --egress-allow api.anthropic.com. The platform’s egress broker holds real API keys on the host, so the sandbox never sees them, matching the need for secret protection.

A checkpoint can be taken with kosa8 checkpoint sealed --label "before the risky bit" and reversed with kosa8 rewind sealed. Forking (kosa8 fork api -n 8) lets you explore multiple analysis approaches in parallel, keeping only the successful fork, while the original remains untouched. Every action—whether a file write or a network request—is logged to a hash‑chained audit trail that can be verified with kosa8 audit verify.

05Monday‑morning actions for the CISO

Review each AI‑agent deployment and map its intended workspace. Create a sealed sandbox for it with a single bind‑mount, using the kosa8 sandbox create sealed command and specifying the folder path.

Compile an outbound allow‑list that includes only internal FHIR endpoints and the approved model vendor. Add the rule to the sandbox configuration and reject all other destinations.

Before any agent runs a new library or script, take a checkpoint. Label the snapshot so you can trace which version introduced an issue, then test the change in an 8‑fork experiment. If something goes wrong, invoke rewind and verify the audit log.

Schedule a weekly run of kosa8 audit verify across all agent sandboxes. Review the tamper‑evident log for any unexpected human‑marked actions and enforce the two‑person rule for any operation that modifies patient‑record schemas.

Takeaways

  1. Create a sealed sandbox per agent with a single bound workspace.
  2. Enforce an outbound allow‑list and keep secrets on the host.
  3. Checkpoint before any risky library install; rewind on failure.
  4. Verify the audit log daily with the built‑in verification command.
  5. Use 8‑fork parallel testing to evaluate new analysis pipelines safely.

Where kosa8 fits

kosa8 delivers sealed microVMs that give each AI agent its own kernel and a single visible workspace folder, while the host‑level network is locked down to an explicit allow‑list. API secrets remain on the host and are injected only at egress, eliminating key exposure inside the sandbox. Checkpoint and rewind let you snapshot an entire machine in about 0.7 seconds and restore it quickly, and every action is recorded in a hash‑chained audit log that can be verified with a single command.

Check yourself · +100 XP

Which control stops an AI agent from unintentionally sending PHI to an external service?

Questions people ask

How can I ensure AI agents do not access unauthorized patient records?

Run each agent in a sealed microVM with a single bind‑mounted workspace. The sandbox sees no other files on the host, preventing cross‑record access.

What helps me prove that an AI‑generated note was not altered after creation?

Every write is logged in a hash‑chained audit trail. You can run the verification command to confirm the log’s integrity and see which entity performed each action.

How this was written

Part of the kosa8 industry series, written with Cloudflare Workers AI and checked automatically: every claim about kosa8 comes from our fact sheet, no statistics are invented, and frameworks are named, never "certified". kosa8 helps you build the controls and evidence they ask for; your assessor decides the rest. Spotted a mistake? Tell us.

kosa8 for Hospitals & pharma

Let your agents work. Keep the evidence.

Start a 14-day trial on one machine today, or talk to us about a pilot, air-gapped installs, a security review or procurement paperwork — a person answers.