Join our Newsletter — 33% off our NHI Course
Home FAQ Cyber Security What is the difference between SQL-level access controls…
Cyber Security

What is the difference between SQL-level access controls and plugin-loaded code in PostgreSQL?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated September 6, 2026 Domain: Cyber Security

SQL-level access controls govern what a role can do through the database permission model, such as ACLs and row-level security. Plugin-loaded code is different because it runs inside the PostgreSQL process itself, outside the SQL executor. Once code is loaded this way, it can bypass normal permission checks and act with the trust of the server process.

SQL permissions and loaded code are enforced at different layers

SQL-level access controls govern what a role can do through PostgreSQL’s permission model, including object privileges, row-level security, and other checks applied by the SQL executor. Plugin-loaded code is different because it executes inside the PostgreSQL process itself, so it sits below those permission checks. That means the comparison is not really about “more or less access” in the same layer, but about whether trust is being enforced by SQL policy or by the server runtime.

That distinction matters because a database can be tightly locked down at the SQL layer and still be exposed if untrusted code is allowed to load into the backend process. In other words, SQL controls constrain what a session may request, while loaded code can change what the process can do once execution has crossed that boundary. For readers who assess database hardening, this is the difference between access mediation and process-level trust. In practice, many teams discover the gap only after a privileged extension or plugin has already been approved for deployment.

For background on how prescriptive security controls distinguish access enforcement from platform hardening, see CIS Controls v8.

What changes once code runs inside the PostgreSQL process

SQL-level controls still matter, but they are no longer the only protection boundary once plugin-loaded code is involved. A SQL statement is evaluated through the database engine’s normal authorization path, which can include ownership checks, grants, schema permissions, row filters, and other policy logic. Loaded code, by contrast, executes with the privileges and memory access of the backend process, so it can interact with internal server state in ways that ordinary SQL cannot.

That has practical consequences for both administration and assurance. If the code is trusted, it may legitimately extend the database with custom functions, types, or operational hooks. If it is not trusted, the risk is that the code can inspect data, alter execution flow, or misuse server capabilities without being constrained by the SQL permission model. The precise impact depends on what the code is allowed to do, but the security meaning is consistent: the trust boundary shifts from database policy to process trust.

  • SQL-level controls answer: “What may this role ask the database to do?”
  • Plugin-loaded code answers: “What may this process do once code is already executing inside it?”
  • The second question is broader because it can include actions that are not mediated by SQL permissions.
  • Security review therefore has to consider both the role model and the provenance of any loaded extension or plugin.

Where this guidance breaks down is when the question is not about runtime trust at all, but about purely administrative extension packaging or compile-time configuration, because those concerns shift the control point away from SQL enforcement and into software supply chain governance.

Trusted extension boundaries and the cases that blur them

Tighter control over loaded code often increases operational overhead, because teams must validate extension provenance, compatibility, and upgrade behaviour before they can rely on the software. The tradeoff is real: stricter approval reduces the chance that process-level trust is granted casually, but it can also slow feature delivery and maintenance.

There is also an important edge case. Some PostgreSQL extensions are widely used and operationally normal, but that does not make them equivalent to SQL permission checks. The practical question is whether the code executes with server trust, not whether the package is popular or whether it is installed through a standard administration path. An extension can be legitimate and still meaningfully expand the blast radius of compromise or misconfiguration.

For identity-heavy environments, the distinction also matters when database access is mediated through service accounts or automated workflows. The plugin still runs outside the normal SQL decision path, so granting a role fewer database privileges does not automatically reduce the risk introduced by code that executes in-process. Security teams should treat the trust decision as separate from the role decision, even when both are part of the same deployment workflow.

For a framework view of account and privilege discipline around this kind of boundary, the CIS Controls v8 guidance on controlled use of administrative access is the closest practical fit. Where organisations need stronger policy context for regulated environments, PCI DSS v4.0 is also relevant because it emphasises restricting access paths and controlling privileged software execution.

Risk and Threat Considerations

The main risk is privilege expansion through a trust boundary that sits below SQL authorisation. If untrusted or poorly reviewed plugin-loaded code is introduced, it can operate with the PostgreSQL backend’s effective trust and undermine the protection assumptions that row-level security, grants, and role separation are meant to provide.

Failure mechanism: The database engine correctly enforces SQL permissions for statements, but loaded code runs inside the process and can use internal execution context, server capabilities, or unsafe interfaces outside that mediation path. That makes the security outcome depend on code provenance and extension control rather than only on SQL policy.

Impact: A compromised or over-privileged extension can expose data, alter execution behaviour, widen access to sensitive objects, or create a persistence point that is harder to reason about than ordinary SQL abuse.

Standards & Framework Alignment

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

CIS Controls v8 and NIST CSF 2.0 set the technical controls, while PCI DSS v4.0 define the regulatory obligations.

FrameworkControl / ReferenceRelevance
CIS Controls v86 — Access Control ManagementDirectly addresses restricting and reviewing privileged access paths in database environments.
4 — Secure Configuration of Enterprise Assets and SoftwareLoaded plugins are part of software hardening and trusted configuration.
Recommendation — Enforce least-privilege access and review which code paths can run with server trust. Harden PostgreSQL by allowing only approved extensions and controlled software changes.
PCI DSS v4.02 — Secure Configurations for System ComponentsApplies where database software and extensions must be locked down as trusted components.
Recommendation — Restrict unapproved database components and verify trusted configuration before deployment.
NIST CSF 2.0PR.AC-4 — Access Permissions and AuthorizationsMaps to SQL-level authorization and role-based control enforcement.
PR.IP-1 — Configuration BaselineRelevant to controlling trusted database extensions and runtime configuration.
Recommendation — Enforce database permissions so roles can only perform approved actions. Baseline PostgreSQL configuration and permit only reviewed in-process code.

Practitioner Guidance

What to prioritise: Treat plugin trust as a separate control decision from SQL privilege design. If a team can only describe role grants but cannot explain why a loaded extension is safe to run inside the backend process, the control review is incomplete.

What to verify: Confirm which extensions or plugins are permitted, who approved them, how updates are reviewed, and whether the deployment model prevents informal loading of unvetted code. The key evidence is not just that the role is constrained, but that the in-process code path is intentionally governed.

Decision rule: If the security concern is “can this role query or modify data,” SQL controls are the right lens. If the concern is “can this code run with server trust,” the answer depends on extension governance, not on SQL permissions alone.

Practitioner takeaway: The dangerous shortcut is assuming least privilege at the SQL layer automatically contains anything that executes inside the database process; it does not.

Deepen Your Knowledge

Sign up to our weekly newsletter — get 33% off our NHI Foundation Level Course

    NHIMG Editorial Note
    Reviewed and updated by the NHIMG editorial team on September 6, 2026.
    NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org