UGLYPEAR AI completes its business upgrade: High-Performance Document Compression × RAG Data Engineering PlatformLearn about the New Business →

Enforce Permissions When Results Are Assembled, Not When Data Is Stored

Here is a permission bug that passes every code review I have seen it in.

You store a document with a sensitivity label. You check the label when the document goes in. Everyone agrees the system is now "permission-aware." Then someone asks a question three steps removed from the obvious, and the answer they get lets them infer a passage they were never meant to see. The label did nothing, because it was applied at the wrong moment.

The general lesson: least-privilege is a retrieval-time property, not an ingestion-time one.

Why static labels fail

A static label answers a simple question — can this document be stored here, and who owns it. It does not answer the question that matters at query time: within this specific result, which parts may this person see.

Documents in the real world are mixed. One contract has commercial terms, personal data, and a privileged legal note. A single case file mixes public procedure with protected detail. Labeling the whole object at the container level is too coarse; it either hides too much or leaks too much.

The useful model narrows control to the content segment and applies it when results are assembled. Ask a question, and the system returns only the parts you are entitled to see — the restriction is enforced as the answer is built, not stamped on the file weeks earlier.

The adversarial test you should actually run

Nobody enjoys this test, because its entire purpose is to find your own weak spots. Run it anyway.

Take a passage the test user is not allowed to see. Then avoid asking for it directly. Ask an indirect question whose aggregated answer would still reveal it. A few examples of the shape of the attack:

  • Ask for a count or a summary that, combined with another figure, exposes the protected number.
  • Ask a comparative question where the protected segment is the only missing variable.
  • Ask the same question with paraphrasing and changed context, so a keyword-based restriction does not fire.

If your permission model was applied only at storage time, these slip through. If it is applied when the result is assembled, they do not. The distinction is not academic — it is exactly what an auditor is probing when they ask how you know permissions are enforced per content segment.

The principle here is broader than documents. Any system that returns computed results over protected inputs needs to enforce policy at the point of computation, not at the point of ingestion.

Three signals that make this measurable

A permission rule on paper is easy to write. Knowing it holds in practice takes signals a third party can reproduce:

  1. End-to-end latency — time from issuing a query to getting a result with its source attached. If a policy check is added at retrieval, does the system stay responsive?
  2. Failure isolation — in a batch, does one bad item get pinpointed without taking down the rest? Permission failures should behave like data failures: contained and locatable.
  3. Permission regression — after a rule changes, rerun a fixed corpus of "should see / should not see" cases. This is the check that catches the indirect-query hole before an auditor does.

These are standard industry practice, not the invention of any vendor. What they share is reproducibility — nobody has to take your word for it.

Why this matters more now

The context around search makes this urgent. McKinsey's research puts time spent searching for and gathering information at about 9.3 hours a week, roughly a fifth of the working week. Once a system can answer questions over your documents, the value is high — and so is the cost of an answer that includes what it should not.

IBM's 2025 breach-cost report adds the other half of the picture: the average incident runs to 4.44 million dollars, and 26% of breaches trace to human error. The most likely source of an over-broad answer is not an attacker. It is a legitimate user asking an ordinary question in a way your static label was never designed to handle.

The takeaway

If you are evaluating a system for sensitive documents, do not accept "we support permissions" as an answer. Ask when the permission is enforced. Ask to see a test where someone tries to infer a protected passage from an aggregate. Ask what happens to latency when that check runs live.

A design that enforces at retrieval time will answer all three. A design that stamps labels at ingestion will answer the first and hope you never ask the others.

Learn more about local-first handling at https://www.uglypear.com/, deployment options at https://www.uglypear.com/products/, and engineering notes at https://www.uglypear.com/blog/.

Try it now

  • https://www.uglypear.com/ — local-first document handling by design.
  • https://www.uglypear.com/products/ — deployment options that keep data inside the network.
  • https://www.uglypear.com/blog/ — more engineering notes on permissions and governance.

FAQ

Q: What is the difference between ingestion-time and retrieval-time permissions?
A: Ingestion-time permissions label data when it is stored. Retrieval-time permissions decide, as an answer is assembled, which parts the requester may see. Only the second holds up under indirect questions.

Q: Can an indirect question really expose a protected passage?
A: Yes. A count, a summary, or a comparison can reveal a protected value when combined with other available figures, even if nobody ever asks for the passage directly. Testing for this is a standard part of permission evaluation.

Q: How do you verify least-privilege is working?
A: Rerun a fixed set of "should see / should not see" cases after every rule change, including paraphrased and indirect versions. If a third party can reproduce the cases, you have evidence rather than a claim.