Skip to content

Commit 2f1cfa8

Browse files
authored
Add annotate arguments as sqli sink
1 parent 3bacb18 commit 2f1cfa8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ruby/ql/test/query-tests/security/cwe-089/ActiveRecordInjection.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,17 @@ def yet_another_handler
137137
Admin.delete_by(params[:admin_condition])
138138
end
139139
end
140+
141+
class AnnotatedController < ActionController::Base
142+
def index
143+
name = params[:user_name]
144+
# GOOD: string literal arguments not controlled by user are safe for annotations
145+
users = User.annotate("this is a safe annotation").find_by(user_name: name)
146+
end
147+
148+
def unsafe_action
149+
name = params[:user_name]
150+
# BAD: user input passed into annotations are vulnerable to SQLi
151+
users = User.annotate("this is an unsafe annotation:#{params[:comment]}").find_by(user_name: name)
152+
end
153+
end

0 commit comments

Comments
 (0)