- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit70396db
committed
Document security implications of search_path and the public schema.
The ability to create like-named objects in different schemas opens upthe potential for users to change the behavior of other users' queries,maliciously or accidentally. When you connect to a PostgreSQL server,you should remove from your search_path any schema for which a userother than yourself or superusers holds the CREATE privilege. If you donot, other users holding CREATE privilege can redefine the behavior ofyour commands, causing them to perform arbitrary SQL statements underyour identity. "SET search_path = ..." and "SELECTpg_catalog.set_config(...)" are not vulnerable to such hijacking, so onecan use either as the first command of a session. As specialexceptions, the following client applications behave as documentedregardless of search_path settings and schema privileges: clusterdbcreatedb createlang createuser dropdb droplang dropuser ecpg (notprograms it generates) initdb oid2name pg_archivecleanup pg_basebackuppg_config pg_controldata pg_ctl pg_dump pg_dumpall pg_isreadypg_receivewal pg_recvlogical pg_resetwal pg_restore pg_rewind pg_standbypg_test_fsync pg_test_timing pg_upgrade pg_waldump reindexdb vacuumdbvacuumlo. Not included are core client programs that run user-specifiedSQL commands, namely psql and pgbench. PostgreSQL encourages non-coreclient applications to do likewise.Document this in the context of libpq connections, psql connections,dblink connections, ECPG connections, extension packaging, and schemausage patterns. The principal defense for applications is "SELECTpg_catalog.set_config('search_path', '', false)", and the principaldefense for databases is "REVOKE CREATE ON SCHEMA public FROM PUBLIC".Either one is sufficient to prevent attack. After a REVOKE, considerauditing the public schema for objects named like pg_catalog objects.Authors of SECURITY DEFINER functions use some of the same defenses, andthe CREATE FUNCTION reference page already covered them thoroughly.This is a good opportunity to audit SECURITY DEFINER functions forrobust security practice.Back-patch to 9.3 (all supported versions).Reviewed by Michael Paquier and Jonathan S. Katz. Reported by ArseniySharoglazov.Security:CVE-2018-10581 parente170b8c commit70396db
File tree
19 files changed
+369
-101
lines changed- doc/src/sgml
- ref
- src/test/examples
19 files changed
+369
-101
lines changedLines changed: 7 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5987 | 5987 |
| |
5988 | 5988 |
| |
5989 | 5989 |
| |
| 5990 | + | |
| 5991 | + | |
| 5992 | + | |
| 5993 | + | |
| 5994 | + | |
| 5995 | + | |
| 5996 | + | |
5990 | 5997 |
| |
5991 | 5998 |
| |
5992 | 5999 |
| |
| |||
5997 | 6004 |
| |
5998 | 6005 |
| |
5999 | 6006 |
| |
6000 |
| - | |
6001 |
| - | |
6002 |
| - | |
6003 |
| - | |
6004 | 6007 |
| |
6005 | 6008 |
| |
6006 | 6009 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
75 | 75 |
| |
76 | 76 |
| |
77 | 77 |
| |
78 |
| - | |
| 78 | + | |
79 | 79 |
| |
80 | 80 |
| |
81 | 81 |
| |
|
Lines changed: 25 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
83 | 83 |
| |
84 | 84 |
| |
85 | 85 |
| |
86 |
| - | |
| 86 | + | |
87 | 87 |
| |
88 | 88 |
| |
89 | 89 |
| |
| |||
104 | 104 |
| |
105 | 105 |
| |
106 | 106 |
| |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
107 | 118 |
| |
108 | 119 |
| |
109 | 120 |
| |
| |||
121 | 132 |
| |
122 | 133 |
| |
123 | 134 |
| |
124 |
| - | |
| 135 | + | |
125 | 136 |
| |
126 | 137 |
| |
127 | 138 |
| |
128 | 139 |
| |
129 | 140 |
| |
130 |
| - | |
| 141 | + | |
131 | 142 |
| |
132 | 143 |
| |
133 | 144 |
| |
| |||
416 | 427 |
| |
417 | 428 |
| |
418 | 429 |
| |
419 |
| - | |
| 430 | + | |
| 431 | + | |
420 | 432 |
| |
421 | 433 |
| |
422 | 434 |
| |
| |||
450 | 462 |
| |
451 | 463 |
| |
452 | 464 |
| |
453 |
| - | |
| 465 | + | |
| 466 | + | |
454 | 467 |
| |
455 | 468 |
| |
456 | 469 |
| |
| |||
461 | 474 |
| |
462 | 475 |
| |
463 | 476 |
| |
464 |
| - | |
| 477 | + | |
| 478 | + | |
465 | 479 |
| |
466 | 480 |
| |
467 | 481 |
| |
| |||
479 | 493 |
| |
480 | 494 |
| |
481 | 495 |
| |
482 |
| - | |
| 496 | + | |
483 | 497 |
| |
484 | 498 |
| |
485 | 499 |
| |
| |||
503 | 517 |
| |
504 | 518 |
| |
505 | 519 |
| |
506 |
| - | |
| 520 | + | |
507 | 521 |
| |
508 | 522 |
| |
509 | 523 |
| |
| |||
778 | 792 |
| |
779 | 793 |
| |
780 | 794 |
| |
781 |
| - | |
| 795 | + | |
782 | 796 |
| |
783 | 797 |
| |
784 | 798 |
| |
| |||
899 | 913 |
| |
900 | 914 |
| |
901 | 915 |
| |
902 |
| - | |
| 916 | + | |
903 | 917 |
| |
904 | 918 |
| |
905 | 919 |
| |
| |||
1036 | 1050 |
| |
1037 | 1051 |
| |
1038 | 1052 |
| |
1039 |
| - | |
| 1053 | + | |
1040 | 1054 |
| |
1041 | 1055 |
| |
1042 | 1056 |
| |
|
Lines changed: 67 additions & 27 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2119 | 2119 |
| |
2120 | 2120 |
| |
2121 | 2121 |
| |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
2122 | 2136 |
| |
2123 | 2137 |
| |
2124 | 2138 |
| |
| |||
2235 | 2249 |
| |
2236 | 2250 |
| |
2237 | 2251 |
| |
2238 |
| - | |
2239 |
| - | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
2240 | 2255 |
| |
2241 | 2256 |
| |
2242 | 2257 |
| |
| |||
2286 | 2301 |
| |
2287 | 2302 |
| |
2288 | 2303 |
| |
2289 |
| - | |
2290 |
| - | |
2291 |
| - | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
2292 | 2307 |
| |
2293 | 2308 |
| |
| 2309 | + | |
| 2310 | + | |
2294 | 2311 |
| |
2295 |
| - | |
2296 |
| - | |
2297 |
| - | |
2298 |
| - | |
2299 |
| - | |
2300 |
| - | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
2301 | 2321 |
| |
2302 | 2322 |
| |
2303 | 2323 |
| |
2304 | 2324 |
| |
2305 | 2325 |
| |
2306 |
| - | |
2307 |
| - | |
2308 |
| - | |
2309 |
| - | |
2310 |
| - | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
2311 | 2335 |
| |
| 2336 | + | |
2312 | 2337 |
| |
| 2338 | + | |
2313 | 2339 |
| |
2314 |
| - | |
2315 |
| - | |
2316 |
| - | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
2317 | 2349 |
| |
2318 | 2350 |
| |
2319 | 2351 |
| |
2320 | 2352 |
| |
2321 | 2353 |
| |
2322 |
| - | |
2323 |
| - | |
2324 |
| - | |
2325 |
| - | |
2326 |
| - | |
2327 |
| - | |
2328 |
| - | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
2329 | 2360 |
| |
2330 | 2361 |
| |
2331 | 2362 |
| |
2332 | 2363 |
| |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
| 2372 | + | |
2333 | 2373 |
| |
2334 | 2374 |
| |
2335 | 2375 |
| |
| |||
2352 | 2392 |
| |
2353 | 2393 |
| |
2354 | 2394 |
| |
2355 |
| - | |
| 2395 | + | |
2356 | 2396 |
| |
2357 | 2397 |
| |
2358 | 2398 |
| |
|
0 commit comments
Comments
(0)