There are many type of security vulnerability may exist in
your software application. You just need to start to know, how many type of
security related risk may exist in your applications. Common practice is in
development is that we try to find very simplest way to get our problem
resolved. But we forget about security related aspects.
So this is the time to learn how should we write our code and what we need to avoid to use in our code. We are going yo start with top 10 vulnerabilities which every programmer should know.
Top 10 Vulnerabilities by OWASP (Open Web Application Security
Project)
Let’s talk about these vulnerabilities one by one:
What is SQL Injection and how it works
SQL Injection means attacker sends simple text based attacks
that exploit the syntax of the targeted interpreter. SQL injections are
introduced when software developers write dynamic query that includes user
supplied inputs.
2. Attacker sends an attack in the form data
3. Application forwards attack to the database in a SQL
query
4. Database runs query containing attack and sends encrypted
results back to application
5. Application decrypts data as normal and sends results to
the user
Some Malicious line of code where SQL Injection is
possible
#Scenario 1: The application uses
untrusted data in the construction of the following vulnerable SQL call:
String query = "SELECT * FROM accounts
WHERE custID='" + request.getParameter("id") + "'";
#Scenario 2: Similarly, blind trust in
frameworks may result in queries that are still vulnerable, (e.g., Hibernate
Query Language (HQL)):
Query HQLQuery = session.createQuery(“FROM
accounts
WHERE custID='“ +
request.getParameter("id") + "'");
Why those lines can be effected by SQL Injection
#Scenario 1: The
application uses untrusted data in the construction of the following vulnerable
SQL call:
String
query = "SELECT * FROM accounts WHERE custID='" +
request.getParameter("id") + "'";
request.getParameter("id“)
containing code “1’ OR 1 = 1”
#Scenario
2: Similarly, blind trust in frameworks may result in queries that are still
vulnerable, (e.g., Hibernate Query Language (HQL)):
Query
HQLQuery = session.createQuery(“FROM accounts
WHERE
custID='“ + request.getParameter("id") + "'");
request.getParameter("id“)
containing code “1’
OR 1 = 1”
Some
general guidelines:
"Connections"
between systems are highly vulnerable
Always assume that
data coming from user could be "evil"
be sure to include
"evil" use cases and user stories in your design
Ideally, only allow
the user to select among "safe" options
no generic text
allowed
If user-input text is
needed, use parameterized queries
clean up quotes,
parenthesis, and SQL comments
Use a battle-tested
library for protecting your database
Java
PreparedStatement, OWASP's ESAPI codecs
Comments
Post a Comment