So, I played with my MS SQL Server 2008 to find out how it is protected against SQL injection. The application allows users to create views in the database.
Now consider the following:
create view dbo.[]]; drop database foo
This creates a view with the name ]; drop database foo-- ]; drop database foo-- . It is valid and you can select it (returns the number 1, obviously).
Strange thing # 1:
In SQL Management Studio, the query SELECT [hi!] FROM [dbo].[]]; drop database foo--] SELECT [hi!] FROM [dbo].[]]; drop database foo--] red-underlined as invalid, stating that the object name is not valid. However, it executes and returns 1.
Strange thing # 2:
Calling OBJECT_ID(']; drop database foo--') yields NULL (which means the object does not exist), but the following query returns the view information properly:
select * from sys.objects where name = ']; drop database foo--';
Are these errors or not enough points?
GSerg source share