Skip to content
Merged
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
a6b0764
minor edits to data redaction lab
richardcevans Mar 31, 2025
20cb751
minor edits to data redaction lab
richardcevans Mar 31, 2025
36f8836
Merge branch 'main' of https://github.com/richardcevans/security
richardcevans Apr 1, 2025
c34670c
Merge branch 'oracle-livelabs:main' into main
richardcevans Apr 15, 2025
a47ef16
create livelabs folder for database world nyc
richardcevans Apr 15, 2025
4304046
Merge branch 'oracle-livelabs:main' into main
richardcevans May 13, 2025
c3e18fd
combo tde-okv-dv lab
richardcevans May 13, 2025
02470f2
tde-okv-dv
richardcevans May 13, 2025
4f27939
beyond-the-baseline
richardcevans May 13, 2025
d94990a
beyond the baseline updates
richardcevans May 15, 2025
77f1fb2
Update intro-beyond-the-baseline.md
richardcevans May 15, 2025
ce6ffab
Merge branch 'oracle-livelabs:main' into main
richardcevans May 16, 2025
e9918a1
updated dv labs to clarify steps
richardcevans May 19, 2025
0a39136
updates to the main dv lab
richardcevans May 19, 2025
9873bab
updates to dv related labs
richardcevans May 20, 2025
281828c
Update database-vault.md
richardcevans May 20, 2025
825f67d
Merge branch 'main' into main
dannymgithub May 20, 2025
762e7c7
Merge branch 'oracle-livelabs:main' into main
richardcevans May 20, 2025
d4259a9
Merge branch 'oracle-livelabs:main' into main
richardcevans May 20, 2025
86ae89b
Update database-vault.md
richardcevans May 21, 2025
1064fa2
Update database-vault.md
richardcevans May 21, 2025
232fa04
updates to dv labs
richardcevans May 22, 2025
b067642
Update intro-beyond-the-baseline.md
richardcevans May 22, 2025
f013f3e
Update intro-beyond-the-baseline.md
richardcevans May 22, 2025
be8eb1a
Update database-vault.md
richardcevans May 22, 2025
04da3fb
Update database-vault.md
richardcevans May 22, 2025
695c599
Merge branch 'oracle-livelabs:main' into main
richardcevans May 22, 2025
3227946
minor dv updates to clarify wording
richardcevans May 22, 2025
ed4243a
Merge branch 'main' of https://github.com/richardcevans/security
richardcevans May 22, 2025
ba8c6b0
Update database-vault.md
richardcevans May 22, 2025
4877374
minor dv updates
richardcevans May 22, 2025
a4f92c9
Merge branch 'oracle-livelabs:main' into main
richardcevans May 22, 2025
014c65c
Update database-vault.md
richardcevans May 22, 2025
8d8dcc3
Merge remote-tracking branch 'upstream/main'
richardcevans May 22, 2025
57901a9
minor dv updates
richardcevans May 22, 2025
157b37f
updates to beyond baseline intro markdown
richardcevans May 22, 2025
768e1f4
minor updates to dv markdown
richardcevans May 22, 2025
6796aef
Merge branch 'oracle-livelabs:main' into main
richardcevans Jun 6, 2025
d3c2e24
updated getting started link
richardcevans Jun 6, 2025
cfdbe38
Update manifest.json
richardcevans Jun 9, 2025
6956508
Update database-vault.md
richardcevans Jun 9, 2025
6f5ab33
Update database-vault.md
richardcevans Jun 9, 2025
95cb5a2
Update database-vault.md
richardcevans Jun 9, 2025
565f2fa
Merge branch 'main' into main
richardcevans Jun 9, 2025
2e73263
Merge branch 'oracle-livelabs:main' into main
richardcevans Jun 17, 2025
a6a52f4
Merge branch 'oracle-livelabs:main' into main
richardcevans Aug 20, 2025
87e9f7d
Merge branch 'oracle-livelabs:main' into main
richardcevans Sep 3, 2025
ce4f443
minor updates to formatting.
richardcevans Sep 4, 2025
72db2a0
Merge branch 'oracle-livelabs:main' into main
richardcevans Nov 18, 2025
e0da77e
Merge branch 'oracle-livelabs:main' into main
richardcevans Nov 19, 2025
46e9d42
fixed image not showing tab error.
richardcevans Nov 19, 2025
e19ef69
Update wget command URL for VPD lab download
richardcevans Dec 2, 2025
ab6efc7
Merge branch 'oracle-livelabs:main' into main
richardcevans Dec 4, 2025
6027977
Remove unused image assets and update documentation
richardcevans Dec 4, 2025
452950a
Update .gitignore
richardcevans Dec 4, 2025
0831c70
Create dv-concept.png
richardcevans Dec 5, 2025
fe4e7a6
Update Oracle NNE workshop documentation
richardcevans Dec 5, 2025
82a7a4d
Update nne.md
richardcevans Dec 5, 2025
15e4838
update acknowledgements and database naming conventions
richardcevans Dec 5, 2025
ff3fdf2
working on the beyond tokenization lab
richardcevans Dec 18, 2025
1e58164
Merge branch 'oracle-livelabs:main' into main
richardcevans Jan 6, 2026
5c7837b
Merge branch 'oracle-livelabs:main' into main
richardcevans Jan 7, 2026
814aecf
Merge branch 'oracle-livelabs:main' into main
richardcevans Jan 28, 2026
e00075a
Merge branch 'oracle-livelabs:main' into main
richardcevans Mar 2, 2026
37a20a6
Merge branch 'oracle-livelabs:main' into main
richardcevans Mar 16, 2026
4efcf71
Merge branch 'main' of https://github.com/richardcevans/security
richardcevans Mar 16, 2026
c154b84
updated scripts PAR link
richardcevans Mar 16, 2026
c86a2a4
Update VPD LiveLab documentation
richardcevans Mar 16, 2026
63cc55e
removed unnecessary lab
richardcevans Mar 16, 2026
05f0b53
fixed markdown issues
richardcevans Mar 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 66 additions & 64 deletions database/baseline/vpd/vpd-livelab/vpd.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
## Introduction
Oracle Virtual Private Database enforces security, to a fine level of granularity, directly on database tables, views, or synonyms. Because you attach security policies directly to these database objects, and the policies are automatically applied whenever a user accesses data, there is no way to bypass security.

Description: This lab introduces the functionality of Oracle Virtual Private Database (VPD). It gives the user an opportunity to learn how to configure this feature to implement row and column level security. Oracle VPD creates security policies to control database access at the row and column level.
This lab introduces the functionality of Oracle Virtual Private Database (VPD). It gives the user an opportunity to learn how to configure this feature to implement row and column level security. Oracle VPD creates security policies to control database access at the row and column level.

*Estimated Time:* 30 minutes

*Version tested in this lab:* Oracle DB 19.17
*Version tested in this lab:* Oracle DB 19c

### Objectives
- Understand how to create a PL/SQL function for use in a VPD policy
Expand All @@ -23,44 +23,44 @@ This lab assumes you have:
- Lab: Environment Setup
- Lab: Initialize Environment

## Task 1: Download vpd.tar file to local directory.
## Task 1: Download vpd.tar file to local directory

1. Open a Terminal session on your **DBSec-Lab** VM as OS user *oracle* and use `cd` command to move to livelabs directory.
1. Open a Terminal session on your **DBSec-Lab** VM as OS user *oracle* and use `cd` command to move to livelabs directory.

````
<copy>cd livelabs</copy>
````

**Note**: If you are using a remote desktop session, double-click on the *Terminal* icon on the desktop to launch a session

2. Use the Linux command 'wget' to download a bundled (zipped) file of the commands for the lab.
2. Use the Linux command 'wget' to download a bundled (zipped) file of the commands for the lab.

````
<copy>wget https://objectstorage.us-ashburn-1.oraclecloud.com/p/cSHhQf7m7ms3YRkyhSIfYtQw9qRcoOeBevb81RGUKsU19RhLMsLTjtUNRPoO4UaN/n/oradbclouducm/b/dbsec_rich/o/dbsec-livelabs-vpd.tar</copy>
<copy>wget https://objectstorage.us-ashburn-1.oraclecloud.com/p/Ca1HsovSmxaXDPvFRjf7CS9E-jGCl6U3rfaNlwePwWoD5Hi8vPcfeg1xs-_KAJp-/n/oradbclouducm/b/dbsec_rich/o/dbsec-livelabs-vpd.tar</copy>
````

3. Unarchive the downloaded tar to expand the directory and scripts.
3. Unarchive the downloaded tar to expand the directory and scripts.

````
<copy>tar xvf dbsec-livelabs-vpd.tar</copy>
````

4. Use `cd` command to move to vpd directory.
4. Use `cd` command to move to vpd directory.

````
<copy>cd vpd</copy>
````

5. Use `ls` command to list files.
5. Use `ls` command to list files.

````
<copy>ls</copy>
````

## Task 2: Create row function and policies

1. Initial query to show that there have not been VPD policies created yet.
1. Initial query to show that there have not been VPD policies created yet.

````
<copy>./vpd_query_policies.sh</copy>
````
Expand All @@ -71,8 +71,8 @@ This lab assumes you have:
no rows selected
````

2. Initial query to demonstrate that `EMPLOYEESEARCH_PROD` and `DBA_DEBRA` can see employee-related data. Note the number of rows and the sensitive data returned in the columns.
2. Initial query to demonstrate that `EMPLOYEESEARCH_PROD` and `DBA_DEBRA` can see employee-related data. Note the number of rows and the sensitive data returned in the columns.

````
<copy>./vpd_query_employee_data.sh</copy>
````
Expand All @@ -84,56 +84,58 @@ This lab assumes you have:

![Initial Query DBA_DEBRA](./images/vpd_initialquerydebra.png " ")

3. VPD relies on PL/SQL functions for business logic. Create a function that applies a `1=0` predicate (where clause) to the query if the session user is not the application owner, `EMPLOYEESEARCH_PROD`
3. VPD relies on PL/SQL functions for business logic. Create a function that applies a `1=0` predicate (where clause) to the query if the session user is not the application owner, `EMPLOYEESEARCH_PROD`

````
<copy>./vpd_create_row_function.sh</copy>
````

4. Apply a VPD policy to the `EMPLOYEESEARCH_PROD.DEMO_HR_EMPLOYEES` table that will call the PL/SQL function and restrict rows for `SELECT` queries.
4. Apply a VPD policy to the `EMPLOYEESEARCH_PROD.DEMO_HR_EMPLOYEES` table that will call the PL/SQL function and restrict rows for `SELECT` queries.

````
<copy>./vpd_create_row_policy.sh</copy>
````
**Output:**

![Create Row Policy](./images/vpd_createrowpolicy.png " ")

5. Re-run the query to view employee data. With the VPD row policy applies, `EMPLOYEESEARCH_PROD` will still see all rows but `DBA_DEBRA` will no longer be able to see employee data.
5. Re-run the query to view employee data. With the VPD row policy applies, `EMPLOYEESEARCH_PROD` will still see all rows but `DBA_DEBRA` will no longer be able to see employee data.

````
<copy>./vpd_query_employee_data.sh</copy>
````
**Output for `EMPLOYEESEARCH_PROD`:**

![Row Policy Query](./images/vpd_rerunquery.png " ")

**Output for `DBA_DEBRA`:**
![Row Policy Query DBA_DEBRA](./images/vpd_rerunquerydebra.png " ")

6. Now that you understand how to use VPD to limit the number of rows returned, we will drop the row policy and move on to protecting column values.
6. Now that you understand how to use VPD to limit the number of rows returned, we will drop the row policy and move on to protecting column values.

````
<copy>./vpd_drop_row_policy.sh</copy>
````
## Task 3: Create column function and policies.
1. Similar to the row function, the PL/SQL function will limit the number of rows returned for users who are not the application schema owner, `EMPLOYEESEARCH_PROD`. In addition, the the application user, the function will also verify the `CLIENT_IDENTIFIER` value is set in the user's session context.


## Task 3: Create column function and policies

1. Similar to the row function, the PL/SQL function will limit the number of rows returned for users who are not the application schema owner, `EMPLOYEESEARCH_PROD`. In addition, the application user, the function will also verify the `CLIENT_IDENTIFIER` value is set in the user's session context.

````
<copy>./vpd_create_col_function.sh</copy>
````

2. Create the VPD policy using the PL/SQL column function. This policy will apply to the `SSN`, `SIN`, and `NINO` columns.
2. Create the VPD policy using the PL/SQL column function. This policy will apply to the `SSN`, `SIN`, and `NINO` columns.

````
<copy>./vpd_create_col_policy.sh</copy>
````
**Output:**

![Column Policy](./images/vpd_createvpdpolicy.png " ")

3. When `EMPLOYEESEARCH_PROD` queries data, 9 rows will be returned but the values for the sensitive columns will not. This is because the VPD policy function will not return the values of these columns until the session user and `CLIENT_IDENTIFIER` session context are both met.
3. When `EMPLOYEESEARCH_PROD` queries data, 9 rows will be returned but the values for the sensitive columns will not. This is because the VPD policy function will not return the values of these columns until the session user and `CLIENT_IDENTIFIER` session context are both met.

````
<copy>./vpd_query_employee_data.sh</copy>
````
Expand All @@ -144,90 +146,90 @@ This lab assumes you have:

![Column Policy Query DBA_DEBRA](./images/vpd_columnpolicyquerydebra.png " ")

4. To demonstrate the results when both session user and `CLIENT_IDENTIFIER` are met, append `hradmin` to the previous query. Sensitive column values will be displayed. However, `DBA_DEBRA` will never see this data because she is not authorized by the PL/SQL function.
4. To demonstrate the results when both session user and `CLIENT_IDENTIFIER` are met, append `hradmin` to the previous query. Sensitive column values will be displayed. However, `DBA_DEBRA` will never see this data because she is not authorized by the PL/SQL function.

````
<copy>./vpd_query_employee_data.sh hradmin</copy>
````
**Output for `EMPLOYEESEARCH_PROD`:**

![Client Identifier Query](./images/vpd_clientidentifierquery.png " ")

**Output for `DBA_DEBRA`:**

![Client Identifier Query DBA_DEBRA](./images/vpd_clientidentifierquerydebra.png " ")

5. Altering the query from `hradmin` to `can_candy` will not display any of the sensitive columns because our PL/SQL function does not recognize `can_candy` as a `CLIENT_IDENTIFIER` yet.
5. Altering the query from `hradmin` to `can_candy` will not display any of the sensitive columns because our PL/SQL function does not recognize `can_candy` as a `CLIENT_IDENTIFIER` yet.

````
<copy>./vpd_query_employee_data.sh can_candy</copy>
````
**Output for `EMPLOYEESEARCH_PROD`:**

![Can_Candy Identifier Query](./images/vpd_can_candyidentifierquery.png " ")

**Output for `DBA_DEBRA`:**

![Can_Candy Identifier Query DBA_DEBRA](./images/vpd_can_candyidentifierquerydebra.png " ")

6. Update the PL/SQL function to include an `elsif` to allow `can_candy` to see the sensitive columns for Toronto-based employees.
6. Update the PL/SQL function to include an `elsif` to allow `can_candy` to see the sensitive columns for Toronto-based employees.

````
<copy>./vpd_update_col_function.sh</copy>
````

7. Demonstrate that `hradmin` sees 9 rows and sensitive columns but `DBA_DEBRA` does not.
7. Demonstrate that `hradmin` sees 9 rows and sensitive columns but `DBA_DEBRA` does not.

````
<copy>./vpd_query_employee_data.sh hradmin</copy>
````
**Output for `EMPLOYEESEARCH_PROD`:**

![Hradmin Identifier Query](./images/vpd_hradminidentifierquery.png " ")

**Output for `DBA_DEBRA`:**

![Hradmin Identifier Query DBA_DEBRA](./images/vpd_hradminidentifierquerydebra.png " ")

8. Demonstrate that `can_candy` will see 9 rows and only the sensitive columns for Toronto-based employees. `DBA_DEBRA` will still not see any sensitive columns.
8. Demonstrate that `can_candy` will see 9 rows and only the sensitive columns for Toronto-based employees. `DBA_DEBRA` will still not see any sensitive columns.

````
<copy>./vpd_query_employee_data.sh can_candy</copy>
````
**Output for `EMPLOYEESEARCH_PROD`:**

![Updated Can_Candy Query](./images/vpd_updatedcan_candyquery.png " ")

**Output for `DBA_DEBRA`:**

![Updated Can_Candy Query DBA_DEBRA](./images/vpd_updatedcan_candyquerydebra.png " ")

## Task 4: Clean up.
## Task 4: Clean up

1. Remove the PL/SQL functions and drop the VPD-related policies.

1. Remove the PL/SQL functions and drop the VPD-related policies.

````
<copy>./vpd_cleanup.sh</copy>
````

2. Verify both `EMPLOYESEARCH_PROD` and `DBA_DEBRA` have full access to rows and columns without the VPD policies in place.
2. Verify both `EMPLOYEESEARCH_PROD` and `DBA_DEBRA` have full access to rows and columns without the VPD policies in place.

````
<copy>./vpd_query_employee_data.sh</copy>
````
**Output for `EMPLOYEESEARCH_PROD`:**

![Cleanup Query](./images/vpd_cleanupquery.png " ")

**Output for `DBA_DEBRA`:**
![Cleanup Query DBA_DEBRA](./images/vpd_cleanupquerydebra.png " ")

![Cleanup Query DBA_DEBRA](./images/vpd_cleanupquerydebra.png " ")

## Learn More
Technical Documentation:
- [Using Oracle Virtual Private Database to Control Data Access](https://docs.oracle.com/en/database/oracle/oracle-database/21/dbseg/using-oracle-vpd-to-control-data-access.html#GUID-06022729-9210-4895-BF04-6177713C65A7)

## Acknowledgements
- **Author** - Stephen Stuart & Noah Galloso, Solution Engineers, North America Specialist Hub
- **Contributors** - Richard C. Evans, Database Security Product Manager
- **Last Updated By/Date** - Stephen Stuart & Noah Galloso, August 2023
- **Contributors** - Richard C. Evans, Database Security Product Manager
- **Last Updated By/Date** - Richard C. Evans, March 2026
Loading