【发布时间】:2018-04-17 12:28:05
【问题描述】:
我正在尝试在 Azure SQL Server 上配置 Dynamic Data Masking。
但是,尽管我应用了掩码,非特权用户仍然可以访问未掩码的数据,即使他们不应该拥有权限。作为健全性检查,我在 SQL Express 本地数据库安装上尝试了相同的设置,但没有遇到任何问题。
我正在使用以下脚本:
SELECT @@VERSION AS 'Current database version';
GO
--Create a table Cars with masked tables for License plates and the names of the owner.
CREATE TABLE Cars (
id int IDENTITY PRIMARY KEY,
LicensePlate nvarchar(20) MASKED WITH(FUNCTION = 'partial(1, "****", 1)') NOT NULL,
OwnerName nvarchar(40) MASKED WITH(FUNCTION = 'default()') NOT NULL
)
GO
-- Add some dummy queryable data
INSERT INTO Cars(LicensePlate, OwnerName)
VALUES ('AAA111', 'Alice'), ('BBB222', 'Bob'),
('CCC333', 'Carol'), ('ABC123', 'David'),
('XYZ987', 'Emily')
GO
-- Look at all the data in plain form(as admin user)
SELECT * FROM Cars
GO
-- Create a regular user who has no privileges
CREATE USER regular_user WITHOUT LOGIN
GRANT SELECT ON Cars TO regular_user;
--Execute the same select query as the regular user and see nothing
EXECUTE AS USER = 'regular_user'
SELECT * FROM Cars
REVERT
Azure 数据库上的结果:
本地数据库结果:
根据 Microsoft 的说法,该功能应该具有普遍可用性,并且 Azure 门户似乎采用了配置。但非特权用户只能在 Azure 的情况下继续查询未屏蔽的数据。
【问题讨论】: