PostgREST is a web server that exposes a PostgreSQL database as a REST API. It maps tables, views, functions and permissions into HTTP endpoints, so clients can read and write data through standard requests while database roles, row-level security and SQL privileges control what each caller can access.
How PostgREST Works
PostgREST turns a PostgreSQL database into an HTTP interface by projecting database objects into API resources. Tables and views become readable and writable endpoints, while functions can be exposed as callable routes, so the API surface is defined by the database schema rather than by a separate application layer.
This model is attractive because it reduces duplicate business logic and keeps one source of truth for data shape and permissions. It also means the database becomes the API boundary, so design choices in schema layout, naming, grants and query behaviour directly affect how clients interact with the system.
Permissions, Roles, and Row-Level Security
The defining security property of PostgREST is that access decisions come from PostgreSQL itself. Database roles, grants and row-level security determine which rows, tables and functions each caller can reach, so endpoint behaviour is only as strong as the underlying database policy model.
That makes fine-grained authorization a first-class design concern rather than an application afterthought. If row-level rules are consistent, clients can share the same API without seeing each other’s data. If they are incomplete or uneven, the API can unintentionally expose records, writable paths or function execution that the database was meant to restrict.
Because permission logic is expressed in SQL and catalog privileges, teams need a clear governance model for who owns roles, policy changes and function exposure. The advantage is tight coupling between data and access control; the trade-off is that mistakes in the database layer immediately become API security issues.
API Surface, Data Exposure, and Operational Fit
PostgREST is most useful where the database schema is already well structured and the service needs a predictable REST interface with minimal middleware. It fits reporting, internal platforms and data-centric applications especially well, because the API can be generated from tables, views and SQL functions without a large bespoke service layer.
The same simplicity can become a constraint when teams need complex orchestration, custom validation, or highly tailored business workflows. Since the exposed surface is schema-driven, changes to views, functions and permissions can alter what clients see as much as a code deploy would in a traditional API service.
For practitioners, that means API design, schema design and access design are inseparable. A clean endpoint catalog is not just a developer convenience, it is part of the security model and the operational contract with every client.
Failure Modes and Security Consequences
PostgREST inherits many of its risks from the database it exposes. Weak grants, overly broad roles, unsafe function exposure or missing row-level policies can turn a convenient REST wrapper into a direct path to sensitive records. Misconfiguration is therefore the main failure mode, not a flaw in the HTTP interface itself.
It also creates a strong dependency on database hygiene. If privileged roles, service credentials or SQL functions are reused too broadly, the blast radius can extend across every endpoint that maps to them. In practice, the API is only as trustworthy as the least controlled database object behind it.
Risk and Threat Considerations
Because PostgREST exposes the database directly, the main risk is that an authorization mistake in PostgreSQL becomes an application-level exposure. A small policy gap can reveal rows, permit unintended writes, or let callers invoke functions that were meant to stay internal.
Failure mechanism: Attackers or careless clients abuse permissive grants, weak row-level security, or exposed functions to reach data and actions beyond the intended API contract.
Impact: Sensitive data exposure, unauthorized modification, privilege expansion through database functions, and a larger blast radius if API-facing credentials are compromised.
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 SP 800-53 Rev 5, NIST CSF 2.0 and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP API Security Top 10 | API5 — Broken Function Level Authorization | PostgREST exposes SQL functions as API routes, so function-level authorization is materially central. |
| Recommendation — Restrict exposed functions to approved callers and verify every route has explicit authorization. | ||
| NIST SP 800-53 Rev 5 | AC-3 — Access Enforcement | PostgREST relies on database access rules to enforce who can read or write through the API. |
| IA-5 — Authenticator Management | The API boundary depends on managed database credentials and service authentication material. | |
| Recommendation — Enforce least-privilege database permissions for each exposed table, view and function. Rotate and protect database credentials used by PostgREST and downstream clients. | ||
| NIST CSF 2.0 | PR.AA-04 — Identity Management, Authentication and Access Control | PostgREST turns database roles and privileges into API access decisions that must be governed. |
| Recommendation — Align database roles and API exposure so each caller receives only intended access. | ||
| CIS Controls v8 | CIS-6 — Access Control Management | Database roles and endpoint exposure are access-control decisions that need centralized review. |
| Recommendation — Review database grants and revoke unneeded access paths to exposed data and functions. | ||
Practitioner Guidance
Governance implication: Treat PostgreSQL permissions as the source of API authorization truth. Ownership of roles, views, functions and row-level policies should be explicit, because the API layer will faithfully publish whatever the database allows.
What to watch for: Review every exposed function, every writable endpoint and every role that can bypass intended restrictions. In PostgREST deployments, the safest operating assumption is that a mis-scoped database privilege is already an API vulnerability.
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 3, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org