Skip to content

SQL Injection Type 5 :- The database isn’t readonly

The database isn’t readonly

So far, we have done nothing but query the database, and even though a SELECT is readonly, that doesn’t mean that SQL is. SQL uses the semicolon for statement termination, and if the input is not sanitized properly, there may be nothing that prevents us from stringing our own unrelated command at the end of the query.

The most drastic example is:

SELECT email, passwd, login_id, full_name
  FROM members
 WHERE email = 'x'; DROP TABLE members; --';  -- Boom!

The first part provides a dummy email address — ‘x’ — and we don’t care what this query returns: we’re just getting it out of the way so we can introduce an unrelated SQL command. This one attempts to drop (delete) the entire members table, which really doesn’t seem too sporting.

This shows that not only can we run separate SQL commands, but we can also modify the database. This is promising.

x  Powerful Protection for WordPress, from Shield Security
This Site Is Protected By
Shield Security