One of the hot spots for CVEs in Django these days is our interface with the spatial libraries required by GeoDjango (GDAL, GEOS, and PROJ). Do we need to update the Django docs to be honest about how “gray” the security posture is?
While we are grateful for the security support these libraries offer, that support is more limited than what we get from Python: perhaps only a fix in the next patch or feature release. Public web services may not even be a primary use case for these analysis libraries.
For example, the GDAL Security Considerations document offers advice to:
- always run the latest version
- restrict filesystem access with a sandbox
- rebuild from source with a compile-time option to disable
curl - limit allowed drivers at compile- or runtime, since the chaining of drivers yields a “not obvious” attack surface
This is miles away from the recipe in Django’s docs to sudo apt-get install binutils libproj-dev gdal-bin.
Members of the Django Security Team are actively engaging with the maintainers on some follow-ups, as they prefer to analyze security reports in the open. One told me that GeoJSON clients are simply not prepared for malicious inputs:
Most current file formats and their parsers have been written in good faith. They are not prepared for counterfeit data.
Given that, Django’s Security Team often has to decide how much effort to expend re-implementing a safer parser in Django before forwarding inputs to spatial libraries.
When the attack surface is wide, we’ve bitten the bullet and re-implemented. One particularly tricky case for GEOS took a second try to get right.
For one issue fixed in today’s Django releases, we had:
- a narrow attack surface
- reimplementing the parsing would have been error prone / impossible to avoid breaking valid cases
- a “safer” method was available in GDAL 3.9+
…so we just used the safer method if the GDAL version was 3.9 or better, and issued a system check warning (that could be silenced if you weren’t using the niche functionality) if you were using GeoDjango on anything lower.
Django generally “officially” supports the last five years of spatial library releases. This is a practice, not documented, I don’t think. However, in these times drenched with AI findings, this is in tension with “Django is secure by default” if the official upstream advice is “Upgrade to the latest versions … that might contain fixes for some vulnerabilities.”
Is the system check framework the right place to be collecting this knowledge about where Django does not provide total protection against malicious inputs? (Developers ignore warnings.) And/or, should it be collected in Django’s docs, by adding a “Secure version” column to the versions table, with footnotes about Django’s various levels of protections?
Will “five years” really hold up in the AI-vuln era? GDAL 3.9 will be approximately 3 years old when Django 6.2 is released in April. It’s tempting to make that the minimum version and drop today’s system check (or elevate it to an error) so that the 6.2 LTS has the best security posture. But GDAL is not the easiest to install.
(For reference, on Django’s 6.1 branch, we had to alter the postgis.yml workflow to add an unstable apt repository to get GDAL 3.9 and pass our own test cases, even though it’s over two years old.)
GeoDjango users, what would be most helpful here, in terms of policy and docs?