Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

PostgreSQL & Active Record: Two SQL Injection Vulnerabilities

DZone's Guide to

PostgreSQL & Active Record: Two SQL Injection Vulnerabilities

· Java Zone
Free Resource

Get the Edge with a Professional Java IDE. 30-day free trial.

If 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.


Get the Java IDE that understands code & makes developing enjoyable. Level up your code with IntelliJ IDEA. Download the free trial.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}