Re: Proposal: template-ify (binary) extensions - Mailing list pgsql-hackers
From | Dimitri Fontaine |
---|---|
Subject | Re: Proposal: template-ify (binary) extensions |
Date | |
Msg-id | m2vc46m8x6.fsf@2ndQuadrant.fr Whole thread Raw |
In response to | Re: Proposal: template-ify (binary) extensions (Markus Wanner <markus@bluegap.ch>) |
Responses |
Re: Proposal: template-ify (binary) extensions
|
List | pgsql-hackers |
Markus Wanner <markus@bluegap.ch> writes: >> - per-installation (not even per-cluster) DSO availability >> >> If you install PostGIS 1.5 on a system, then it's just impossible to >> bring another cluster (of the same PostgreSQL major version), let > On Debian, that should be well possible. Certainly installing Postgres > 9.1 w/ postgis-1.5 in parallel to Postgres 9.2 w/ postgis-2.0 is. I > designed it to be. > > I think I'm misunderstanding the problem statement, here. (of the same PostgreSQL major version) > Can CREATE EXTENSION check if the standbys have the extension installed? > And refuse creation, if they don't? No, because we don't register standbies so we don't know who they are, and also because some things that we see connected and using the replication protocol could well be pg_basebackup or pg_receivexlog. Also, it's possible that the standby is only there for High Availability purposes and runs no user query. > I'm sure you are aware that even without this clear separation of roles, > the guarantee means we provide an additional level of security against > attackers. Given lo_import() to upload a file from the client to the server then LOAD with the absolute path where the file ended up imported (or any untrusted PL really), this argument carries no sensible weight in my opinion. > None the less, the "safe by default" has served us well, I think. That's true. We need to consider carefully the proposal at hand though. It's all about allowing the backend to automatically load a file that it finds within its own $PGDATA so that we can have per-cluster and per-database modules (DSO files). The only difference with before is the location where the file is read from, and the main security danger comes from the fact that we used to only consider root-writable places and now propose to consider postgres bootstrap user writable places. Having the modules in different places in the system when it's a template and when it's instanciated allows us to solve a problem I forgot to list: - upgrading an extension at the OS level Once you've done that, any new backend will load the newer module (DSO file), so you have to be real quick if installingan hot fix in production and the SQL definition must be changed to match the new module version… With the ability to "instanciate" the module in a per-cluster per-database directory within $PGDATA the new version of the DSO module would only put in place and loaded at ALTER EXTENSION UPDATE time. I'm still ok with allowing to fix those problems only when a security option that defaults to 'false' has been switched to 'true', by the way, so that it's an opt-in, but I will admit having a hard time swallowing the threat model we're talking about… >> I don't think the relaxed behaviour we're talking about is currently >> possible to develop as an extension, by the way. > > It's extensions that undermine the guarantee, at the moment. But yeah, > it depends a lot on what kind of "relaxed behavior" you have in mind. The ability to load a module from another place than the current Dynamic_library_path is what we're talking about here, and IIUC Robert mentioned that maybe it could be down to an extension to allow for changing the behavior. I didn't look at that in details but I would be surprised to be able to tweak that without having to patch the backend. > If the sysadmin wants to disallow arbitrary execution of native code to > postgres (the process), any kind of embedded compiler likely is equally > unwelcome. You already mentioned untrusted PL languages, and I don't see any difference in between offering PL/pythonu and PL/C on security grounds, really. I don't think we would consider changing the current model of the "LANGUAGE C" PL, we would add a new "LANGUAGE PL/C" option, either untrusted or with a nice sandbox. The problem of sandboxing PL/C is that it makes it impossible to address such use cases as uuid or PostGIS extensions even if it still allows for hstore or other datatypes styles of extensions. Regards, -- Dimitri Fontaine http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
pgsql-hackers by date: