DB Unit-5
DB Unit-5
REVOKE:
DBMS must now revoke the SELECT privilege on EMPLOYEE
from A3.
Next, suppose that A1 wants to give back to A3 a limited
capability to SELECT from the EMPLOYEE relation. The
limitation is to retrieve only the Name, Bdate, and Address
attributes and only for the tuples with Dno = 5.
CREATE VIEW A3EMPLOYEE AS
SELECT Name, Bdate, Address
FROM EMPLOYEE
WHERE Dno = 5;
After the view is created, A1 can grant SELECT on the view
A3EMPLOYEE to A3 as follows:
GRANT SELECT ON A3EMPLOYEE TO A3 WITH GRANT
OPTION;
Finally, suppose that A1 wants to allow A4 to update only the
Salary attribute of EMPLOYEE; A1 can then issue the following
command:
GRANT UPDATE ON EMPLOYEE (Salary) TO A4;
SQL Injection
• SQL injection is a code injection technique that might
destroy your database.
• SQL injection is one of the most common web hacking
techniques.
• SQL injection is the placement of malicious code in SQL
statements, via web page input.
SQL in Web Pages
SQL injection usually occurs when you ask a user for
input, like their username/userid, and instead of a name/id,
the user gives you an SQL statement that you will
unknowingly run on your database.
Example
txtUserId=getRequestString("UserId");
txtSQL = "SELECT * FROM Users WHERE UserId = " +
txtUserId;
SQL Injection Based on 1=1 is Always True
Create an SQL statement to select a user, with a given
user id.
Select * from users where userid=105;
User can enter some "smart" input like this:
UserId: 105 OR 1=1
Then, the SQL statement will look like this:
SELECT * FROM Users WHERE UserId = 105 OR 1=1;
The above SQL is valid and will return ALL rows from the
"Users" table, since OR 1=1 is always TRUE.
Does the example above look dangerous? What if the "Users"
table contains names and passwords?
The SQL statement above is much the same as this:
SELECT UserId, Name, Password FROM Users WHERE UserId
= 105 or 1=1;
A hacker might get access to all the user names and
passwords in a database, by simply inserting 105 OR 1=1 into
the input field.
Flow Control:
1. Access Control – Protect unauthorized access.
2. Flow Control − Data flow from one site to another and
also within a site must be controlled.
3. Data Encryption- Data transmission in public must be in
encrypted.