Over a million developers have joined DZone.

PostgreSQL & Active Record: Two SQL Injection Vulnerabilities

DZone's Guide to

PostgreSQL & Active Record: Two SQL Injection Vulnerabilities

· Java Zone ·
Free Resource

Build vs Buy a Data Quality Solution: Which is Best for You? Gain insights on a hybrid approach. Download white paper now!

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.

Build vs Buy a Data Quality Solution: Which is Best for You? Maintaining high quality data is essential for operational efficiency, meaningful analytics and good long-term customer relationships. But, when dealing with multiple sources of data, data quality becomes complex, so you need to know when you should build a custom data quality tools effort over canned solutions. Download our whitepaper for more insights into a hybrid approach.


Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}