By NHI Mgmt Group Editorial TeamBased on Cerbos: “Don't fetch that. A developer's guide to pre- vs. post-filtering for authorization” (June 26, 2025)

TL;DR: Centralised authorization only solves part of the problem if applications still fetch broad datasets and filter later, because post-filtering creates over-fetching, pagination drift, and brief in-memory exposure, according to Cerbos. Pre-filtering pushes authorization conditions into the query plan, making data access more efficient and safer by design.


At a glance

What this is: This is an analysis of pre-filtering versus post-filtering for authorization, and the key finding is that pushing policy into the query plan reduces exposure, improves pagination, and removes unnecessary data handling.

Why it matters: It matters because IAM and application security teams need authorization patterns that prevent excess access at retrieval time, not after sensitive data has already entered application memory.


Context

Authorization is only fully effective if the data path itself respects the decision. If an application fetches broad records first and filters them later, the policy layer may be correct while the retrieval pattern still creates avoidable exposure and operational friction.

Pre-filtering moves the authorization check into the query plan so the database returns only the records a user is allowed to see. That changes the control point from application memory to the data layer, which is where scale, pagination, and exposure risk are easiest to manage.


Key questions

Q: What breaks when authorization is done after data retrieval?

A: Post-fetch filtering wastes database and application resources, but the bigger issue is that it exposes data to the application before access is decided. That creates unnecessary blast radius and makes the authorization layer harder to scale. Query-time enforcement avoids reading records the user should never see.

Q: Why does pre-filtering reduce exposure in access-controlled applications?

A: Because the database only returns records that already match the policy conditions, unauthorized data never needs to pass through application memory. That lowers the attack surface, reduces bandwidth waste, and makes pagination predictable. The security gain comes from preventing excess data movement, not from post-hoc cleanup.

Q: When should teams use a hybrid pre-filter and verify pattern?

A: Use it when the application is high-security or mission-critical and a final policy check is worth the extra overhead. The hybrid pattern adds assurance against subtle misconfigurations or edge cases, but it should complement source-side filtering rather than replace it.

Q: How do access-control teams decide whether filtering belongs in the app or the query layer?

A: If the policy can be translated into row-level conditions, the query layer should enforce it first. The app should not fetch broad datasets only to discard most of them later, because that shifts the control point too late and creates avoidable exposure and scaling problems.


Technical breakdown

Why post-filtering creates over-fetching and pagination drift

Post-filtering means the application retrieves a broad result set and then removes unauthorized records after the fact. That seems simple in small systems, but it breaks down because pagination is computed before authorization is applied, so a page can contain fewer usable records than requested. The result is extra database load, wasted network transfer, and unstable user experience. More importantly, the application briefly handles data the user should never have received in the first place. In security terms, the control arrives too late to prevent unnecessary exposure.

Practical implication: Design access-controlled queries so the result set is already bounded before pagination is applied.

How pre-filtering uses query plans to enforce access at source

Pre-filtering asks the authorization service for conditions, not just an allow or deny decision. Those conditions are then translated into a database-native filter such as a SQL WHERE clause, so the database returns only authorized rows. Cerbos describes this as partial evaluation of policy, where an abstract syntax tree of rules is reduced to a queryable constraint. This is a different control pattern from post-filtering because the application never needs to inspect rows it should not see. The decisive benefit is that authorization becomes part of data retrieval, not a separate cleanup step.

Practical implication: Push authorization conditions into the data query layer wherever your policy engine can safely emit row-level filters.

Why a hybrid pre-filter and verify pattern exists

For high-security or mission-critical systems, the article proposes a hybrid pattern: pre-filter at the database and then verify the returned records again through the policy decision point before sending them onward. This is a belt-and-braces approach for cases where policy complexity, edge conditions, or implementation risk justify an extra gate. It does not replace pre-filtering, because the performance and exposure gains still come from source-side filtering. Instead, it adds a final assurance layer for environments where correctness and containment matter more than simplicity alone.

Practical implication: Use a second authorization check only where the risk of misconfiguration or policy edge cases justifies the extra control.


NHI Mgmt Group analysis

Pre-filtering changes authorization from a cleanup control into a prevention control. Post-filtering assumes it is acceptable for unauthorized data to enter application memory briefly, then be removed before delivery. That assumption is too weak for modern access-controlled systems, especially where row-level entitlements are large, dynamic, or sensitive. The practitioner implication is that retrieval architecture and authorization design have to be treated as one control surface, not two separate steps.

Pagination drift is a governance signal, not just a UX defect. When teams cannot reliably page over authorised data because filtering happens after retrieval, they are revealing that access enforcement sits too far from the source. That pattern also makes auditability weaker, because the system is handling more data than the user should ever have been eligible to request. Practitioners should treat unstable pagination as evidence that enforcement timing is wrong.

Source-side filtering is the more durable access-control pattern for data-intensive applications. It scales better because the database performs the work it was built to do, and it narrows the exposure window because unauthorized records never cross the application boundary. That makes the pattern relevant to broader authorization design, not only to one vendor’s implementation. Teams should prefer retrieval-time enforcement where policy can be translated into native data filters.

Pre-filtering and verification together define the modern row-level control model. The article’s hybrid pattern shows that source-side filtering and final policy verification are not mutually exclusive. The strategic point is that practitioners should stop treating post-filtering as the primary control and reserve it for validation, exception handling, or high-assurance confirmation. That rebalances responsibility toward the data layer while preserving final-check semantics where needed.

Authorization architecture now has to account for data movement, not just decision logic. Centralized policy services clean up the codebase, but they do not solve the exposure created when broad datasets are fetched before authorization is applied. The named concept here is the fetch-then-filter trap: the system remains logically authorised but operationally overexposed. Practitioners should design for where data sits, not only for whether a policy engine approved access.

What this signals

Fetch-then-filter is a control timing problem disguised as an implementation choice. The earlier the authorization condition is applied, the less opportunity there is for oversharing, unstable pagination, or application-layer exposure. For modern IAM and application teams, the design question is not whether policies exist, but whether they constrain retrieval before data moves.

Pre-filtering is the more defensible default for row-level authorization. It aligns the enforcement point with the data source and leaves the application to work only with authorised records. That is easier to reason about in audits, easier to scale under load, and safer in environments where data sensitivity varies record by record.


For practitioners

  • Shift row-level enforcement into the query plan Translate policy output into database-native filters so unauthorized rows are excluded before the application receives them. This reduces memory exposure, network load, and pagination errors in data-heavy workflows.
  • Reserve post-filtering for validation, not primary enforcement Use a second authorization check only as a final safety net for mission-critical paths, not as the main method for deciding which records to fetch.
  • Test pagination against authorized subsets Verify that page size, offsets, and result stability still behave correctly when authorization constraints are applied first. If pagination only works on the unfiltered dataset, the access model is too late in the flow.
  • Measure data exposure before application memory Review whether sensitive records are ever loaded into the service before being rejected. If they are, treat that as an architectural exposure point rather than an acceptable implementation detail.

Key takeaways

  • Post-filtering can leave applications handling data they should never have received, even when the final response is correct.
  • Pre-filtering reduces over-fetching, makes pagination deterministic, and keeps unauthorized records out of application memory.
  • The strongest pattern is to enforce authorization at retrieval time and reserve any later check for verification, not primary control.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP API Security Top 10 addresses the attack and risk surface, while NIST CSF 2.0, OWASP ASVS and CSA Cloud Controls Matrix set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP API Security Top 10API5 — Broken Function Level AuthorizationRow-level access decisions are being enforced through application-controlled retrieval logic.
Recommendation — Push authorization into the request path so the application never fetches records it should not expose.
NIST CSF 2.0PR.AA-05 — Access Permissions, Entitlements and AuthorizationsThe article is fundamentally about where authorization is applied in the data flow.
Recommendation — Align entitlement enforcement with data retrieval so only authorized records are returned.
OWASP ASVSV8 — AuthorizationThe post examines authorization enforcement and where it sits in the application stack.
Recommendation — Verify that authorization checks govern data access before the application processes sensitive records.
CSA Cloud Controls MatrixIAM — Identity and Access ManagementThe article addresses access enforcement patterns in cloud and data-driven application design.
Recommendation — Apply IAM controls so retrieval and authorization are enforced together at the data layer.

Key terms

  • Pre-Filtering: A data access pattern where authorization conditions are applied before the datastore returns rows. The query itself is constrained by policy, so the system only receives data the user can already see, reducing exposure and making paging more reliable.
  • Post-filter: A post-filter is a second-pass check applied after data has already been fetched from storage. It is sometimes necessary when the database cannot express every policy operator, but it weakens the trust boundary because unauthorized records may be read before final removal.
  • Partial evaluation: Partial evaluation precomputes stable parts of a policy so repeated decisions are faster at runtime. For autonomous or high-throughput enforcement points, it helps reduce latency without changing the policy logic, but it still requires careful testing to avoid hidden complexity.
  • Query planner: A query planner is the component that decides which order and direction to evaluate parts of an authorization request. In graph-based access control, it turns reachability into a cost-based routing problem, choosing paths that can reduce fan-out, short-circuit sooner, and limit unnecessary work.

Deepen your knowledge

NHI governance, agentic AI identity, and machine identity lifecycle are core topics in our NHI Foundation Level course, the industry's only accredited NHI security programme. If you are building or maturing an IAM programme, it is worth exploring.
NHIMG Editorial Note
Published by the NHIMG editorial team on June 12, 2026.
Updated on October 6, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org