PostgreSQL & Active Record: Two SQL Injection Vulnerabilities
Join the DZone community and get the full member experience.
Join For FreeIf you're working with Active Record and PostgreSQL, you may want to be aware of a pair of SQL injection vulnerabilities publicized by Rafael Mendonça França. According to his mailing list email archived here on oss-sec, the vulnerabilities affect PostgreSQL versions above 2.0, and rely on some of the unconventional data types found in Postgres:
Only applications which query against either bitstring or range types are vulnerable. The particular data types affected depend on the version of Rails you're using, but the vulnerable code will look the same. Vulnerable code will take either take the form of:
Model.where(bitstring: params[:some_value])
Model.where(range: params[:from]..params[:to])
The specific versions affected is included below, however all users running an affected release should upgrade immediately.
According to França, workarounds are not really practical at this point, and upgrading is definitely recommending, and for those who cannot currently upgrade, patches are available, at least for users of more recent versions.
If you're using an older version, it's probably time to upgrade. Check out França's email transcript for all the details.
Opinions expressed by DZone contributors are their own.
Comments