From: PG Doc comments form <noreply@postgresql.org>
To: pgsql-docs@lists.postgresql.org
Cc: cc@sse-ag.ch
Subject: Potential vuln in example for "F.25.1.1. digest()"
Date: Tue, 17 Aug 2021 16:11:53 +0000
Message-ID: <162921671324.1653.2466671901617491685@wrigleys.postgresql.org> (raw)
The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/13/pgcrypto.html
Description:
Hi,
in "F.25.1.1. digest()" you suggest:
CREATE OR REPLACE FUNCTION sha1(bytea) returns text AS $$
SELECT encode(digest($1, 'sha1'), 'hex')
$$ LANGUAGE SQL STRICT IMMUTABLE;
While this is a great example, it may expose a database app to
vulnerabilities if the attacker succeeds in overriding the function
sha1(...) in the app's user context (schema). This may or may not require
administrative privileges.
Explicitly putting it into the "postgres" schema and calling it using
"postgres.sha1(...)" could mitigate the risk in such a way that
administrative privileges are required.
Do you have an even better solution to secure it?
:-) Beat
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: noreply@postgresql.org, pgsql-docs@lists.postgresql.org, cc@sse-ag.ch
Subject: Re: Potential vuln in example for "F.25.1.1. digest()"
In-Reply-To: <162921671324.1653.2466671901617491685@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox