SlideShare a Scribd company logo
Data Redaction
Presented by:
Amul Sul
Principal Software Engineer, EDB
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.2
Welcome
• This webinar is being recorded.
• We will be sharing the slides and recording with you after the session.
• Please submit your questions via Zoom Q&A. All questions will be answered
at the end of the presentation.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.3
Agenda
Data Redaction
• Why & what Data Redaction ?
• What is EDB Data Redaction ?
• How to limit sensitive data exposure in EPAS ?
• Provision for the Oracle compatibility in EPAS ?
• Demo.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.4
Why & What Data Redaction ?
A technique that limits sensitive data exposure.
A GDPR (General Data Protection Regulation)-compliant implementation requires the use of many
technical capabilities, such as authentication, authorization, access control, virtual database, and
encryption.
One of the techniques often considered is data redaction to limits sensitive data exposure by
dynamically changing data as it is displayed for specific users.
Data redaction in EPAS version prior v11 and PostgreSQL -- See Creating a Data Redaction
Capability to Meet GDPR Requirements Using EDB Postgres blog, shows how we can use the
PostgreSQL search_path, user defined functions and views to add data redaction protection.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.5
What is EDB Data Redaction ?
Limits sensitive data exposure by dynamically changing data as it is displayed for specific users.
Data Policy Other User
Privileged User
Custom Data
Masking logic
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.6
What is EDB Data Redaction ?
Limits sensitive data exposure by dynamically changing data as it is displayed for specific users.
Policy
Name SSN
Sally Sample 020-78-9345
Jane Doe 123-33-9345
Emp Table Other
User
Privileged
User
Name SSN
Sally Sample xxx-xx-9345
Jane Doe xxx-xx-9345
Name SSN
Sally Sample 020-78-9345
Jane Doe 123-33-9345
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.7
How to limit sensitive data exposure in EPAS ?
Using Native Data Redaction Capability of EDB Postgres Advanced Server.
Redaction functionPolicy
Scope and exception options Policy expression
Redaction policies allow a user to
choose redaction behavior via
redaction function.
More than one redaction policy can
be created on the same table, but a
column can only be associated with
one policy.
Flexibility to choose when actual
redaction should apply and
exemptions on columns in the query
via the scope and exception options.
Boolean expression for the policy;
determines how the policy is to be
applied. The redaction occurs if this
policy expression is evaluated to TRUE.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.8
Policy
Create policy:
CREATE REDACTION POLICY name ON table_name
[ FOR ( expression ) ]
[ ADD column_name USING
redaction_function()
[ WITH OPTIONS ( redaction_options ) ] ]
[, … ];
Alter Policy:
ALTER REDACTION POLICY name ON table_name ...
➔Rename policy, enable or disable the policy
➔Change policy expression
➔Add more column or remove existing one
➔Change redaction_function and redaction_options
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.9
Policy
Create policy on emp table:
CREATE REDACTION POLICY emp_protect ON emp
ADD COLUMN ssn USING redact_ssn(ssn);
And the table description will be:
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.10
Redaction
function
CREATE FUNCTION redact_ssn (ssn varchar(11))
RETURNS varchar(11) AS
$$
SELECT overlay (ssn placing 'xxx-xx' from 1);
$$
LANGUAGE SQL;
Note : Return type of the redaction function should be same as the column type.
Policy
Other
User
Name SSN
Sally Sample xxx-xx-9345
Jane Doe xxx-xx-9345
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.11
Scope &
exception
options
Previously seen table description:
➢ SCOPE: Identified the query part where redaction to be applied
for the column.
○ Values: query, top_tlist, top_tlist_or_error.
➢ EXCEPTION: Identified the query part where redaction to be
exempted.
○ Values: none, equal, leakproof.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.12
Policy
expression
ALTER REDACTION POLICY emp_protect ON emp
FOR (SESSION_USER <> 'privileged_user');
OR
CREATE REDACTION POLICY emp_protect ON emp
FOR (SESSION_USER <> 'privileged_user')
ADD COLUMN ssn USING redact_ssn(ssn);
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.13
Oracle compatibility Provision in EPAS ?
DBMS_REDACT package
Redaction functionPolicy
Policy expression
Like Oracle, provides various
redaction type and supporting
functions.
DBMS_REDACT package provides
Oracle like procedure to add, alter,
enable, disable or drop the policy.
Same as the native support, the
redaction occurs if this policy
expression is evaluated to TRUE.
Scope and exception options
No provision, but user can use
native alter syntax to set scope and
exception.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.14
Policy
Create policy on emp table:
BEGIN
DBMS_REDACT.add_policy (
object_schema => 'public',
object_name => 'emp',
policy_name => 'emp_protect',
policy_description => 'policy for emp table ...',
column_name => 'ssn',
function_type => DBMS_REDACT.partial,
function_parameters => DBMS_REDACT.REDACT_US_SSN_F5,
expression => '1=1',
enable => true);
END;
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.15
Policy
Create policy on emp table:
BEGIN
DBMS_REDACT.add_policy (
object_schema => 'public',
object_name => 'emp',
policy_name => 'emp_protect',
policy_description => 'policy for emp table ...',
column_name => 'ssn',
function_type => DBMS_REDACT.partial,
function_parameters => DBMS_REDACT.REDACT_US_SSN_F5,
expression => '1=1',
enable => true);
END;
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.16
Function_type and Function_parameters:
BEGIN
DBMS_REDACT.add_policy (
object_schema => 'public',
object_name => 'emp',
policy_name => 'emp_protect',
policy_description => 'policy for emp table ...',
column_name => 'ssn',
function_type => DBMS_REDACT.partial,
function_parameters => DBMS_REDACT.REDACT_US_SSN_F5,
expression => '1=1',
enable => true);
END;
Redaction
function
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.17
Parameters: function_type
Redaction
function
NONE No redaction.
FULL Full redaction, redacts full values of the column data.
PARTIAL
Partial redaction, redacts a portion of the column data.
function_parameters needed.
RANDOM
Random redaction, each query results in a different random
value depending on the datatype of the column.
REGEXP
Regular Expression based redaction, searches for the
pattern of data to redact. regexp_pattern,
regexp_replace_string, regexp_position,
regexp_occurence, regexp_match_parameter
needed.
CUSTOM Custom redaction type.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.18
Parameters: function_parameters needed for PARTIAL type.
1. REDACT_US_SSN_F5
- Redacts the first 5 numbers of SSN.
- Example: The number 123-45-6789 becomes XXX-
XX-6789
1. REDACT_NA_PHONE_NUMBER
- Redacts the North American phone number by 0 leaving
the area code.
- Example: 1234567890 becomes 1230000000.
1. REDACT_DATE_MILLENNIUM
- Redacts a date that is in the DD-MM-YY format.
- Example: Redacts all date to 01-JAN-2000.
So on…
Partial redaction supports only Character, Number and Date types.
Redaction
function
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.19
Existing function_parameters constants not matching my
requirement, then?
Answer: No problem, you can use your function_parameters.
Here are the previously seen function_parameters constants for
Character, Number and Date type respectively and its internal
definition.
1. REDACT_US_SSN_F5 => 'VVVFVVFVVVV,VVV-VV-VVVV,X,1,5'
- input_fmt,output_fmt,mask_char,start,end
1. REDACT_NA_PHONE_NUMBER => '0,4,10'
- mask_digit,start,end
1. REDACT_DATE_MILLENNIUM => 'm1d1y2000'
- monthDigit,dayDigit,yearDigit
- You can replace hours, minutes and seconds too.
Redaction
function
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.20
Policy expression:
BEGIN
DBMS_REDACT.add_policy (
object_schema => 'public',
object_name => 'emp',
policy_name => 'emp_protect',
policy_description => 'policy for emp table ...',
column_name => 'ssn',
function_type => DBMS_REDACT.partial,
function_parameters => DBMS_REDACT.REDACT_US_SSN_F5,
expression => '1=1',
enable => true);
END;
Policy
expression
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.21
Alter
Policy
Action parameter of ALTER_POLICY() decides what
to alter:
1. Add column to the existing policy,
- action => ADD_COLUMN
1. Modify/Drop column redaction method,
- action => MODIFY_COLUMN
1. Modify policy expression,
- action => MODIFY_EXPRESSION
1. Set policy description, and
- action => SET_POLICY_DESCRIPTION
1. Set column description
- action => SET_COLUMN_DESCRIPTION
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.22
Alter
Policy
Alter policy to add another column:
BEGIN
DBMS_REDACT.alter_policy (
object_schema => 'public',
object_name => 'emp',
policy_name => 'emp_protect',
action =>
DBMS_REDACT.add_column,
column_name => 'salary',
function_type =>
DBMS_REDACT.full);
END;
e.g:
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.23
1. A sample data set with employee IDs, names, social security numbers, salary
etc. is created in the table employees in the mycompany database.
2. A data redaction policy for ssn and salary column will be applied whenever user other than
privilegeduser tries to access the employees table data
Demo
Step-by-step walkthrough for the complete demo:
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.24
Step 1: Create database
DROP DATABASE IF EXISTS mycompany;
CREATE DATABASE mycompany
WITH OWNER = enterprisedb;
Step 2: Connect to the new database
psql -d mycompany -U enterprisedb
psql (11.6.13)
Type "help" for help.
mycompany=>
Demo
A sample data set with employee IDs, names, social security numbers, salary etc. is created in the
table employees in the mycompany database.
Step 3: Create table
CREATE TABLE employees (
id SERIAL PRIMARY KEY,
name VARCHAR(40) NOT NULL,
SSN VARCHAR(11) NOT NULL,
salary MONEY);
Step 4: Add sample data
INSERT INTO employees (name, ssn, salary)
VALUES ('Sally Sample', '020-78-9345', 51234.34),
('Jane Doe', '123-33-9345', 62500.00),
('Bill Foo', '123-89-9345', 45350.00);
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.25
CREATE ROLE privilegeduser LOGIN PASSWORD 'password';
GRANT ALL ON employees TO privilegeduser;
CREATE ROLE non_privilegeduser LOGIN PASSWORD 'password';
GRANT ALL ON employees TO non_privilegeduser;
Demo
Create privileged and non-privileged user and grant the necessary access.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.26
BEGIN
DBMS_REDACT.add_policy (
object_schema => 'public',
object_name => 'employees',
policy_name => 'emp_data_protect',
policy_description => 'hide sensitive info of the
employees',
column_name => 'ssn',
function_type => DBMS_REDACT.partial,
function_parameters => 'VVVFVVFVVVV,VVV-VV-VVVV,#,1,5',
expression => 'SESSION_USER <>
''privilegeduser''',
enable => true);
END;
Demo
Create policy and on ssn and salary column for non-privileged users.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.27
BEGIN
DBMS_REDACT.alter_policy (
object_schema => 'public',
object_name => 'employees',
policy_name => 'emp_data_protect',
action => DBMS_REDACT.add_column,
column_name => 'salary',
function_type => DBMS_REDACT.full);
END;
Demo
Add salary column to emp_data_protect policy.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.28
mycompany=> c - privilegeduser
You are now connected to database "mycompany" as user "privilegeduser".
mycompany=> SELECT * FROM employees;
id | name | ssn | salary
----+--------------+-------------+------------
1 | Sally Sample | 020-78-9345 | $51,234.34
2 | Jane Doe | 123-33-9345 | $62,500.00
3 | Bill Foo | 123-89-9345 | $45,350.00
(3 rows)
Demo
By default table owner and super user can see un-redacted data.
Also, privilegeduser can see un-redacted data to whom we have exempted from the policy.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.29
mycompany=> c - non_privilegeduser
You are now connected to database "mycompany" as user
"non_privilegeduser".
mycompany=> SELECT * FROM employees;
id | name | ssn | salary
----+--------------+-------------+--------
1 | Sally Sample | ###-##-9345 | $0.00
2 | Jane Doe | ###-##-9345 | $0.00
3 | Bill Foo | ###-##-9345 | $0.00
(3 rows)
Demo
When a user other than privilegeduser tries to access the employee table will see redacted data for
ssn and salary column.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.30
mycompany=> c - privilegeduser
mycompany=> EXPLAIN VERBOSE SELECT * FROM employees;
QUERY PLAN
---------------------------------------------------------------------
Seq Scan on public.employees (cost=0.00..14.50 rows=450 width=150)
Output: id, name, ssn, salary
(2 rows)
mycompany=> c - non_privilegeduser
mycompany=> EXPLAIN VERBOSE SELECT * FROM employees;
QUERY PLAN
--------------------------------------------------------------------------
Seq Scan on public.employees (cost=0.00..240.62 rows=450 width=150)
Output: id, name, redact_partial_str(ssn, ...), redact_full_num(salary)
(2 rows)
Demo
Explain plan of the privilegeduser and non-privilegeduser user’s query.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.31
mycompany=> c - non_privilegeduser
You are now connected to database "mycompany" as user
"non_privilegeduser".
mycompany=> SELECT * FROM employees WHERE salary > 60000::money;
id | name | ssn | salary
----+----------+-------------+--------
2 | Jane Doe | ###-##-9345 | $0.00
(1 row)
How to restrict this ?
Demo
By default for the Oracle compatibility if policy created using DBMS_REDACT package procedure
the scope is “top_tlist” -- So what?
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.32
mycompany=> c - enterprisedb
mycompany=> ALTER REDACTION POLICY emp_data_protect ON employees
MODIFY COLUMN salary WITH OPTIONS (SCOPE query);
ALTER REDACTION POLICY
mycompany=> c - non_privilegeduser
mycompany=> SELECT * FROM employees WHERE salary > 60000::money;
id | name | ssn | salary
----+------+-----+--------
(0 rows)
Demo
Use native syntax to tweak scope and exception, since no provision in DBMS_REDACT package for
that.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.33
-- scope: top_tlist
mycompany=> EXPLAIN VERBOSE SELECT * FROM employees WHERE salary > 60000::money;
QUERY PLAN
--------------------------------------------------------------------------
Seq Scan on public.employees (cost=0.00..92.12 rows=150 width=150)
Output: id, name, redact_partial_str(ssn, ...), redact_full_num(salary)
Filter: (employees.salary > (60000)::money)
(3 rows)
-- scope: query
mycompany=> EXPLAIN VERBOSE SELECT * FROM employees WHERE salary > 60000::money;
QUERY PLAN
--------------------------------------------------------------------------
Seq Scan on public.employees (cost=0.00..204.62 rows=150 width=150)
Output: id, name, redact_partial_str(ssn, ...), redact_full_num(salary)
Filter: (redact_full_num(employees.salary) > (60000)::money)
(3 rows)
Demo
Explain plan of the query when scope “top_tlist” vs “query”.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.34
mycompany=> c - enterprisedb
mycompany=> ALTER REDACTION POLICY emp_data_protect ON employees
MODIFY COLUMN salary WITH OPTIONS (SCOPE top_tlist_or_error);
ALTER REDACTION POLICY
mycompany=> c - non_privilegeduser
mycompany=> SELECT * FROM employees WHERE salary > 60000::money;
ERROR: redacted column is allowed only in top targetlist
Demo
Use SCOPE for the strictness.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.35
mycompany=> c - enterprisedb
mycompany=> ALTER REDACTION POLICY emp_data_protect ON employees
MODIFY COLUMN ssn WITH OPTIONS (SCOPE top_tlist_or_error, EXCEPTION equal);
mycompany=> c - non_privilegeduser
mycompany=> SELECT * FROM employees WHERE ssn = '123-89-9345';
id | name | ssn | salary
----+----------+-------------+--------
3 | Bill Foo | ###-##-9345 | $0.00
(1 row)
mycompany=> SELECT * FROM employees WHERE ssn like '123-89%';
ERROR: redacted column is allowed only in top targetlist
Demo
Some reasons you want to show information if the non_privilegeduser has exact column value, but
your scope is top_tlist_or_error, then?
--
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.36
Who is EDB?
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.37
The largest dedicated PostgreSQL company
EDB acquires 2ndQuadrant in Sept 2020
• More customers: Than any dedicated PostgreSQL
company
• More experts: Leading PostgreSQL contributors
• More innovation: Positioned to lead in enterprise
PostgreSQL and hybrid cloud
+
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.38
EDB supercharges PostgreSQL
Questions
&
Answers
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.40
Blog:
● Native Data Redaction Capability in EDB Postgres Advanced Server 11
● Creating a Data Redaction Capability to Meet GDPR Requirements
Document:
• EDB Postgres Advanced Server : Security : Data Redaction
• EDB Postgres Advanced Server : Built-In Packages : DBMS_REDACT
Learn more about EDB data redaction:
--
Thank you !

More Related Content

PPTX
Physical architecture of sql server
PPTX
Oracle GoldenGate Microservices Overview ( with Demo )
PDF
Monitoring Oracle Database Instances with Zabbix
PPTX
MySQL8.0_performance_schema.pptx
PPT
IBM DB2 LUW UDB DBA Training by www.etraining.guru
PPS
Oracle Database Overview
PPTX
SKILLWISE-DB2 DBA
Physical architecture of sql server
Oracle GoldenGate Microservices Overview ( with Demo )
Monitoring Oracle Database Instances with Zabbix
MySQL8.0_performance_schema.pptx
IBM DB2 LUW UDB DBA Training by www.etraining.guru
Oracle Database Overview
SKILLWISE-DB2 DBA

What's hot (20)

PDF
Oracle db architecture
PDF
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재
PDF
Learning To Love Forms (WebVisions '07)
PDF
ALL ABOUT DB2 DSNZPARM
 
PDF
PL-SQL, Cursors & Triggers
PPT
Oracle archi ppt
PDF
Db2 recovery IDUG EMEA 2013
PPTX
Sql server basics
PPT
Database Connection
PDF
The Top 5 Reasons to Deploy Your Applications on Oracle RAC
PPTX
E book management system
PPTX
Skillwise-IMS DB
PPT
App Dynamics
PPTX
Continuous DB Changes Delivery With Liquibase
PDF
RMAN in 12c: The Next Generation (PPT)
PPTX
Understanding DB2 Optimizer
PPTX
Introduction Data warehouse
PDF
What is new in MariaDB 10.6?
PPT
PL/SQL
PPTX
Sql server 運用 101
Oracle db architecture
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재
Learning To Love Forms (WebVisions '07)
ALL ABOUT DB2 DSNZPARM
 
PL-SQL, Cursors & Triggers
Oracle archi ppt
Db2 recovery IDUG EMEA 2013
Sql server basics
Database Connection
The Top 5 Reasons to Deploy Your Applications on Oracle RAC
E book management system
Skillwise-IMS DB
App Dynamics
Continuous DB Changes Delivery With Liquibase
RMAN in 12c: The Next Generation (PPT)
Understanding DB2 Optimizer
Introduction Data warehouse
What is new in MariaDB 10.6?
PL/SQL
Sql server 運用 101
Ad

Similar to Introducing Data Redaction - an enabler to data security in EDB Postgres Advanced Server (20)

PPTX
Oracle Data Redaction - UKOUG - TECH14
PPTX
Oracle Data Redaction
PPTX
Data Redaction - OTN TOUR LA 2015
PPTX
Oracle Database 12c - Data Redaction
PPTX
Oracle Data Redaction
PPTX
Oracle Data Redaction
PDF
OER Unit 4 Virtual Private Database
PPTX
12c Mini Lesson - Data Redaction
PDF
An Illustrative Approach to Use SQL Functions: A Review
PPT
PPT
Database security copy
PPT
Oracle Sql & PLSQL Complete guide
PPT
PPTX
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
PDF
Overview of Oracle database12c for developers
DOCX
Teradata imp
DOC
PPTX
Presentation on Database Security in DBMS
Oracle Data Redaction - UKOUG - TECH14
Oracle Data Redaction
Data Redaction - OTN TOUR LA 2015
Oracle Database 12c - Data Redaction
Oracle Data Redaction
Oracle Data Redaction
OER Unit 4 Virtual Private Database
12c Mini Lesson - Data Redaction
An Illustrative Approach to Use SQL Functions: A Review
Database security copy
Oracle Sql & PLSQL Complete guide
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
Overview of Oracle database12c for developers
Teradata imp
Presentation on Database Security in DBMS
Ad

More from EDB (20)

PDF
Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
 
PDF
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
 
PDF
Migre sus bases de datos Oracle a la nube
 
PDF
EFM Office Hours - APJ - July 29, 2021
 
PDF
Benchmarking Cloud Native PostgreSQL
 
PDF
Las Variaciones de la Replicación de PostgreSQL
 
PDF
NoSQL and Spatial Database Capabilities using PostgreSQL
 
PDF
Is There Anything PgBouncer Can’t Do?
 
PDF
Data Analysis with TensorFlow in PostgreSQL
 
PDF
Practical Partitioning in Production with Postgres
 
PDF
A Deeper Dive into EXPLAIN
 
PDF
IOT with PostgreSQL
 
PDF
A Journey from Oracle to PostgreSQL
 
PDF
Psql is awesome!
 
PDF
EDB 13 - New Enhancements for Security and Usability - APJ
 
PPTX
Comment sauvegarder correctement vos données
 
PDF
Cloud Native PostgreSQL - Italiano
 
PDF
New enhancements for security and usability in EDB 13
 
PPTX
Best Practices in Security with PostgreSQL
 
PDF
Cloud Native PostgreSQL - APJ
 
Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
 
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
 
Migre sus bases de datos Oracle a la nube
 
EFM Office Hours - APJ - July 29, 2021
 
Benchmarking Cloud Native PostgreSQL
 
Las Variaciones de la Replicación de PostgreSQL
 
NoSQL and Spatial Database Capabilities using PostgreSQL
 
Is There Anything PgBouncer Can’t Do?
 
Data Analysis with TensorFlow in PostgreSQL
 
Practical Partitioning in Production with Postgres
 
A Deeper Dive into EXPLAIN
 
IOT with PostgreSQL
 
A Journey from Oracle to PostgreSQL
 
Psql is awesome!
 
EDB 13 - New Enhancements for Security and Usability - APJ
 
Comment sauvegarder correctement vos données
 
Cloud Native PostgreSQL - Italiano
 
New enhancements for security and usability in EDB 13
 
Best Practices in Security with PostgreSQL
 
Cloud Native PostgreSQL - APJ
 

Recently uploaded (20)

PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Approach and Philosophy of On baking technology
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Cloud computing and distributed systems.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
KodekX | Application Modernization Development
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PPTX
Big Data Technologies - Introduction.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Approach and Philosophy of On baking technology
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Cloud computing and distributed systems.
20250228 LYD VKU AI Blended-Learning.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
KodekX | Application Modernization Development
The Rise and Fall of 3GPP – Time for a Sabbatical?
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Big Data Technologies - Introduction.pptx
Electronic commerce courselecture one. Pdf
Machine learning based COVID-19 study performance prediction
Advanced methodologies resolving dimensionality complications for autism neur...
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Chapter 3 Spatial Domain Image Processing.pdf

Introducing Data Redaction - an enabler to data security in EDB Postgres Advanced Server

  • 1. Data Redaction Presented by: Amul Sul Principal Software Engineer, EDB
  • 2. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.2 Welcome • This webinar is being recorded. • We will be sharing the slides and recording with you after the session. • Please submit your questions via Zoom Q&A. All questions will be answered at the end of the presentation.
  • 3. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.3 Agenda Data Redaction • Why & what Data Redaction ? • What is EDB Data Redaction ? • How to limit sensitive data exposure in EPAS ? • Provision for the Oracle compatibility in EPAS ? • Demo.
  • 4. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.4 Why & What Data Redaction ? A technique that limits sensitive data exposure. A GDPR (General Data Protection Regulation)-compliant implementation requires the use of many technical capabilities, such as authentication, authorization, access control, virtual database, and encryption. One of the techniques often considered is data redaction to limits sensitive data exposure by dynamically changing data as it is displayed for specific users. Data redaction in EPAS version prior v11 and PostgreSQL -- See Creating a Data Redaction Capability to Meet GDPR Requirements Using EDB Postgres blog, shows how we can use the PostgreSQL search_path, user defined functions and views to add data redaction protection.
  • 5. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.5 What is EDB Data Redaction ? Limits sensitive data exposure by dynamically changing data as it is displayed for specific users. Data Policy Other User Privileged User Custom Data Masking logic
  • 6. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.6 What is EDB Data Redaction ? Limits sensitive data exposure by dynamically changing data as it is displayed for specific users. Policy Name SSN Sally Sample 020-78-9345 Jane Doe 123-33-9345 Emp Table Other User Privileged User Name SSN Sally Sample xxx-xx-9345 Jane Doe xxx-xx-9345 Name SSN Sally Sample 020-78-9345 Jane Doe 123-33-9345
  • 7. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.7 How to limit sensitive data exposure in EPAS ? Using Native Data Redaction Capability of EDB Postgres Advanced Server. Redaction functionPolicy Scope and exception options Policy expression Redaction policies allow a user to choose redaction behavior via redaction function. More than one redaction policy can be created on the same table, but a column can only be associated with one policy. Flexibility to choose when actual redaction should apply and exemptions on columns in the query via the scope and exception options. Boolean expression for the policy; determines how the policy is to be applied. The redaction occurs if this policy expression is evaluated to TRUE.
  • 8. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.8 Policy Create policy: CREATE REDACTION POLICY name ON table_name [ FOR ( expression ) ] [ ADD column_name USING redaction_function() [ WITH OPTIONS ( redaction_options ) ] ] [, … ]; Alter Policy: ALTER REDACTION POLICY name ON table_name ... ➔Rename policy, enable or disable the policy ➔Change policy expression ➔Add more column or remove existing one ➔Change redaction_function and redaction_options
  • 9. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.9 Policy Create policy on emp table: CREATE REDACTION POLICY emp_protect ON emp ADD COLUMN ssn USING redact_ssn(ssn); And the table description will be:
  • 10. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.10 Redaction function CREATE FUNCTION redact_ssn (ssn varchar(11)) RETURNS varchar(11) AS $$ SELECT overlay (ssn placing 'xxx-xx' from 1); $$ LANGUAGE SQL; Note : Return type of the redaction function should be same as the column type. Policy Other User Name SSN Sally Sample xxx-xx-9345 Jane Doe xxx-xx-9345
  • 11. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.11 Scope & exception options Previously seen table description: ➢ SCOPE: Identified the query part where redaction to be applied for the column. ○ Values: query, top_tlist, top_tlist_or_error. ➢ EXCEPTION: Identified the query part where redaction to be exempted. ○ Values: none, equal, leakproof.
  • 12. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.12 Policy expression ALTER REDACTION POLICY emp_protect ON emp FOR (SESSION_USER <> 'privileged_user'); OR CREATE REDACTION POLICY emp_protect ON emp FOR (SESSION_USER <> 'privileged_user') ADD COLUMN ssn USING redact_ssn(ssn);
  • 13. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.13 Oracle compatibility Provision in EPAS ? DBMS_REDACT package Redaction functionPolicy Policy expression Like Oracle, provides various redaction type and supporting functions. DBMS_REDACT package provides Oracle like procedure to add, alter, enable, disable or drop the policy. Same as the native support, the redaction occurs if this policy expression is evaluated to TRUE. Scope and exception options No provision, but user can use native alter syntax to set scope and exception.
  • 14. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.14 Policy Create policy on emp table: BEGIN DBMS_REDACT.add_policy ( object_schema => 'public', object_name => 'emp', policy_name => 'emp_protect', policy_description => 'policy for emp table ...', column_name => 'ssn', function_type => DBMS_REDACT.partial, function_parameters => DBMS_REDACT.REDACT_US_SSN_F5, expression => '1=1', enable => true); END;
  • 15. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.15 Policy Create policy on emp table: BEGIN DBMS_REDACT.add_policy ( object_schema => 'public', object_name => 'emp', policy_name => 'emp_protect', policy_description => 'policy for emp table ...', column_name => 'ssn', function_type => DBMS_REDACT.partial, function_parameters => DBMS_REDACT.REDACT_US_SSN_F5, expression => '1=1', enable => true); END;
  • 16. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.16 Function_type and Function_parameters: BEGIN DBMS_REDACT.add_policy ( object_schema => 'public', object_name => 'emp', policy_name => 'emp_protect', policy_description => 'policy for emp table ...', column_name => 'ssn', function_type => DBMS_REDACT.partial, function_parameters => DBMS_REDACT.REDACT_US_SSN_F5, expression => '1=1', enable => true); END; Redaction function
  • 17. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.17 Parameters: function_type Redaction function NONE No redaction. FULL Full redaction, redacts full values of the column data. PARTIAL Partial redaction, redacts a portion of the column data. function_parameters needed. RANDOM Random redaction, each query results in a different random value depending on the datatype of the column. REGEXP Regular Expression based redaction, searches for the pattern of data to redact. regexp_pattern, regexp_replace_string, regexp_position, regexp_occurence, regexp_match_parameter needed. CUSTOM Custom redaction type.
  • 18. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.18 Parameters: function_parameters needed for PARTIAL type. 1. REDACT_US_SSN_F5 - Redacts the first 5 numbers of SSN. - Example: The number 123-45-6789 becomes XXX- XX-6789 1. REDACT_NA_PHONE_NUMBER - Redacts the North American phone number by 0 leaving the area code. - Example: 1234567890 becomes 1230000000. 1. REDACT_DATE_MILLENNIUM - Redacts a date that is in the DD-MM-YY format. - Example: Redacts all date to 01-JAN-2000. So on… Partial redaction supports only Character, Number and Date types. Redaction function
  • 19. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.19 Existing function_parameters constants not matching my requirement, then? Answer: No problem, you can use your function_parameters. Here are the previously seen function_parameters constants for Character, Number and Date type respectively and its internal definition. 1. REDACT_US_SSN_F5 => 'VVVFVVFVVVV,VVV-VV-VVVV,X,1,5' - input_fmt,output_fmt,mask_char,start,end 1. REDACT_NA_PHONE_NUMBER => '0,4,10' - mask_digit,start,end 1. REDACT_DATE_MILLENNIUM => 'm1d1y2000' - monthDigit,dayDigit,yearDigit - You can replace hours, minutes and seconds too. Redaction function
  • 20. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.20 Policy expression: BEGIN DBMS_REDACT.add_policy ( object_schema => 'public', object_name => 'emp', policy_name => 'emp_protect', policy_description => 'policy for emp table ...', column_name => 'ssn', function_type => DBMS_REDACT.partial, function_parameters => DBMS_REDACT.REDACT_US_SSN_F5, expression => '1=1', enable => true); END; Policy expression
  • 21. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.21 Alter Policy Action parameter of ALTER_POLICY() decides what to alter: 1. Add column to the existing policy, - action => ADD_COLUMN 1. Modify/Drop column redaction method, - action => MODIFY_COLUMN 1. Modify policy expression, - action => MODIFY_EXPRESSION 1. Set policy description, and - action => SET_POLICY_DESCRIPTION 1. Set column description - action => SET_COLUMN_DESCRIPTION
  • 22. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.22 Alter Policy Alter policy to add another column: BEGIN DBMS_REDACT.alter_policy ( object_schema => 'public', object_name => 'emp', policy_name => 'emp_protect', action => DBMS_REDACT.add_column, column_name => 'salary', function_type => DBMS_REDACT.full); END; e.g:
  • 23. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.23 1. A sample data set with employee IDs, names, social security numbers, salary etc. is created in the table employees in the mycompany database. 2. A data redaction policy for ssn and salary column will be applied whenever user other than privilegeduser tries to access the employees table data Demo Step-by-step walkthrough for the complete demo:
  • 24. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.24 Step 1: Create database DROP DATABASE IF EXISTS mycompany; CREATE DATABASE mycompany WITH OWNER = enterprisedb; Step 2: Connect to the new database psql -d mycompany -U enterprisedb psql (11.6.13) Type "help" for help. mycompany=> Demo A sample data set with employee IDs, names, social security numbers, salary etc. is created in the table employees in the mycompany database. Step 3: Create table CREATE TABLE employees ( id SERIAL PRIMARY KEY, name VARCHAR(40) NOT NULL, SSN VARCHAR(11) NOT NULL, salary MONEY); Step 4: Add sample data INSERT INTO employees (name, ssn, salary) VALUES ('Sally Sample', '020-78-9345', 51234.34), ('Jane Doe', '123-33-9345', 62500.00), ('Bill Foo', '123-89-9345', 45350.00);
  • 25. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.25 CREATE ROLE privilegeduser LOGIN PASSWORD 'password'; GRANT ALL ON employees TO privilegeduser; CREATE ROLE non_privilegeduser LOGIN PASSWORD 'password'; GRANT ALL ON employees TO non_privilegeduser; Demo Create privileged and non-privileged user and grant the necessary access.
  • 26. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.26 BEGIN DBMS_REDACT.add_policy ( object_schema => 'public', object_name => 'employees', policy_name => 'emp_data_protect', policy_description => 'hide sensitive info of the employees', column_name => 'ssn', function_type => DBMS_REDACT.partial, function_parameters => 'VVVFVVFVVVV,VVV-VV-VVVV,#,1,5', expression => 'SESSION_USER <> ''privilegeduser''', enable => true); END; Demo Create policy and on ssn and salary column for non-privileged users.
  • 27. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.27 BEGIN DBMS_REDACT.alter_policy ( object_schema => 'public', object_name => 'employees', policy_name => 'emp_data_protect', action => DBMS_REDACT.add_column, column_name => 'salary', function_type => DBMS_REDACT.full); END; Demo Add salary column to emp_data_protect policy.
  • 28. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.28 mycompany=> c - privilegeduser You are now connected to database "mycompany" as user "privilegeduser". mycompany=> SELECT * FROM employees; id | name | ssn | salary ----+--------------+-------------+------------ 1 | Sally Sample | 020-78-9345 | $51,234.34 2 | Jane Doe | 123-33-9345 | $62,500.00 3 | Bill Foo | 123-89-9345 | $45,350.00 (3 rows) Demo By default table owner and super user can see un-redacted data. Also, privilegeduser can see un-redacted data to whom we have exempted from the policy.
  • 29. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.29 mycompany=> c - non_privilegeduser You are now connected to database "mycompany" as user "non_privilegeduser". mycompany=> SELECT * FROM employees; id | name | ssn | salary ----+--------------+-------------+-------- 1 | Sally Sample | ###-##-9345 | $0.00 2 | Jane Doe | ###-##-9345 | $0.00 3 | Bill Foo | ###-##-9345 | $0.00 (3 rows) Demo When a user other than privilegeduser tries to access the employee table will see redacted data for ssn and salary column.
  • 30. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.30 mycompany=> c - privilegeduser mycompany=> EXPLAIN VERBOSE SELECT * FROM employees; QUERY PLAN --------------------------------------------------------------------- Seq Scan on public.employees (cost=0.00..14.50 rows=450 width=150) Output: id, name, ssn, salary (2 rows) mycompany=> c - non_privilegeduser mycompany=> EXPLAIN VERBOSE SELECT * FROM employees; QUERY PLAN -------------------------------------------------------------------------- Seq Scan on public.employees (cost=0.00..240.62 rows=450 width=150) Output: id, name, redact_partial_str(ssn, ...), redact_full_num(salary) (2 rows) Demo Explain plan of the privilegeduser and non-privilegeduser user’s query.
  • 31. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.31 mycompany=> c - non_privilegeduser You are now connected to database "mycompany" as user "non_privilegeduser". mycompany=> SELECT * FROM employees WHERE salary > 60000::money; id | name | ssn | salary ----+----------+-------------+-------- 2 | Jane Doe | ###-##-9345 | $0.00 (1 row) How to restrict this ? Demo By default for the Oracle compatibility if policy created using DBMS_REDACT package procedure the scope is “top_tlist” -- So what?
  • 32. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.32 mycompany=> c - enterprisedb mycompany=> ALTER REDACTION POLICY emp_data_protect ON employees MODIFY COLUMN salary WITH OPTIONS (SCOPE query); ALTER REDACTION POLICY mycompany=> c - non_privilegeduser mycompany=> SELECT * FROM employees WHERE salary > 60000::money; id | name | ssn | salary ----+------+-----+-------- (0 rows) Demo Use native syntax to tweak scope and exception, since no provision in DBMS_REDACT package for that.
  • 33. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.33 -- scope: top_tlist mycompany=> EXPLAIN VERBOSE SELECT * FROM employees WHERE salary > 60000::money; QUERY PLAN -------------------------------------------------------------------------- Seq Scan on public.employees (cost=0.00..92.12 rows=150 width=150) Output: id, name, redact_partial_str(ssn, ...), redact_full_num(salary) Filter: (employees.salary > (60000)::money) (3 rows) -- scope: query mycompany=> EXPLAIN VERBOSE SELECT * FROM employees WHERE salary > 60000::money; QUERY PLAN -------------------------------------------------------------------------- Seq Scan on public.employees (cost=0.00..204.62 rows=150 width=150) Output: id, name, redact_partial_str(ssn, ...), redact_full_num(salary) Filter: (redact_full_num(employees.salary) > (60000)::money) (3 rows) Demo Explain plan of the query when scope “top_tlist” vs “query”.
  • 34. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.34 mycompany=> c - enterprisedb mycompany=> ALTER REDACTION POLICY emp_data_protect ON employees MODIFY COLUMN salary WITH OPTIONS (SCOPE top_tlist_or_error); ALTER REDACTION POLICY mycompany=> c - non_privilegeduser mycompany=> SELECT * FROM employees WHERE salary > 60000::money; ERROR: redacted column is allowed only in top targetlist Demo Use SCOPE for the strictness.
  • 35. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.35 mycompany=> c - enterprisedb mycompany=> ALTER REDACTION POLICY emp_data_protect ON employees MODIFY COLUMN ssn WITH OPTIONS (SCOPE top_tlist_or_error, EXCEPTION equal); mycompany=> c - non_privilegeduser mycompany=> SELECT * FROM employees WHERE ssn = '123-89-9345'; id | name | ssn | salary ----+----------+-------------+-------- 3 | Bill Foo | ###-##-9345 | $0.00 (1 row) mycompany=> SELECT * FROM employees WHERE ssn like '123-89%'; ERROR: redacted column is allowed only in top targetlist Demo Some reasons you want to show information if the non_privilegeduser has exact column value, but your scope is top_tlist_or_error, then? --
  • 36. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.36 Who is EDB?
  • 37. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.37 The largest dedicated PostgreSQL company EDB acquires 2ndQuadrant in Sept 2020 • More customers: Than any dedicated PostgreSQL company • More experts: Leading PostgreSQL contributors • More innovation: Positioned to lead in enterprise PostgreSQL and hybrid cloud +
  • 38. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.38 EDB supercharges PostgreSQL
  • 40. © Copyright EnterpriseDB Corporation, 2020. All rights reserved.40 Blog: ● Native Data Redaction Capability in EDB Postgres Advanced Server 11 ● Creating a Data Redaction Capability to Meet GDPR Requirements Document: • EDB Postgres Advanced Server : Security : Data Redaction • EDB Postgres Advanced Server : Built-In Packages : DBMS_REDACT Learn more about EDB data redaction: --