Aller au contenu

SQL injection (ARCH6100)

Ce contenu n’est pas encore disponible dans votre langue.

Key ruby.security.sql-injection · Severity error · Category security · CWE CWE-89

Interpolating or concatenating user input directly into SQL text lets attackers alter the query structure to exfiltrate or modify data.

def search(name)
User.where("name = '#{name}'").to_a
end
def search(name)
User.where("name = ?", name).to_a
end

Never embed input into SQL; use bound parameters or parameter placeholders.