The vulnerability is an SQL injection flaw within the activerecord-jdbc-adapter library, specifically in the to_sql method located in lib/arjdbc/jdbc/adapter.rb. The root cause, as detailed in GitHub issue #322, is the improper use of Ruby's String#gsub method for substituting SQL bind parameters. The vulnerable code created a copy of the bind parameters and then used gsub with a block to replace '?' placeholders. However, if a bind value itself contained a '?', gsub would incorrectly perform a substitution on the already-placed value, corrupting the SQL query. This could be exploited by an attacker to manipulate the query structure. The fixing commit, 9bdf8b0940551885cebb28572497f4c8fa8d6a48, addresses this by modifying how the bind array is processed within the gsub block, preventing the double-substitution error. Therefore, the to_sql function is the precise location of the vulnerability.