Database-Level Security for AI Knowledge Bases

Security and permissions for a shared AI knowledge base must be enforced at the database level rather than by the personal AI agent.


Cole Medin, who builds and teaches systems for running AI assistants against shared knowledge bases, recently drew a hard line about where security has to live in those systems: in the database, not in the assistant.

His argument is about a setup that is becoming common in small companies and teams — a shared "second brain" where multiple people query company documents, notes, and records through their own personal AI agents. Each person has an assistant on their laptop or phone, and all of those assistants read from the same central store. The natural temptation, when you build this, is to let each agent decide what its owner is allowed to see. The agent checks permissions, then fetches data accordingly.

Medin's point is that this is backwards, because the agent is the one part of the system the user controls completely. A person who wants past a restriction doesn't need to hack anything. They can talk their own assistant into ignoring its rules — the technique known as prompt injection, where instructions in plain language override the system's intended behavior — or, if they have any technical ability, simply edit their local copy of the agent's code. The gatekeeper is on the wrong side of the door.

"The most important takeaway here, no matter how you build this system, is you need the gate to sit in the database. You cannot have this second brain, the personal part of the system, responsible for the security in any way cuz then it's going to be way too easy for the individual to get around it with, you know, sort of like prompt injection to their own agent or just changing their own agent's implementation."

The fix he describes is architectural rather than clever: the database itself refuses to return data the requester isn't entitled to, no matter what the agent asks for. In database terms this is usually called row-level security — the store checks the identity of whoever is asking and filters results before anything leaves it. The assistant can be confused, manipulated, or rewritten entirely, and it still won't get back rows it shouldn't, because the database never sent them.

This is for a specific reader: if you lead a team or administer business data that several people now reach through AI assistants — client records, HR notes, financial documents, internal strategy — this is the question to put to whoever built or sold you the system. Where does the permission check happen? If the honest answer is "the agent checks," you have a polite suggestion system, not a security system. If you are a solo user with a personal knowledge base and no sensitive shared data, this mostly doesn't apply to you yet.

Is it usable today? The principle is, and Medin presents it as something he implements, not something he's speculating about. Databases with built-in row-level access controls exist and are widely used. What the quote does not cover is the harder practical side: wiring user identities from each agent into the database correctly, and keeping permissions in sync as people join, leave, and change roles. Saying "the gate sits in the database" is easy; building and maintaining that gate is real work, and it's worth being honest that the enforcement layer adds setup and ongoing administration that a casual shared-docs setup doesn't have.

There's also a limit worth naming plainly: database-level security protects against the agent as a weak point, but it doesn't address every other leak path — a user with legitimate access can still paste what they see into an email. The gate stops unauthorized retrieval, not authorized misuse. That's not a flaw in the idea; it's a reminder that "the database enforces it" is the necessary foundation, not the whole security story.

efficiencymemoryprivacyvideosecuritydeveloper
Source: youtube.com