背景
1、産品的問題點
2、問題點背後涉及的技術原理
- 任何使用者都可以檢視目前PG執行個體中有哪些使用者名、它們的權限、有哪些資料庫、有哪些表空間、有哪些權限設定等
postgres=> \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+---------------------
abc | Cannot login | {}
d | Cannot login | {}
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
ro | | {pg_read_all_data}
rw | | {pg_write_all_data}
postgres=> \db
List of tablespaces
Name | Owner | Location
------------+----------+----------
pg_default | postgres |
pg_global | postgres |
(2 rows)
postgres=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+---------+-------+-----------------------
postgres | postgres | UTF8 | C | en_US |
template0 | postgres | UTF8 | C | en_US | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C | en_US | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
postgres=> \dp+
Access privileges
Schema | Name | Type | Access privileges | Column privileges | Policies
--------+----------------+-------+---------------------------+-------------------+----------
public | a | table | | |
public | b | table | | |
public | c | table | | |
public | comments | table | | |
public | pg_buffercache | view | postgres=arwdDxt/postgres+| |
| | | pg_monitor=r/postgres | |
public | posts | table | | |
public | t | table | | |
(7 rows)
postgres=> \dx
List of installed extensions
Name | Version | Schema | Description
----------------+---------+------------+---------------------------------
pg_buffercache | 1.3 | public | examine the shared buffer cache
pgcrypto | 1.3 | public | cryptographic functions
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
roaringbitmap | 0.5 | public | support for Roaring Bitmaps
(4 rows)
3、這個問題将影響哪些行業以及業務場景
4、會導緻什麼問題?
- SaaS類業務, 一個資料庫執行個體可能給多個客戶使用, 每個客戶配置設定1個資料庫賬号, 給予1個私有資料庫. 但是它可以看到這個執行個體中還有哪些使用者、哪些資料庫, 雖然可以從權限上隔離DB之間的互相通路, 但是依舊可能在名字上洩露商業機密.
- DBaaS類業務, 與之類似.
5、業務上應該如何避免這個坑
- 每個使用者使用一個執行個體, 而不是通過執行個體中的 不同使用者 和 不同資料庫 來進行區分.
6、業務上避免這個坑犧牲了什麼, 會引入什麼新的問題
- 執行個體過多, 需要為每個執行個體配置設定獨立的記憶體, 比較浪費資源.
-
- 一個大執行個體中建立多個DB和USER可以更好的實作資源的共享, 充分利用資源, 同時能支援更好的彈性伸縮.
7、資料庫未來産品疊代如何修複這個坑
- 希望核心支援, 對普通使用者隐藏敏感的全局資料. 例如設計執行個體級全局使用者專門用來管理叢集, 其他的是普通超級使用者, 普通使用者