Skip to content

Commit

Permalink
Require reset_user() when using set_user()
Browse files Browse the repository at this point in the history
When using a token to escalate using set_user(), the token was not
required for resetting to the original role.

pgaudit#22
  • Loading branch information
gitstashpop committed Feb 28, 2019
1 parent c7157eb commit 5a4677a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions set_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,27 @@ PU_hook(Node *parsetree, const char *queryString,
if ((strcmp(((VariableSetStmt *) parsetree)->name,
"log_statement") == 0) &&
Block_LS)
{
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("\"SET log_statement\" blocked by set_user config")));
}
else if ((strcmp(((VariableSetStmt *) parsetree)->name,
"role") == 0))
{
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("\"RESET role\" blocked by set_user config"),
errhint("\"Use `SELECT reset_user();` to reset role\"")));
}
else if ((strcmp(((VariableSetStmt *) parsetree)->name,
"user") == 0))
{
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("\"RESET user\" blocked by set_user config"),
errhint("\"Use `SELECT reset_user();` to reset user\"")));
}
break;
default:
break;
Expand Down

0 comments on commit 5a4677a

Please sign in to comment.