Search |
|||||||||||
Top 10 web security vulnerabilities number 2: Injection FlawsPosted by caroljmcdonald on October 2, 2009 at 3:35 PM PDT
OWASP Top 10 number 2: Injection Flaws
Number 2 in the Top
10 most critical web application security vulnerabilities
identified by the Open
Web Application Security Project (OWASP)
is Injection Flaws. Injection happens whenever an attacker's data is
able to modify a query or command sent to a database, LDAP server,
operating system or other Interpreter. Types of injections are SQL,
LDAP, XPath, XSLT, HTML, XML, OS command... SQL injection
and Cross-Site
Scripting account for more than 80% of the vulnerabilities being
discovered against Web applications (SANS Top Cyber
Security Risks). |
|||||||||||
"select * from MYTABLE where name=" + parameter |
"select * from MYTABLE where name= 'name' OR 'a'='a'; |
"select * from MYTABLE; |
"select * from MYTABLE where name= 'name' OR 'a'='a'; delete from MYTABLE; |
"select * from MYTABLE; delete from MYTABLE; |
String empId= req.getParameter("empId") // input parameter |
|
| String
selectStatement = "SELECT * FROM Employee WHERE id = ? "; PreparedStatement pStmt = con.prepareStatement(selectStatement); pStmt.setString(1, empId); |
| q =
entityManager.createQuery(“select e from Employee e WHERE ” + “e.id = ':id'”); q.setParameter(“id”, empId); |
QueryBuilder qb = em.getQueryBuilder(); CriteriaQuery<Employee> q = qb.createQuery(Employee.class); Root<Employee> e = q.from(Employee.class); ParameterExpression<String> id = cb.parameter(String.class); TypedQuery<Employee> query = em.createQuery( q.select(e).where(cb.equal(e.get(Employee_.id), id) ); query.setParameter(id, empId); |
|
|