Unit-3 First
Unit-3 First
INTRODUCTION:
• Describe the different types of users in a database environment and the distinct purpose of each
• Identify and explain the concepts of five security models
• List the most commonly used application types
• Implement the most common application security models
• Understand the use of data encryption within database applications
Types of Users:
• Application:
– Solves a problem
– Performs a specific business function
• Database: collection of related data files used by an application
• Application user: user within the application schema
• Types:
– Application administrator
– Application owner
– Application user
– Database administrator
– Database user
– Proxy user
– Schema owner
– Virtual user
Security Models:
• Access Matrix Model:
– Represents two main entities: objects and subjects:
• Columns represent objects
• Rows represent subjects
– Objects: tables, views, procedures, database objects
– Subjects: users, roles, privileges, modules
– Authorization cell
Web Applications:
• Evolved with the rise of dot-com and Web-based companies
• Uses the Web to connect and communicate to the server
• A Web application uses HTML pages created using:
– ActiveX
– Java applets or beans
– ASP (Active Server Pages)
• Components:
– Web browser layer
– Web server layer
– Application server layer
– Business logic layer
– Database server layer
• Implementation in Oracle:
– Create users
– Add content to your tables
– Add a row for an application user
– Look for application user’s role
– Activate the role for this specific session
• Implementation in SQL Server:
– Use application roles:
• Special roles you that are activated at the time of authorization
• Require a password and cannot contain members
– Connect a user to the application role: overrules user’s privileges
– Create and drop application roles using the command line and the Enterprise Manager:
• SP_ADDAPPROLE
• SP_DROPAPPROLE
– You can activate application roles using SP_SETAPPROLE
– Connect to database as the proxy user
– Validate the user name and password
– Retrieve the application role name
– Activate the application role
UNIT-3
Objectives:
• Define the term “virtual private database” and explain its importance
• Implement a virtual private database by using the VIEW database object
• Implement a virtual private database by using Oracle’s application context
• Implement row-level and column-level security
Why VPD?
• Security
– Server-enforced security (as opposed to application-enforced).
• Purposes/benefits:
– Security requirements necessitate data access be restricted at row or column level (FGA)
– One database schema serves multiple unrelated groups or entities
• Scalability
– Table Customers contains 1,000 customer records.
– Suppose we want customers to access their own records only.
– Using views, we need to create 1,000 views. Using VPD, it can be done with a single policy function.
• Simplicity
– Say, we have a table T and many views are based on T.
– Suppose we want to restrict access to some information in T.
– Without VPD, all view definitions have to be changed.
– Using VPD, it can be done by attaching a policy function to T; as the policy is enforced in T, the policy is also enforced for
all the views that are based on T.
Create a VIEW object to display rows that belong only to the logged on user
CREATE VIEW EMPLOYEES_VIEW1 AS
SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, HIRE_DATE, JOB_ID, SALARY, MANAGER_ID, DEPARTMENT_ID,
CTL_UPD_USER USER_NAME
FROM EMPLOYEES_VER1
WHERE CTL_UPD_USER = USER Rename to USER_NAME
Oracle VPD:
• How does it work?
When a user accesses a table (or view or synonym) which is protected by a VPD policy (function),
1. The Oracle server invokes the policy function whenever a logged on user tries to execute a query.
2. The policy function returns a predicate, based on session attributes or database contents.
3. The server dynamically rewrites the submitted query by appending the returned predicate to the WHERE clause.
4. The modified SQL query is executed.
Column-level VPD:
• Instead of attaching a policy to a whole table or a view, attach a policy only to security-relevant columns
– Default behavior: restricts the number of rows returned by a query.
– Masking behavior: returns all rows, but returns NULL values for the columns that contain sensitive information.
– Restrictions
– Applies only to ‘select’ statements
– The predicate must be a simple boolean expression.
Example:
• Suppose Alice has the following table.
•
• e_id • Name • Salary
• 1 • Alice • 80
• 2 • Bob • 60
• 3 • Carl • 99
Example:
1. Create a policy function
Create function sec_function(p_schema varchar2, p_obj varchar2)
Return varchar2
As
user VARCHAR2(100);
Begin
user := SYS_CONTEXT(‘userenv’, ‘SESSION_USER’);
return ‘Name = ‘ || user;
end if;
End;
2. Attach the policy function to Employees (default behavior)
execute dbms_rls.add_policy (object_schema => ‘Alice’,
object_name => ‘employees’,
policy_name => ‘my_policy’,
function_schema => ‘Alice’,
policy_function => ‘sec_function’,
sec_relevant_cols=>’salary’);
3. Bob accesses table Employees (default behavior)
select e_id, name from Employee;
e_id Name
1 Alice
2 Bob
3 Carl
2 Bob 60
e_id Name
1 Alice
2 Bob
3 Carl
1 Alice
2 Bob 60
3 Carl
Application Context:
• Application contexts act as secure caches of data that may be used by a fine-grained access control policy.
– Upon logging into the database, Oracle sets up an application context in the user’s section.
– You can define, set and access application attributes that you can use as a secure data cache.
– There is a pre-defined application context, “userenv”.
– in Oracle Security Guide.
Application Context:
• One can create a customized application context and attributes.
– Say, each employee can access a portion of the Customers table, based on the job-position.
– For example, a clerk can access only the records of the customers who lives in a region assigned to him. But a manager
can access any record.
– Suppose that the job-positions of employees are stored in a LDAP server (or in the Employee table).
– Such information can be accessed and cached in an application context when an employee logs in.
Multiple Policies:
• It is possible to associate multiple policies to a database object.
– The policies are enforced with AND syntax.
– For example, suppose table T is associated with {P1, P2, P3}.
– When T is accessed by query Q = select A from T where C.
– Q’ = select A from T where C (c1 c2 c3).
• Different from Stonebraker’s approach
– The policies are enforced with OR syntax.
– Q’ = select A from T where C (c1 c2 c3).
– While Stonebraker’s policies specify “what users can see” (permissions), VPD policies specify “what users cannot see”
(prohibitions).