Yes it is. Each time you insert user input into the query string, it is vulnerable. If month is:
5' AND '8'; DROP TABLE timeslots;
You may have serious problems. Not to mention the drop database, etc.
I did not reproduce this particular request, but something similar [I had to add) to my request due to the use of the act_as_paranoid plugin]:
SomeModel.pluck(:id) => [1, 2, 4, 3, 5, 6] abc = 'a\');delete from some_models where id=6;--' User.where("name = '#{abc}'") => [] SomeModel.pluck(:id) => [1, 2, 4, 3, 5]
The reason the attack is possible is because I could provide ' and -- (which starts to comment). When you use the proposed method, that is, use .where ("name =?", "My_name"), then the attack will be impossible. Check this:
abc = 'a\');delete from some_models where id=5;
This is the first request:
User Load (1.5ms) SELECT "users".* FROM "users" WHERE ("users"."deleted_at" IS NULL) AND (name = 'a');delete from some_models where id=6;
This is the second
User Load (1.0ms) SELECT "users".* FROM "users" WHERE ("users"."deleted_at" IS NULL) AND (name = 'a'');delete from some_models where id=5;--')
Note the extra ' in the second - query(name = 'a'')