Methods of SQL injections detection

Detection of SQL injections is somewhat similar to email spam filtration. The problems, developers of such systems to solve, are also similar.

So let’s take a look at the methods of spam filtration used by email servers:

  • Analyzing text of messages with various algorithms (Bayesian filtering for example).
  • Content filtering. It includes looking for spam signs such as links, product offers, key words etc. in the text of messages.
  • Filtering based on statistical information about decisions made by other email server users (looking if they marked similar messages as spam).
  • Using information on credibility of the mail server received from other services.

Each of these tests is divided into sub-tests. A certain “cost” (in points) is assigned for each sub-test. If the incoming message passes the sub-test, its points are added to the test overall score. The score could be just as positive so to negative. When the testing of a message is completed, the anti-spam system sums the overall score. The higher the score, the higher the possibility that the tested message contains spam.

For example, Spam Assassin spam filter features customizable threshold. If the test’s overall score exceeds the threshold, the message is considered as spam. Usually, the threshold is configured in such a way that it is not enough for a message to pass one test to exceed the threshold value (to be marked as spam). Operation principles of other filters are similar to Spam Assassin’s.

Any spam filtering method alone guaranties full protection against unwanted messages as well as against false alarms. That’s why in practice a combination of various methods is used. Configuring overall threshold and sub-tests “cost” needs to determine filter’s “level of suspicion”.

SQL injection filtering works almost similar to spam filters. On DAF level, in most cases you encounter valid SQL code, that’s why it’s necessary to use indirect signs when determining if the query is SQL-injected.

DataSunrise can detect SQL injections based on the following signs.

  • Number of invalid queries coming from a certain host or issued by a certain client.
  • Presence of constant conditions in the query which always return TRUE or FALSE.
  • Are there commentaries in the query body and do these commentaries (they) contain SQL query parts.
  • OR and UNION blocks in the query code.
  • Other conditions.
  • Ability to detect each sign alone is not sufficient for recognition of SQL injection attack, but the capability to spot all these signs in a query enables DataSunrise to establish essential protection.

    And at last it should be mentioned that full protection against SQL injection attacks could be achieved only by using quality and properly tested application server.

    DataSunrise supports all major databases and data warehouses including Oracle or Exadata. It also supports IBM DB2, IBM Netezza, MySQL, MariaDB, Greenplum, Amazon Aurora, Amazon Redshift, Microsoft SQL Server, Azure SQL, Teradata and more. You are welcome to download a free trial if would like to install on your premises. In case you are a cloud user and run your database on Amazon AWS or Microsoft Azure you can get it from AWS market place or Azure market place.