Commit c028faf
committed
Fix mishandling of column-level SELECT privileges for join aliases.
scanNSItemForColumn, expandNSItemAttrs, and ExpandSingleTable would
pass the wrong RTE to markVarForSelectPriv when dealing with a join
ParseNamespaceItem: they'd pass the join RTE, when what we need to
mark is the base table that the join column came from. The end
result was to not fill the base table's selectedCols bitmap correctly,
resulting in an understatement of the set of columns that are read
by the query. The executor would still insist on there being at
least one selectable column; but with a correctly crafted query,
a user having SELECT privilege on just one column of a table would
nonetheless be allowed to read all its columns.
To fix, make markRTEForSelectPriv fetch the correct RTE for itself,
ignoring the possibly-mismatched RTE passed by the caller. Later,
we'll get rid of some now-unused RTE arguments, but that risks
API breaks so we won't do it in released branches.
This problem was introduced by commit 9ce77d7, so back-patch
to v13 where that came in. Thanks to Sven Klemm for reporting
the problem.
Security: CVE-2021-202291 parent 6214e2b commit c028faf
File tree
4 files changed
+93
-23
lines changed- src
- backend/parser
- test/regress
- expected
- sql
4 files changed
+93
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
660 | 660 | | |
661 | 661 | | |
662 | 662 | | |
663 | | - | |
664 | | - | |
| 663 | + | |
| 664 | + | |
665 | 665 | | |
666 | 666 | | |
667 | 667 | | |
| |||
990 | 990 | | |
991 | 991 | | |
992 | 992 | | |
993 | | - | |
| 993 | + | |
| 994 | + | |
994 | 995 | | |
995 | 996 | | |
996 | | - | |
997 | | - | |
998 | | - | |
999 | | - | |
1000 | | - | |
1001 | 997 | | |
1002 | 998 | | |
1003 | | - | |
1004 | | - | |
| 999 | + | |
1005 | 1000 | | |
1006 | | - | |
1007 | | - | |
| 1001 | + | |
1008 | 1002 | | |
1009 | 1003 | | |
1010 | 1004 | | |
| |||
1036 | 1030 | | |
1037 | 1031 | | |
1038 | 1032 | | |
1039 | | - | |
| 1033 | + | |
1040 | 1034 | | |
1041 | 1035 | | |
1042 | 1036 | | |
1043 | 1037 | | |
1044 | 1038 | | |
1045 | | - | |
| 1039 | + | |
1046 | 1040 | | |
1047 | 1041 | | |
1048 | 1042 | | |
| |||
1051 | 1045 | | |
1052 | 1046 | | |
1053 | 1047 | | |
1054 | | - | |
| 1048 | + | |
1055 | 1049 | | |
1056 | 1050 | | |
1057 | 1051 | | |
1058 | 1052 | | |
1059 | 1053 | | |
1060 | | - | |
| 1054 | + | |
1061 | 1055 | | |
1062 | 1056 | | |
1063 | 1057 | | |
| |||
1078 | 1072 | | |
1079 | 1073 | | |
1080 | 1074 | | |
1081 | | - | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
1082 | 1079 | | |
1083 | 1080 | | |
1084 | 1081 | | |
| |||
1089 | 1086 | | |
1090 | 1087 | | |
1091 | 1088 | | |
1092 | | - | |
| 1089 | + | |
1093 | 1090 | | |
1094 | 1091 | | |
1095 | 1092 | | |
| |||
3105 | 3102 | | |
3106 | 3103 | | |
3107 | 3104 | | |
3108 | | - | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
| 3108 | + | |
3109 | 3109 | | |
3110 | | - | |
| 3110 | + | |
| 3111 | + | |
3111 | 3112 | | |
3112 | 3113 | | |
3113 | 3114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1384 | 1384 | | |
1385 | 1385 | | |
1386 | 1386 | | |
1387 | | - | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
1388 | 1391 | | |
1389 | | - | |
| 1392 | + | |
| 1393 | + | |
1390 | 1394 | | |
1391 | 1395 | | |
1392 | 1396 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
479 | 483 | | |
480 | 484 | | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
481 | 527 | | |
482 | 528 | | |
483 | 529 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| 306 | + | |
| 307 | + | |
306 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
307 | 326 | | |
308 | 327 | | |
309 | 328 | | |
| |||
0 commit comments