0

I was reading about possible security issues when creating functions in Postgres with "security definer". Official documentation suggests that search_path is set to some trusted schema followed by pg_temp. All examples I could find had pg_temp at the end. Do I have to put pg_temp at the end, what would happen if set search_path only to the trusted schema? Would it open any security holes? And why would you put pg_temp in search_path anyway?

1 Answer 1

2

pg_temp is always in the search path. If you don't add it to search_path parameter explicitly, it will behave as if it were there at the beginning of the setting. That means the user could create tables which masked the ones the function was supposed to operate on.

2
  • I have tried calling function which was in pg_temp but not in the trusted schema and got an error that function not found
    – Danil
    Mar 24, 2020 at 8:24
  • "However, the temporary schema is only searched for relation (table, view, sequence, etc)" I see
    – Danil
    Mar 24, 2020 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.