Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit11da970

Browse files
committed
Empty search_path in logical replication apply worker and walsender.
This is likeCVE-2018-1058 commit582edc3. Today, a malicious user of apublisher or subscriber database can invoke arbitrary SQL functionsunder an identity running replication, often a superuser. This fix maycause "does not exist" or "no schema has been selected to create in"errors in a replication process. After upgrading, consider watchingserver logs for these errors. Objects accruing schema qualification inthe wake of the earlier commit are unlikely to need further correction.Back-patch to v10, which introduced logical replication.Security:CVE-2020-14349
1 parente078fb5 commit11da970

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

‎src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include"access/xlog.h"
2323
#include"catalog/pg_type.h"
24+
#include"common/connect.h"
2425
#include"funcapi.h"
2526
#include"libpq-fe.h"
2627
#include"mb/pg_wchar.h"
@@ -213,6 +214,22 @@ libpqrcv_connect(const char *conninfo, bool logical, const char *appname,
213214
returnNULL;
214215
}
215216

217+
if (logical)
218+
{
219+
PGresult*res;
220+
221+
res=libpqrcv_PQexec(conn->streamConn,
222+
ALWAYS_SECURE_SEARCH_PATH_SQL);
223+
if (PQresultStatus(res)!=PGRES_TUPLES_OK)
224+
{
225+
PQclear(res);
226+
ereport(ERROR,
227+
(errmsg("could not clear search path: %s",
228+
pchomp(PQerrorMessage(conn->streamConn)))));
229+
}
230+
PQclear(res);
231+
}
232+
216233
conn->logical=logical;
217234

218235
returnconn;

‎src/backend/replication/logical/worker.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,12 @@ ApplyWorkerMain(Datum main_arg)
20192019
MyLogicalRepWorker->userid,
20202020
0);
20212021

2022+
/*
2023+
* Set always-secure search path, so malicious users can't redirect user
2024+
* code (e.g. pg_index.indexprs).
2025+
*/
2026+
SetConfigOption("search_path","",PGC_SUSET,PGC_S_OVERRIDE);
2027+
20222028
/* Load the subscription into persistent memory context. */
20232029
ApplyContext=AllocSetContextCreate(TopMemoryContext,
20242030
"ApplyContext",

‎src/test/subscription/t/001_rep_changes.pl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
$node_subscriber->start;
1717

1818
# Create some preexisting content on publisher
19+
$node_publisher->safe_psql(
20+
'postgres',
21+
"CREATE FUNCTION public.pg_get_replica_identity_index(int)
22+
RETURNS regclass LANGUAGE sql AS 'SELECT 1/0'");# shall not call
1923
$node_publisher->safe_psql('postgres',
2024
"CREATE TABLE tab_notrep AS SELECT generate_series(1,10) AS a");
2125
$node_publisher->safe_psql('postgres',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp