Commit d9a22aa
committed
fix: enforce data isolation in server mode
In server mode, multiple users share one pgAdmin instance. Several
code paths loaded objects belonging to all users without filtering,
allowing cross-user information disclosure.
Changes:
- Add centralized get_accessible_server() and related helpers in
utils/server_access.py. Single-query check: owned OR shared OR
admin. Desktop mode bypasses (single user).
- Replace ~30 unscoped Server.query.filter_by(id=sid) callsites
across servers, sqleditor, schema_diff, erd, psql, import_export,
views, workspaces with get_accessible_server(sid) + None checks.
- Add access check in connection_manager() — the real security
boundary for ~50+ check_precondition-decorated endpoints.
- Scope ServerGroup.query.all() to current user + shared groups.
Add user check to ServerGroup.properties() and nodes(gid).
- Replace Server.shared listing patterns with get_user_server_query()
using proper shared server semantics.
- Add user_id to DebuggerFunctionArguments model + composite PK.
Alembic migration handles SQLite (recreate) and PostgreSQL
(add column, backfill from server owner, recreate PK).
SCHEMA_VERSION bumped to 50.
- Scope disconnect_from_all_servers(), delete_adhoc_servers(),
get_servers_with_saved_passwords() to current user. Guard
delete_adhoc_servers with has_request_context() for app startup.
- Add indexes: server(user_id), server(servergroup_id),
sharedserver(user_id), sharedserver(osid), servergroup(user_id).
- Fix old migration ca00ec32581b to use raw SQL instead of model
import (prevents breakage when model shape changes).1 parent d59fcf3 commit d9a22aa
17 files changed
Lines changed: 531 additions & 122 deletions
File tree
- web
- migrations/versions
- pgadmin
- browser/server_groups
- servers
- databases
- schemas/views
- misc/workspaces
- tools
- debugger
- erd
- import_export
- psql
- schema_diff
- sqleditor
- utils
- driver/psycopg3
Lines changed: 123 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
| |||
26 | 24 | | |
27 | 25 | | |
28 | 26 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
34 | 31 | | |
35 | 32 | | |
36 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
286 | 288 | | |
287 | 289 | | |
288 | 290 | | |
289 | | - | |
| 291 | + | |
290 | 292 | | |
291 | 293 | | |
292 | 294 | | |
| |||
296 | 298 | | |
297 | 299 | | |
298 | 300 | | |
299 | | - | |
| 301 | + | |
| 302 | + | |
300 | 303 | | |
301 | 304 | | |
302 | 305 | | |
| |||
373 | 376 | | |
374 | 377 | | |
375 | 378 | | |
376 | | - | |
377 | | - | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
378 | 382 | | |
379 | 383 | | |
380 | 384 | | |
| |||
383 | 387 | | |
384 | 388 | | |
385 | 389 | | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
395 | 398 | | |
396 | | - | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
397 | 402 | | |
398 | 403 | | |
399 | 404 | | |
| |||
421 | 426 | | |
422 | 427 | | |
423 | 428 | | |
424 | | - | |
| 429 | + | |
425 | 430 | | |
426 | 431 | | |
427 | 432 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
245 | 247 | | |
246 | 248 | | |
247 | 249 | | |
248 | | - | |
249 | | - | |
| 250 | + | |
250 | 251 | | |
251 | 252 | | |
252 | 253 | | |
| |||
560 | 561 | | |
561 | 562 | | |
562 | 563 | | |
563 | | - | |
564 | | - | |
565 | | - | |
| 564 | + | |
566 | 565 | | |
567 | 566 | | |
568 | 567 | | |
| |||
627 | 626 | | |
628 | 627 | | |
629 | 628 | | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
| 629 | + | |
636 | 630 | | |
637 | 631 | | |
638 | 632 | | |
639 | 633 | | |
640 | 634 | | |
641 | 635 | | |
642 | | - | |
643 | | - | |
644 | | - | |
645 | | - | |
| 636 | + | |
| 637 | + | |
646 | 638 | | |
647 | 639 | | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
648 | 645 | | |
649 | 646 | | |
650 | 647 | | |
| |||
754 | 751 | | |
755 | 752 | | |
756 | 753 | | |
757 | | - | |
| 754 | + | |
758 | 755 | | |
759 | 756 | | |
760 | 757 | | |
| |||
956 | 953 | | |
957 | 954 | | |
958 | 955 | | |
959 | | - | |
960 | | - | |
| 956 | + | |
961 | 957 | | |
962 | 958 | | |
963 | | - | |
964 | | - | |
965 | | - | |
| 959 | + | |
966 | 960 | | |
967 | 961 | | |
968 | 962 | | |
| |||
1002 | 996 | | |
1003 | 997 | | |
1004 | 998 | | |
1005 | | - | |
1006 | | - | |
| 999 | + | |
1007 | 1000 | | |
1008 | 1001 | | |
1009 | 1002 | | |
| |||
1395 | 1388 | | |
1396 | 1389 | | |
1397 | 1390 | | |
1398 | | - | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
1399 | 1397 | | |
1400 | 1398 | | |
1401 | 1399 | | |
| |||
1464 | 1462 | | |
1465 | 1463 | | |
1466 | 1464 | | |
1467 | | - | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
1468 | 1469 | | |
1469 | 1470 | | |
1470 | 1471 | | |
| |||
1474 | 1475 | | |
1475 | 1476 | | |
1476 | 1477 | | |
1477 | | - | |
1478 | | - | |
1479 | 1478 | | |
1480 | 1479 | | |
1481 | 1480 | | |
| |||
1693 | 1692 | | |
1694 | 1693 | | |
1695 | 1694 | | |
1696 | | - | |
| 1695 | + | |
1697 | 1696 | | |
1698 | 1697 | | |
1699 | 1698 | | |
| |||
1818 | 1817 | | |
1819 | 1818 | | |
1820 | 1819 | | |
1821 | | - | |
| 1820 | + | |
1822 | 1821 | | |
1823 | 1822 | | |
1824 | 1823 | | |
| |||
2108 | 2107 | | |
2109 | 2108 | | |
2110 | 2109 | | |
2111 | | - | |
| 2110 | + | |
2112 | 2111 | | |
2113 | 2112 | | |
2114 | 2113 | | |
| |||
2165 | 2164 | | |
2166 | 2165 | | |
2167 | 2166 | | |
2168 | | - | |
| 2167 | + | |
2169 | 2168 | | |
2170 | 2169 | | |
2171 | 2170 | | |
| |||
0 commit comments