Opened 5 hours ago
Last modified 5 hours ago
#36588 new Cleanup/optimization
Harden `django.utils.archive` against decompression bombs
Reported by: | Natalia Bidart | Owned by: | |
---|---|---|---|
Component: | Utilities | Version: | dev |
Severity: | Normal | Keywords: | archive |
Cc: | Jake Howard | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The django.utils.archive
module is an internal utility used by startapp
and startproject
when the --template
option is provided. The current implementation does not impose limits on extracted file size, file count, or decompression time. This makes it possible for a crafted archive to consume excessive resources.
Thanks to "junfuchong (chongfujun)" for the report.
This is not considered a security issue under Django's policy because:
- The module is undocumented and only used in local development commands.
- Our policy excludes issues that affect only local dev, and these commands are not intended to run on untrusted archives in production.
Still, adding safeguards (such as maximum size or file count limits) would make the code more robust and user-friendly. This ticket tracks such hardening work after a conversation held within the Security Team.
Jake Howard said:
--template
argument about using untrusted templates, not only for extraction issues, but also because if they contain bad practices or backdoors, the new project would contain them too.zipfile
is probably safe as-is at least for our use case, andtarfile
has extraction filters since 3.12 to mitigate much of the weirdness. We might even be able to useshutil.unpack_archive
entirely (more investigation needed).