Opened 2 months ago
Last modified 7 weeks ago
#36588 assigned Cleanup/optimization
Harden `django.utils.archive` against decompression bombs
| Reported by: | Natalia Bidart | Owned by: | Marcelo Elizeche Landó |
|---|---|---|---|
| Component: | Utilities | Version: | dev |
| Severity: | Normal | Keywords: | archive |
| Cc: | Jake Howard | Triage Stage: | Accepted |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | yes |
| 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.
Change History (7)
comment:1 by , 2 months ago
| Cc: | added |
|---|
comment:2 by , 2 months ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:3 by , 2 months ago
I've opened a PR to add the security warning to --template, which is separate from the hardening.
comment:7 by , 7 weeks ago
| Patch needs improvement: | set |
|---|
Jake Howard said:
--templateargument 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.zipfileis probably safe as-is at least for our use case, andtarfilehas extraction filters since 3.12 to mitigate much of the weirdness. We might even be able to useshutil.unpack_archiveentirely (more investigation needed).