Skip to content

Prevent possible search_path attacks#915

Merged
knizhnik merged 1 commit intoREL_16_STABLE_neonfrom
search_path_attack_v16
Mar 17, 2026
Merged

Prevent possible search_path attacks#915
knizhnik merged 1 commit intoREL_16_STABLE_neonfrom
search_path_attack_v16

Conversation

@knizhnik
Copy link

Problem

See https://databricks.slack.com/archives/C092W8NBXC0/p1771421660357509?thread_ts=1771421653.582579&cid=C092W8NBXC0

We have discussed it many times:
https://databricks.slack.com/archives/C092W8NBXC0/p1769006207119519
last time at this Monday compute sync.
Still not quite clear to me if it is possible or not to prevent all such SECs but just by providing safe search_path.

Let me share my current vision of the problem.
Extensions quite often work with schema public and neon users are allows to create object in schema public . So user can always place some object in schema public which overrides (hides) standard function.

Since PostgreSQL 9.0+, functions are collected from all schemas in the path before resolution. This means adding a schema to search_path can introduce unexpected overload candidates that change which function gets called.

Solution

While selecting function candidates always prefer ones belonging to superuser
Always prepend pg_catalog to search_path (Postgres is doing it only if it is not explicitly include in search path)

Copy link

@mmeent-databricks mmeent-databricks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit, apart from that LGTM

@knizhnik knizhnik force-pushed the search_path_attack_v16 branch 2 times, most recently from 817fa04 to 8234b84 Compare March 16, 2026 20:19
@knizhnik knizhnik merged commit 8234b84 into REL_16_STABLE_neon Mar 17, 2026
1 check passed
@knizhnik knizhnik deleted the search_path_attack_v16 branch March 17, 2026 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants