forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitcfa928f
committed
Plug RLS related information leak in pg_stats view.
The pg_stats view is supposed to be restricted to only show rowsabout tables the user can read. However, it sometimes can leakinformation which could not otherwise be seen when row level securityis enabled. Fix that by not showing pg_stats rows to users that wouldbe subject to RLS on the table the row is related to. This is doneby creating/using the newly introduced SQL visible function,row_security_active().Along the way, clean up three call sites of check_enable_rls(). The secondargument of that function should only be specified as other thanInvalidOid when we are checking as a different user than the current one,as in when querying through a view. These sites were passing GetUserId()instead of InvalidOid, which can cause the function to return incorrectresults if the current user has the BYPASSRLS privilege and row_securityhas been set to OFF.Additionally fix a bug causing RI Trigger error messages to unintentionallyleak information when RLS is enabled, and other minor cleanup andimprovements. Also add WITH (security_barrier) to the definition of pg_stats.Bumped CATVERSION due to new SQL functions and pg_stats view definition.Back-patch to 9.5 where RLS was introduced. Reported by Yaroslav.Patch by Joe Conway and Dean Rasheed with review and input byMichael Paquier and Stephen Frost.1 parent6087d95 commitcfa928f
File tree
16 files changed
+159
-31
lines changed- doc/src/sgml
- src
- backend
- access/index
- catalog
- executor
- rewrite
- utils
- adt
- cache
- init
- misc
- include
- catalog
- utils
- test/regress
- expected
- sql
16 files changed
+159
-31
lines changedLines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15244 | 15244 |
| |
15245 | 15245 |
| |
15246 | 15246 |
| |
| 15247 | + | |
| 15248 | + | |
| 15249 | + | |
| 15250 | + | |
| 15251 | + | |
| 15252 | + | |
15247 | 15253 |
| |
15248 | 15254 |
| |
15249 | 15255 |
| |
| |||
15284 | 15290 |
| |
15285 | 15291 |
| |
15286 | 15292 |
| |
| 15293 | + | |
| 15294 | + | |
| 15295 | + | |
15287 | 15296 |
| |
15288 | 15297 |
| |
15289 | 15298 |
| |
| |||
15447 | 15456 |
| |
15448 | 15457 |
| |
15449 | 15458 |
| |
| 15459 | + | |
| 15460 | + | |
| 15461 | + | |
| 15462 | + | |
| 15463 | + | |
| 15464 | + | |
| 15465 | + | |
15450 | 15466 |
| |
15451 | 15467 |
| |
15452 | 15468 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
204 | 204 |
| |
205 | 205 |
| |
206 | 206 |
| |
207 |
| - | |
| 207 | + | |
208 | 208 |
| |
209 | 209 |
| |
210 | 210 |
| |
|
Lines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
150 | 150 |
| |
151 | 151 |
| |
152 | 152 |
| |
153 |
| - | |
| 153 | + | |
154 | 154 |
| |
155 | 155 |
| |
156 | 156 |
| |
| |||
211 | 211 |
| |
212 | 212 |
| |
213 | 213 |
| |
214 |
| - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
215 | 217 |
| |
216 | 218 |
| |
217 | 219 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1874 | 1874 |
| |
1875 | 1875 |
| |
1876 | 1876 |
| |
1877 |
| - | |
| 1877 | + | |
1878 | 1878 |
| |
1879 | 1879 |
| |
1880 | 1880 |
| |
|
Lines changed: 3 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
107 | 107 |
| |
108 | 108 |
| |
109 | 109 |
| |
110 |
| - | |
111 | 110 |
| |
112 | 111 |
| |
113 | 112 |
| |
| |||
117 | 116 |
| |
118 | 117 |
| |
119 | 118 |
| |
120 |
| - | |
121 |
| - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
122 | 122 |
| |
123 | 123 |
| |
124 | 124 |
| |
125 | 125 |
| |
126 |
| - | |
127 |
| - | |
128 |
| - | |
129 |
| - | |
130 |
| - | |
131 |
| - | |
132 |
| - | |
133 |
| - | |
134 |
| - | |
135 |
| - | |
136 | 126 |
| |
137 | 127 |
| |
138 | 128 |
| |
|
Lines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3243 | 3243 |
| |
3244 | 3244 |
| |
3245 | 3245 |
| |
3246 |
| - | |
| 3246 | + | |
3247 | 3247 |
| |
3248 | 3248 |
| |
3249 | 3249 |
| |
| |||
3264 | 3264 |
| |
3265 | 3265 |
| |
3266 | 3266 |
| |
| 3267 | + | |
| 3268 | + | |
3267 | 3269 |
| |
3268 | 3270 |
| |
3269 | 3271 |
| |
|
Lines changed: 1 addition & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
153 | 153 |
| |
154 | 154 |
| |
155 | 155 |
| |
156 |
| - | |
157 |
| - | |
158 | 156 |
| |
159 | 157 |
| |
160 | 158 |
| |
| |||
177 | 175 |
| |
178 | 176 |
| |
179 | 177 |
| |
180 |
| - | |
181 |
| - | |
182 | 178 |
| |
183 | 179 |
| |
184 | 180 |
| |
| |||
208 | 204 |
| |
209 | 205 |
| |
210 | 206 |
| |
211 |
| - | |
212 |
| - | |
| 207 | + | |
213 | 208 |
| |
214 | 209 |
| |
215 | 210 |
| |
|
Lines changed: 13 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
341 | 341 |
| |
342 | 342 |
| |
343 | 343 |
| |
344 |
| - | |
| 344 | + | |
345 | 345 |
| |
346 | 346 |
| |
347 | 347 |
| |
| |||
359 | 359 |
| |
360 | 360 |
| |
361 | 361 |
| |
| 362 | + | |
| 363 | + | |
| 364 | + | |
362 | 365 |
| |
363 | 366 |
| |
364 | 367 |
| |
| |||
401 | 404 |
| |
402 | 405 |
| |
403 | 406 |
| |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
404 | 416 |
| |
405 | 417 |
| |
406 | 418 |
| |
|
Lines changed: 52 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
16 | 16 |
| |
17 | 17 |
| |
18 | 18 |
| |
| 19 | + | |
19 | 20 |
| |
| 21 | + | |
20 | 22 |
| |
21 | 23 |
| |
| 24 | + | |
22 | 25 |
| |
23 | 26 |
| |
24 | 27 |
| |
| |||
37 | 40 |
| |
38 | 41 |
| |
39 | 42 |
| |
40 |
| - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
41 | 47 |
| |
42 | 48 |
| |
43 | 49 |
| |
| |||
53 | 59 |
| |
54 | 60 |
| |
55 | 61 |
| |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
56 | 73 |
| |
57 | 74 |
| |
58 | 75 |
| |
| |||
111 | 128 |
| |
112 | 129 |
| |
113 | 130 |
| |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + |
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
53 | 53 |
| |
54 | 54 |
| |
55 | 55 |
| |
56 |
| - | |
| 56 | + | |
57 | 57 |
| |
58 | 58 |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5337 | 5337 |
| |
5338 | 5338 |
| |
5339 | 5339 |
| |
| 5340 | + | |
| 5341 | + | |
| 5342 | + | |
| 5343 | + | |
| 5344 | + | |
| 5345 | + | |
5340 | 5346 |
| |
5341 | 5347 |
| |
5342 | 5348 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
305 | 305 |
| |
306 | 306 |
| |
307 | 307 |
| |
| 308 | + | |
308 | 309 |
| |
309 | 310 |
| |
310 | 311 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1120 | 1120 |
| |
1121 | 1121 |
| |
1122 | 1122 |
| |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
1123 | 1127 |
| |
1124 | 1128 |
| |
1125 | 1129 |
| |
|
Lines changed: 36 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
307 | 307 |
| |
308 | 308 |
| |
309 | 309 |
| |
310 |
| - | |
| 310 | + | |
311 | 311 |
| |
312 | 312 |
| |
313 | 313 |
| |
| |||
2886 | 2886 |
| |
2887 | 2887 |
| |
2888 | 2888 |
| |
| 2889 | + | |
| 2890 | + | |
| 2891 | + | |
| 2892 | + | |
| 2893 | + | |
| 2894 | + | |
| 2895 | + | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
2889 | 2923 |
| |
2890 | 2924 |
| |
2891 | 2925 |
| |
2892 | 2926 |
| |
2893 |
| - | |
| 2927 | + | |
2894 | 2928 |
| |
2895 | 2929 |
| |
2896 | 2930 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2061 | 2061 |
| |
2062 | 2062 |
| |
2063 | 2063 |
| |
2064 |
| - | |
| 2064 | + | |
2065 | 2065 |
| |
2066 | 2066 |
| |
2067 | 2067 |
| |
|
0 commit comments
Comments
(0)