Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are ORM's vulnerable for SQL injection?

When using ORM's (Entity Framework, LINQ to SQL, NHibernate ...), are SQL injection attacks mitigated by design?

If not, where should I be doing some extra validation/scrubbing to prevent a vulnerability?

like image 289
Brandon Avatar asked Mar 02 '11 20:03

Brandon


People also ask

What field is vulnerable to SQL injection?

The artist parameter is vulnerable to SQL Injection. The following payload modifies the query to look for an inexistent record. It sets the value in the URL query string to -1 . Of course, it could be any other value that does not exist in the database.

Where is the vulnerability to SQL injection introduced?

SQL injection in different parts of the query Most SQL injection vulnerabilities arise within the WHERE clause of a SELECT query.

What types of databases are more vulnerable to SQL injections?

If a web application or website uses SQL databases like Oracle, SQL Server, or MySQL, it is vulnerable to an SQL injection attack. Hackers use SQL injection attacks to access sensitive business or personally identifiable information (PII), which ultimately increases sensitive data exposure.

Does using ORM prevent SQL injection?

The benefits of using an ORM tool include quick generation of an object layer to communicate to a relational database, standardize code templates for these objects, and that they usually provide a set of safe functions to protect against SQL Injection attacks.


1 Answers

Most, if not all, mainstream ORMs use parametrized SQL, which will protect you from a direct SQL injection attack. However parametrized SQL at the application layer will not protect you from latent SQL injection attacks. These occur when something down the line, other than the ORM, directly concatenates user input in a SQL statement (such as a batch run stored procedure that concatenates user input to create a non-parametrized dynamic query). Note that this isn't an ORM issue at all, but I thought I'd bring it up to point out that parametrized SQL only protects you from injections if it is used everywhere, not just in the ORM.

like image 118
Daniel Auger Avatar answered Oct 01 '22 14:10

Daniel Auger