- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit4c9d96f
committed
Fix improper interactions between session_authorization and role.
The SQL spec mandates that SET SESSION AUTHORIZATION impliesSET ROLE NONE. We tried to implement that within the lowest-levelfunctions that manipulate these settings, but that was a bad idea.In particular, guc.c assumes that it doesn't matter in what orderit applies GUC variable updates, but that was not the case for thesetwo variables. This problem, compounded by some hackish attempts towork around it, led to some security-grade issues:* Rolling back a transaction that had done SET SESSION AUTHORIZATIONwould revert to SET ROLE NONE, even if that had not been the previousstate, so that the effective user ID might now be different from whatit had been.* The same for SET SESSION AUTHORIZATION in a function SET clause.* If a parallel worker inspected current_setting('role'), it saw"none" even when it should see something else.Also, although the parallel worker startup code intended to copewith the current role's pg_authid row having disappeared, itsimplementation of that was incomplete so it would still fail.Fix by fully separating the miscinit.c functions that assignsession_authorization from those that assign role. To implement thespec's requirement, teach set_config_option itself to perform "SETROLE NONE" when it sets session_authorization. (This is undoubtedlyugly, but the alternatives seem worse. In particular, there's no wayto do it within assign_session_authorization without incompatiblechanges in the API for GUC assign hooks.) Also, improveParallelWorkerMain to directly set all the relevant user-ID variablesinstead of relying on some of them to get set indirectly. Thatallows us to survive not finding the pg_authid row during workerstartup.In v16 and earlier, this includes back-patching9987a7b whichfixed a violation of GUC coding rules: SetSessionAuthorizationis not an appropriate place to be throwing errors from.Security:CVE-2024-109781 parent448525e commit4c9d96f
File tree
7 files changed
+341
-109
lines changed- src
- backend
- access/transam
- commands
- utils
- init
- misc
- include
- test/regress
- expected
- sql
7 files changed
+341
-109
lines changedLines changed: 27 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
81 | 81 |
| |
82 | 82 |
| |
83 | 83 |
| |
84 |
| - | |
| 84 | + | |
85 | 85 |
| |
| 86 | + | |
86 | 87 |
| |
87 | 88 |
| |
88 | 89 |
| |
89 |
| - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
90 | 93 |
| |
91 | 94 |
| |
92 | 95 |
| |
| |||
321 | 324 |
| |
322 | 325 |
| |
323 | 326 |
| |
| 327 | + | |
324 | 328 |
| |
325 |
| - | |
326 | 329 |
| |
| 330 | + | |
| 331 | + | |
| 332 | + | |
327 | 333 |
| |
328 | 334 |
| |
329 | 335 |
| |
| |||
1357 | 1363 |
| |
1358 | 1364 |
| |
1359 | 1365 |
| |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
1360 | 1378 |
| |
1361 | 1379 |
| |
1362 | 1380 |
| |
| |||
1422 | 1440 |
| |
1423 | 1441 |
| |
1424 | 1442 |
| |
1425 |
| - | |
1426 |
| - | |
1427 |
| - | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
1428 | 1449 |
| |
1429 |
| - | |
1430 |
| - | |
1431 |
| - | |
1432 | 1450 |
| |
1433 | 1451 |
| |
1434 | 1452 |
| |
|
Lines changed: 72 additions & 29 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
753 | 753 |
| |
754 | 754 |
| |
755 | 755 |
| |
756 |
| - | |
| 756 | + | |
757 | 757 |
| |
758 | 758 |
| |
759 |
| - | |
760 |
| - | |
761 |
| - | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
762 | 762 |
| |
763 |
| - | |
| 763 | + | |
| 764 | + | |
764 | 765 |
| |
765 |
| - | |
766 |
| - | |
767 |
| - | |
768 |
| - | |
| 766 | + | |
769 | 767 |
| |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
770 | 779 |
| |
771 | 780 |
| |
772 |
| - | |
| 781 | + | |
| 782 | + | |
773 | 783 |
| |
774 |
| - | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
775 | 788 |
| |
776 |
| - | |
777 |
| - | |
778 |
| - | |
779 |
| - | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
780 | 798 |
| |
781 |
| - | |
782 |
| - | |
783 |
| - | |
784 | 799 |
| |
785 |
| - | |
786 |
| - | |
787 |
| - | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
788 | 803 |
| |
789 |
| - | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
790 | 828 |
| |
791 | 829 |
| |
792 | 830 |
| |
| |||
836 | 874 |
| |
837 | 875 |
| |
838 | 876 |
| |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
839 | 887 |
| |
840 | 888 |
| |
841 | 889 |
| |
| |||
875 | 923 |
| |
876 | 924 |
| |
877 | 925 |
| |
878 |
| - | |
879 |
| - | |
880 |
| - | |
881 |
| - | |
882 |
| - | |
883 |
| - | |
884 |
| - | |
| 926 | + | |
| 927 | + | |
885 | 928 |
| |
886 | 929 |
| |
887 | 930 |
| |
|
0 commit comments
Comments
(0)