{"schema": "pgtrue.report/1", "url": "https://pgtrue.postgres.ai/shared/brief/aab2a118-9c43-480c-86e7-7198d55a075c", "published": "2026-10-21T05:28:57Z", "publisher": "PostgresAI", "article": {"title": "Part 2/6 | Breaking the Postgres Superuser Guardrails: Attacking Security-Hardening Extensions |Systemic Risks in the Managed PostgreSQL Industry", "url": "https://mehmetince.net/part-2-6-breaking-the-superuser-guardrails-attacking-security-hardening-extensions-systemic-risks-in-the-managed-postgresql-industry", "date_published": "2026-09-23T01:05:18Z", "author": "Mehmet Ince", "publisher": "mehmetince.net"}, "grade": "A", "axes": [{"axis": "Factual", "summary": "A \u00b7 0 wrong of 12 checked \u00b7 0 caveats"}, {"axis": "Applicable", "summary": "A \u00b7 0 wrong of 7 checked \u00b7 0 caveats"}, {"axis": "Consistent", "summary": "A \u00b7 0 wrong of 12 checked \u00b7 0 caveats"}, {"axis": "Transparent", "summary": "A \u00b7 0 wrong of 4 checked \u00b7 0 caveats"}, {"axis": "Safe", "summary": "not applicable"}], "findings": [{"anchor": "F1", "url": "https://pgtrue.postgres.ai/shared/brief/aab2a118-9c43-480c-86e7-7198d55a075c#F1", "claim": "Core resolves the validator name to an OID and invokes that validator\u2026", "title": "Core resolves and invokes FDW validators during creation", "explanation": "PostgreSQL requires superuser status before creating a wrapper. CreateFdwStmt carries function options rather than resolved function OIDs. src/backend/commands/foreigncmds.c:521 resolves the validator name. Line 202 invokes it, including when options are empty. These checks support the stated execution window.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/foreigncmds.c#L450-L568", "label": "REL_18_6 \u00b7 src/backend/commands/foreigncmds.c:450-568"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/foreigncmds.c#L180-L206", "label": "REL_18_6 \u00b7 src/backend/commands/foreigncmds.c:180-206"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/foreigncmds.c#L569-L665", "label": "REL_18_6 \u00b7 src/backend/commands/foreigncmds.c:569-665"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/include/nodes/parsenodes.h#L2948-L2954", "label": "REL_18_6 \u00b7 src/include/nodes/parsenodes.h:2948-2954"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/include/catalog/pg_proc.h#L141-L141", "label": "REL_18_6 \u00b7 src/include/catalog/pg_proc.h:141-141"}]}, {"anchor": "F2", "url": "https://pgtrue.postgres.ai/shared/brief/aab2a118-9c43-480c-86e7-7198d55a075c#F2", "claim": "\u2026the same \"$user\" entry now represents the attacker-created postgres schema\u2026", "title": "The $user schema follows the effective current user", "explanation": "The $user entry expands using CURRENT_USER. doc/src/sgml/config.sgml:9773 documents this behavior. namespace.c derives the path using GetUserId() and resolves the matching schema. Under current_user postgres, an existing postgres schema can replace the original user's schema.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/catalog/namespace.c#L4110-L4160", "label": "REL_18_6 \u00b7 src/backend/catalog/namespace.c:4110-4160"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/config.sgml#L9771-L9778", "label": "REL_18_6 \u00b7 doc/src/sgml/config.sgml:9771-9778"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/catalog/namespace.c#L4298-L4354", "label": "REL_18_6 \u00b7 src/backend/catalog/namespace.c:4298-4354"}]}, {"anchor": "F3", "url": "https://pgtrue.postgres.ai/shared/brief/aab2a118-9c43-480c-86e7-7198d55a075c#F3", "claim": "Roles and schemas are separate PostgreSQL objects\u2026", "title": "A schema name does not select its owner role", "explanation": "CREATE SCHEMA treats its name and authorization role separately. src/backend/commands/schemacmds.c:73 selects the explicit authorization role or the current user. Naming a schema postgres does not assign ownership to the postgres role.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/schemacmds.c#L69-L78", "label": "REL_18_6 \u00b7 src/backend/commands/schemacmds.c:69-78"}]}, {"anchor": "F4", "url": "https://pgtrue.postgres.ai/shared/brief/aab2a118-9c43-480c-86e7-7198d55a075c#F4", "claim": "The lo_export() function takes those bytes and writes them to a chosen filesystem path.", "title": "lo_export writes large-object bytes to the server filesystem", "explanation": "lo_export opens the requested server path and writes bytes from the large object. src/backend/libpq/be-fsstubs.c:532 reads object chunks and passes them to write(). The function provides a file-write primitive within server filesystem permissions.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/libpq/be-fsstubs.c#L480-L560", "label": "REL_18_6 \u00b7 src/backend/libpq/be-fsstubs.c:480-560"}]}, {"anchor": "F5", "url": "https://pgtrue.postgres.ai/shared/brief/aab2a118-9c43-480c-86e7-7198d55a075c#F5", "claim": "\u2026PostgreSQL stores the name of an internal function\u2019s implementation\u2026", "title": "Internal aliases resolve their implementation through pg_proc.prosrc", "explanation": "pg_proc.prosrc stores the implementation symbol for compiled functions. doc/src/sgml/catalogs.sgml:6290 documents the field. src/backend/utils/fmgr/fmgr.c:231 reads that symbol and resolves it through fmgr_lookupByName(). The SQL alias name can differ from the implementation symbol.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/catalogs.sgml#L6287-L6294", "label": "REL_18_6 \u00b7 doc/src/sgml/catalogs.sgml:6287-6294"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/fmgr/fmgr.c#L215-L252", "label": "REL_18_6 \u00b7 src/backend/utils/fmgr/fmgr.c:215-252"}]}, {"anchor": "F6", "url": "https://pgtrue.postgres.ai/shared/brief/aab2a118-9c43-480c-86e7-7198d55a075c#F6", "claim": "\u2026access its methods via LANGUAGE C.", "title": "LANGUAGE C loads functions from shared libraries", "explanation": "LANGUAGE C resolves a library filename and exported symbol. src/backend/utils/fmgr/fmgr.c:386 passes those values to load_external_function(). This supports the stated loading step when permissions, binary compatibility, and library validation permit it.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/fmgr/fmgr.c#L349-L430", "label": "REL_18_6 \u00b7 src/backend/utils/fmgr/fmgr.c:349-430"}]}, {"anchor": "F7", "url": "https://pgtrue.postgres.ai/shared/brief/aab2a118-9c43-480c-86e7-7198d55a075c#F7", "claim": "\u2026postgres_fdw_validator is the built-in option validation function\u2026", "title": "postgres_fdw installs postgres_fdw_validator as its validator", "explanation": "postgres_fdw supplies postgres_fdw_validator(text[], oid). contrib/postgres_fdw/postgres_fdw--1.0.sql:16 installs the wrapper with that function as its VALIDATOR.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/postgres_fdw/postgres_fdw--1.0.sql#L6-L18", "label": "REL_18_6 \u00b7 contrib/postgres_fdw/postgres_fdw--1.0.sql:6-18"}]}, {"anchor": "F8", "url": "https://pgtrue.postgres.ai/shared/brief/aab2a118-9c43-480c-86e7-7198d55a075c#F8", "claim": "The COPY TO/FROM PROGRAM.", "title": "COPY PROGRAM executes commands on the database server", "explanation": "COPY PROGRAM executes a command under the database server's operating-system identity. doc/src/sgml/ref/copy.sgml:566 documents server-side execution. src/backend/commands/copy.c:81 checks pg_execute_server_program privileges before allowing that operation.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ref/copy.sgml#L563-L582", "label": "REL_18_6 \u00b7 doc/src/sgml/ref/copy.sgml:563-582"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/copy.c#L70-L95", "label": "REL_18_6 \u00b7 src/backend/commands/copy.c:70-95"}]}, {"anchor": "F9", "url": "https://pgtrue.postgres.ai/shared/brief/aab2a118-9c43-480c-86e7-7198d55a075c#F9", "claim": "\u2026access and query data stored in external data sources as if they were native Postgres tables\u2026", "title": "The FDW definition matches its cited documentation", "explanation": "FDWs expose external data through PostgreSQL tables. The cited Wrappers overview uses the same definition.", "verdict": "Accurate", "sources": [{"url": "https://supabase.com/docs/guides/database/extensions/wrappers/overview", "label": "https://supabase.com/docs/guides/database/extensions/wrappers/overview"}]}, {"anchor": "F10", "url": "https://pgtrue.postgres.ai/shared/brief/aab2a118-9c43-480c-86e7-7198d55a075c#F10", "claim": "\u2026Aiven has aiven_extras extension\u2026", "title": "Aiven documents the aiven_extras extension", "explanation": "Aiven documents aiven_extras and its superuser-like administrative functions for avnadmin. This confirms the extension name and delegation purpose.", "verdict": "Accurate", "sources": [{"url": "https://aiven.io/docs/products/postgresql/concepts/dba-tasks-pg", "label": "https://aiven.io/docs/products/postgresql/concepts/dba-tasks-pg"}]}, {"anchor": "F11", "url": "https://pgtrue.postgres.ai/shared/brief/aab2a118-9c43-480c-86e7-7198d55a075c#F11", "claim": "\u2026PlanetScale has pg_pscale_utils\u2026", "title": "PlanetScale documents pg_pscale_utils", "explanation": "PlanetScale lists pg_pscale_utils as its utility extension for handling superuser actions.", "verdict": "Accurate", "sources": [{"url": "https://planetscale.com/docs/postgres/extensions", "label": "https://planetscale.com/docs/postgres/extensions"}]}, {"anchor": "F13", "url": "https://pgtrue.postgres.ai/shared/brief/aab2a118-9c43-480c-86e7-7198d55a075c#F13", "claim": "It is normally allows only a superuser to run CREATE FOREIGN DATA WRAPPER\u2026", "title": "CREATE FOREIGN DATA WRAPPER requires superuser privileges", "explanation": "PostgreSQL 18.6 documents that only superusers can create foreign-data wrappers. See doc/src/sgml/ref/create_foreign_data_wrapper.sgml:45.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ref/create_foreign_data_wrapper.sgml#L35-L85", "label": "REL_18_6 \u00b7 doc/src/sgml/ref/create_foreign_data_wrapper.sgml:35-85"}]}]}