SQLSecurity
SQLSecurity
Security:
Access Control, SQL Injection Attacks
+
Data Security
GRANT
GRANT privileges
privileges ON
ON object
object TO
TO users
users
[WITH
[WITH GRANT
GRANT OPTIONS]
OPTIONS]
REVOKE
REVOKE privileges
privileges ON
ON object
object FROM
FROM users
users
[CASCADE
[CASCADE ]]
+
Access Control in MySQL
http://dev.mysql.com/doc/refman/5.0/en/privilege-system.htm
l
There are some things that you cannot do with the MySQL
privilege system:
You cannot explicitly specify that a given user should be denied
access. That is, you cannot explicitly match a user and then refuse
the connection.
You cannot specify that a user has privileges to create or drop
tables in a database but not to create or drop the database itself.
A password applies globally to an account. You cannot associate a
password with a specific object such as a database, table, or
routine.
+ 6
Views in SQL
CREATE
CREATEVIEW
VIEWpmpStudents
pmpStudentsAS
AS
SELECT
SELECT** FROM
FROMStudents
StudentsWHERE…
WHERE…
GRANT
GRANT SELECT
SELECTON
ONpmpStudents
pmpStudentsTO
TO DavidRispoli
DavidRispoli
+
Views in MySQL
http://dev.mysql.com/doc/refman/5.0/en/create-view.ht
ml
Many aspects:
General factors that affect security. These
include choosing good passwords, not granting
unnecessary privileges to users, ensuring application
security by preventing SQL injections and data
corruption, and others. See Section 6.1, “General
Security Issues”.
Security of the installation itself. The data files,
log files, and the all the application files of your
installation should be protected to ensure that they
are not readable or writable by unauthorized parties.
+
MySQL security
Access control and security within the database
system itself, including the users and databases granted
with access to the databases, views and stored programs in
use within the database. For more information, see Section
6.2, “The MySQL Access Privilege System”, and Section 6.3,
“MySQL User Account Management”.
http://www.mysqlperformanceblog.com/2012/07/18/sql-
injection-still-a-problem/
An SQL injection vulnerability resulted in an urgent June bugfix
release of Ruby on Rails 3.x.
Yahoo! Voices was hacked in July. The attack acquired
453,000 user email addresses and passwords. The
perpetrators claimed to have used union-based SQL injection
to break in.
LinkedIn.com leaked 6.5 million user credentials in June. A
class action lawsuit alleges that the attack was accomplished
with SQL injection.
SQL injection was documented as a security threat in 1998,
but new incidents still occur every month. Making honest
mistakes, developers fail to defend against this means of
+
Some good sites to learn more
Prevention guide (with sample code in many languages):
http://bobby-tables.com/
Tutorials:
(webinar) http://www.percona.com/webinars/2012-07-25-sql-injection-
myths-and-fallacies
http://www.netrostar.com/SQL-Injection-Attack
http://www.unixwiz.net/techtips/sql-injection.html
Cool site that let’s you try out attacks on a sample DB and
explains why they work
http://sqlzoo.net/hack/