forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit98ca648
committed
Make contrib modules' installation scripts more secure.
Hostile objects located within the installation-time search_path couldcapture references in an extension's installation or upgrade script.If the extension is being installed with superuser privileges, thisopens the door to privilege escalation. While such hazards have existedall along, their urgency increases with the v13 "trusted extensions"feature, because that lets a non-superuser control the installation pathfor a superuser-privileged script. Therefore, make a number of changesto make such situations more secure:* Tweak the construction of the installation-time search_path to ensurethat references to objects in pg_catalog can't be subverted; andexplicitly add pg_temp to the end of the path to prevent attacks usingtemporary objects.* Disable check_function_bodies within installation/upgrade scripts,so that any security gaps in SQL-language or PL-language function bodiescannot create a risk of unwanted installation-time code execution.* Adjust lookup of type input/receive functions and join estimatorfunctions to complain if there are multiple candidate functions. Thisprevents capture of references to functions whose signature is not thefirst one checked; and it's arguably more user-friendly anyway.* Modify various contrib upgrade scripts to ensure that catalogmodification queries are executed with secure search paths. (Theseare in-place modifications with no extension version changes, sinceit is the update process itself that is at issue, not the end result.)Extensions that depend on other extensions cannot be made fully secureby these methods alone; therefore, revert the "trusted" marking thatcommiteb67623 applied to earthdistance and hstore_plperl, pendingsome better solution to that set of issues.Also add documentation around these issues, to help extension authorswrite secure installation scripts.Patch by me, following an observation by Andres Freund; thanksto Noah Misch for review.Security:CVE-2020-143501 parent378bd1e commit98ca648
File tree
24 files changed
+575
-159
lines changed- contrib
- btree_gist
- citext
- cube
- earthdistance
- hstore
- hstore_plperl
- intagg
- intarray
- ltree
- pg_trgm
- seg
- doc/src/sgml
- ref
- src/backend/commands
24 files changed
+575
-159
lines changedLines changed: 36 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
11 | 20 |
| |
12 | 21 |
| |
13 | 22 |
| |
14 | 23 |
| |
15 |
| - | |
| 24 | + | |
16 | 25 |
| |
17 | 26 |
| |
18 |
| - | |
| 27 | + | |
19 | 28 |
| |
20 | 29 |
| |
21 |
| - | |
| 30 | + | |
22 | 31 |
| |
23 | 32 |
| |
24 |
| - | |
| 33 | + | |
25 | 34 |
| |
26 | 35 |
| |
27 |
| - | |
| 36 | + | |
28 | 37 |
| |
29 | 38 |
| |
30 |
| - | |
| 39 | + | |
31 | 40 |
| |
32 | 41 |
| |
33 |
| - | |
| 42 | + | |
34 | 43 |
| |
35 | 44 |
| |
36 | 45 |
| |
37 |
| - | |
| 46 | + | |
38 | 47 |
| |
39 | 48 |
| |
40 |
| - | |
| 49 | + | |
41 | 50 |
| |
42 | 51 |
| |
43 |
| - | |
| 52 | + | |
44 | 53 |
| |
45 | 54 |
| |
46 |
| - | |
| 55 | + | |
47 | 56 |
| |
48 | 57 |
| |
49 |
| - | |
| 58 | + | |
50 | 59 |
| |
51 |
| - | |
| 60 | + | |
52 | 61 |
| |
53 |
| - | |
| 62 | + | |
54 | 63 |
| |
55 |
| - | |
| 64 | + | |
56 | 65 |
| |
57 |
| - | |
| 66 | + | |
58 | 67 |
| |
59 |
| - | |
| 68 | + | |
60 | 69 |
| |
61 |
| - | |
62 |
| - | |
63 |
| - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + |
Lines changed: 20 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
41 | 41 |
| |
42 | 42 |
| |
43 | 43 |
| |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
44 | 54 |
| |
45 |
| - | |
| 55 | + | |
46 | 56 |
| |
47 | 57 |
| |
48 |
| - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
49 | 62 |
| |
50 |
| - | |
51 |
| - | |
| 63 | + | |
| 64 | + | |
52 | 65 |
| |
53 |
| - | |
54 |
| - | |
| 66 | + | |
| 67 | + | |
| 68 | + |
Lines changed: 16 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
6 |
| - | |
7 |
| - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + |
Lines changed: 20 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
10 | 18 |
| |
11 | 19 |
| |
12 | 20 |
| |
13 | 21 |
| |
14 | 22 |
| |
15 |
| - | |
16 |
| - | |
17 |
| - | |
18 |
| - | |
19 |
| - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
20 | 35 |
| |
21 | 36 |
| |
22 | 37 |
| |
|
Lines changed: 19 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
15 | 24 |
| |
16 | 25 |
| |
17 | 26 |
| |
| |||
20 | 29 |
| |
21 | 30 |
| |
22 | 31 |
| |
23 |
| - | |
| 32 | + | |
24 | 33 |
| |
25 | 34 |
| |
26 | 35 |
| |
27 |
| - | |
28 |
| - | |
29 |
| - | |
30 |
| - | |
31 | 36 |
| |
32 | 37 |
| |
33 | 38 |
| |
| |||
36 | 41 |
| |
37 | 42 |
| |
38 | 43 |
| |
39 |
| - | |
| 44 | + | |
40 | 45 |
| |
41 | 46 |
| |
42 | 47 |
| |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
43 | 56 |
| |
44 | 57 |
| |
45 | 58 |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
31 | 31 |
| |
32 | 32 |
| |
33 | 33 |
| |
34 |
| - | |
| 34 | + | |
35 | 35 |
| |
36 | 36 |
| |
37 | 37 |
| |
|
Lines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
6 |
| - | |
7 | 6 |
|
Lines changed: 7 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
9 | 9 |
| |
10 | 10 |
| |
11 | 11 |
| |
12 |
| - | |
13 | 12 |
| |
14 |
| - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
15 | 16 |
| |
| 17 | + | |
| 18 | + | |
16 | 19 |
| |
17 | 20 |
| |
18 | 21 |
| |
| |||
27 | 30 |
| |
28 | 31 |
| |
29 | 32 |
| |
| 33 | + | |
30 | 34 |
| |
31 | 35 |
| |
32 | 36 |
| |
| |||
43 | 47 |
| |
44 | 48 |
| |
45 | 49 |
| |
| 50 | + | |
46 | 51 |
| |
47 | 52 |
| |
48 | 53 |
|
Lines changed: 25 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
10 | 18 |
| |
11 | 19 |
| |
12 | 20 |
| |
13 | 21 |
| |
14 | 22 |
| |
15 |
| - | |
16 |
| - | |
17 |
| - | |
18 |
| - | |
19 |
| - | |
20 |
| - | |
21 |
| - | |
22 |
| - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
23 | 34 |
| |
24 | 35 |
| |
25 |
| - | |
26 |
| - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
27 | 42 |
| |
28 | 43 |
| |
29 | 44 |
| |
|
Lines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
6 |
| - | |
7 | 6 |
|
Lines changed: 13 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6 | 6 |
| |
7 | 7 |
| |
8 | 8 |
| |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
9 | 17 |
| |
10 | 18 |
| |
11 |
| - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + |
0 commit comments
Comments
(0)