Re: RFC: Additional Directory for Extensions - Mailing list pgsql-hackers
From | Christoph Berg |
---|---|
Subject | Re: RFC: Additional Directory for Extensions |
Date | |
Msg-id | Zg2H8y3O0K8I9mar@msg.df7cb.de Whole thread Raw |
In response to | Re: RFC: Additional Directory for Extensions ("David E. Wheeler" <david@justatheory.com>) |
Responses |
Re: RFC: Additional Directory for Extensions
Re: RFC: Additional Directory for Extensions |
List | pgsql-hackers |
Re: David E. Wheeler > > Yes, I like the suggestion to make it require a restart, which lets the sysadmin control it and not limited to whateverthe person who compiled it thought would make sense. > > Here’s a revision of the Debian patch that requires a server start. Thanks for bringing this up, I should have submitted this years ago. (The patch is originally from September 2020.) I designed the patch to require a superuser to set it, so it doesn't matter very much by which mechanism it gets updated. There should be little reason to vary it at run-time, so I'd be fine with requiring a restart, but otoh, why restrict the superuser from reloading it if they know what they are doing? > However, in studying the patch, it appears that the `extension_directory` is searched for *all* shared libraries, not justthose being loaded for an extension. Am I reading the `expand_dynamic_library_name()` function right? > > If so, this seems like a good way for a bad actor to muck with things, by putting an exploited libpgtypes library intothe extension directory, where it would be loaded in preference to the core libpgtypes library, if they couldn’t exploitthe original. > > I’m thinking it would be better to have the dynamic library lookup for extension libraries (and LOAD libraries?) separate,so that the `extension_directory` would not be used for core libraries. I'm not sure the concept of "core libraries" exists. PG happens to dlopen things at run time, and it doesn't know/care if they were installed by users or by the original PG server. Also, an exploited libpgtypes library is not worse than any other untrusted "user" library, so you really don't want to allow users to provide their own .so files, no matter by what mechanism. > This would also allow the lookup of extension libraries prefixed by the directory field from the control file, which wouldenable much tidier extension installation: The control file, SQL scripts, and DSOs could all be in a single directoryfor an extension. Nice idea, but that would mean installing .so files into PGSHAREDIR. Perhaps the whole extension stuff would have to move to PKGLIBDIR instead. Fwiw, I wrote this patch to solve the problem of testing extensions at build-time where the build process does not have write access to PGSHAREDIR. It solves that problem quite well, almost all PG extensions have build-time test coverage now (where there was basically 0 before). Security is not a concern at this point as everything is running as the same user, and the test cluster will be wiped right after the test. I figured marking the setting as "super user" only was enough security at that point, but I would recommend another audit before using it together with "trusted" extensions and other things in production. Christoph
pgsql-hackers by date: