forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork0
Commita8fc37a
committed
Avoid using unsafe search_path settings during dump and restore.
Historically, pg_dump has "set search_path = foo, pg_catalog" whendumping an object in schema "foo", and has also caused that settingto be used while restoring the object. This is problematic becausefunctions and operators in schema "foo" could capture references meantto refer to pg_catalog entries, both in the queries issued by pg_dumpand those issued during the subsequent restore run. That couldresult in dump/restore misbehavior, or in privilege escalation if anefarious user installs trojan-horse functions or operators.This patch changes pg_dump so that it does not change the search_pathdynamically. The emitted restore script sets the search_path to whatwas used at dump time, and then leaves it alone thereafter. Createdobjects are placed in the correct schema, regardless of the activesearch_path, by dint of schema-qualifying their names in the CREATEcommands, as well as in subsequent ALTER and ALTER-like commands.Since this change requires a change in the behavior of pg_restorewhen processing an archive file made according to this new convention,bump the archive file version number; old versions of pg_restore willtherefore refuse to process files made with new versions of pg_dump.Security:CVE-2018-10581 parent7dd49bd commita8fc37a
File tree
12 files changed
+882
-1126
lines changed- src
- backend/utils/adt
- bin/pg_dump
- test/regress/expected
12 files changed
+882
-1126
lines changedLines changed: 35 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
80 | 80 |
| |
81 | 81 |
| |
82 | 82 |
| |
83 |
| - | |
84 |
| - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
85 | 86 |
| |
86 | 87 |
| |
87 | 88 |
| |
88 | 89 |
| |
89 |
| - | |
| 90 | + | |
90 | 91 |
| |
91 | 92 |
| |
| 93 | + | |
92 | 94 |
| |
93 | 95 |
| |
94 | 96 |
| |
| |||
472 | 474 |
| |
473 | 475 |
| |
474 | 476 |
| |
475 |
| - | |
| 477 | + | |
| 478 | + | |
476 | 479 |
| |
477 | 480 |
| |
478 | 481 |
| |
| |||
571 | 574 |
| |
572 | 575 |
| |
573 | 576 |
| |
574 |
| - | |
| 577 | + | |
| 578 | + | |
575 | 579 |
| |
576 | 580 |
| |
577 | 581 |
| |
| |||
584 | 588 |
| |
585 | 589 |
| |
586 | 590 |
| |
587 |
| - | |
| 591 | + | |
| 592 | + | |
588 | 593 |
| |
589 | 594 |
| |
590 | 595 |
| |
| |||
617 | 622 |
| |
618 | 623 |
| |
619 | 624 |
| |
620 |
| - | |
| 625 | + | |
621 | 626 |
| |
622 | 627 |
| |
623 | 628 |
| |
| |||
822 | 827 |
| |
823 | 828 |
| |
824 | 829 |
| |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
825 | 835 |
| |
826 |
| - | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
827 | 839 |
| |
828 | 840 |
| |
829 | 841 |
| |
| |||
896 | 908 |
| |
897 | 909 |
| |
898 | 910 |
| |
899 |
| - | |
| 911 | + | |
900 | 912 |
| |
901 | 913 |
| |
902 | 914 |
| |
| |||
977 | 989 |
| |
978 | 990 |
| |
979 | 991 |
| |
980 |
| - | |
| 992 | + | |
| 993 | + | |
981 | 994 |
| |
982 | 995 |
| |
983 | 996 |
| |
| |||
1002 | 1015 |
| |
1003 | 1016 |
| |
1004 | 1017 |
| |
1005 |
| - | |
| 1018 | + | |
| 1019 | + | |
1006 | 1020 |
| |
1007 | 1021 |
| |
1008 | 1022 |
| |
| |||
1123 | 1137 |
| |
1124 | 1138 |
| |
1125 | 1139 |
| |
1126 |
| - | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
1127 | 1143 |
| |
1128 | 1144 |
| |
1129 | 1145 |
| |
| |||
1315 | 1331 |
| |
1316 | 1332 |
| |
1317 | 1333 |
| |
1318 |
| - | |
| 1334 | + | |
| 1335 | + | |
1319 | 1336 |
| |
1320 | 1337 |
| |
1321 | 1338 |
| |
| |||
1744 | 1761 |
| |
1745 | 1762 |
| |
1746 | 1763 |
| |
1747 |
| - | |
| 1764 | + | |
1748 | 1765 |
| |
1749 | 1766 |
| |
1750 | 1767 |
| |
| |||
4161 | 4178 |
| |
4162 | 4179 |
| |
4163 | 4180 |
| |
4164 |
| - | |
| 4181 | + | |
| 4182 | + | |
| 4183 | + | |
| 4184 | + | |
4165 | 4185 |
| |
4166 | 4186 |
| |
4167 | 4187 |
| |
|
Lines changed: 58 additions & 24 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
718 | 718 |
| |
719 | 719 |
| |
720 | 720 |
| |
| 721 | + | |
721 | 722 |
| |
722 | 723 |
| |
723 | 724 |
| |
| |||
737 | 738 |
| |
738 | 739 |
| |
739 | 740 |
| |
740 |
| - | |
| 741 | + | |
741 | 742 |
| |
742 | 743 |
| |
743 | 744 |
| |
| |||
791 | 792 |
| |
792 | 793 |
| |
793 | 794 |
| |
794 |
| - | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
795 | 799 |
| |
796 | 800 |
| |
797 | 801 |
| |
| |||
839 | 843 |
| |
840 | 844 |
| |
841 | 845 |
| |
842 |
| - | |
843 |
| - | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
844 | 851 |
| |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
845 | 858 |
| |
846 |
| - | |
847 |
| - | |
848 |
| - | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
849 | 862 |
| |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
850 | 869 |
| |
851 |
| - | |
852 |
| - | |
853 |
| - | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
854 | 873 |
| |
855 | 874 |
| |
856 | 875 |
| |
| |||
865 | 884 |
| |
866 | 885 |
| |
867 | 886 |
| |
868 |
| - | |
869 |
| - | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
870 | 892 |
| |
871 | 893 |
| |
872 | 894 |
| |
| |||
878 | 900 |
| |
879 | 901 |
| |
880 | 902 |
| |
881 |
| - | |
882 |
| - | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
883 | 908 |
| |
884 | 909 |
| |
885 | 910 |
| |
| |||
906 | 931 |
| |
907 | 932 |
| |
908 | 933 |
| |
909 |
| - | |
910 |
| - | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
911 | 939 |
| |
912 | 940 |
| |
913 | 941 |
| |
| |||
958 | 986 |
| |
959 | 987 |
| |
960 | 988 |
| |
961 |
| - | |
| 989 | + | |
962 | 990 |
| |
963 | 991 |
| |
964 | 992 |
| |
| |||
1412 | 1440 |
| |
1413 | 1441 |
| |
1414 | 1442 |
| |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
1415 | 1447 |
| |
1416 | 1448 |
| |
1417 |
| - | |
| 1449 | + | |
1418 | 1450 |
| |
1419 | 1451 |
| |
1420 | 1452 |
| |
1421 | 1453 |
| |
1422 |
| - | |
1423 |
| - | |
| 1454 | + | |
| 1455 | + | |
1424 | 1456 |
| |
1425 | 1457 |
| |
1426 | 1458 |
| |
1427 | 1459 |
| |
1428 | 1460 |
| |
1429 |
| - | |
1430 |
| - | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
1431 | 1465 |
| |
1432 | 1466 |
| |
1433 | 1467 |
| |
1434 |
| - | |
| 1468 | + | |
1435 | 1469 |
| |
1436 | 1470 |
| |
1437 | 1471 |
| |
| |||
1443 | 1477 |
| |
1444 | 1478 |
| |
1445 | 1479 |
| |
1446 |
| - | |
| 1480 | + | |
1447 | 1481 |
| |
1448 | 1482 |
| |
1449 | 1483 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
87 | 87 |
| |
88 | 88 |
| |
89 | 89 |
| |
90 |
| - | |
| 90 | + | |
91 | 91 |
| |
92 | 92 |
| |
93 | 93 |
| |
| |||
101 | 101 |
| |
102 | 102 |
| |
103 | 103 |
| |
104 |
| - | |
| 104 | + | |
105 | 105 |
| |
106 |
| - | |
| 106 | + | |
107 | 107 |
| |
108 | 108 |
| |
109 | 109 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
185 | 185 |
| |
186 | 186 |
| |
187 | 187 |
| |
| 188 | + | |
| 189 | + | |
| 190 | + | |
188 | 191 |
| |
189 | 192 |
| |
190 | 193 |
| |
|
0 commit comments
Comments
(0)