Skip to content

Prevent possible search_path attacks#915

Open
knizhnik wants to merge 1 commit intoREL_16_STABLE_neonfrom
search_path_attack_v16
Open

Prevent possible search_path attacks#915
knizhnik wants to merge 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)

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.

1 participant