Overview
| Artifact ID: | 6c76db6c7aa83811399ffb7f126f5d99381cd57183b050a5805e4cabdfb27047 |
|---|---|
| Ticket: | 9563b8eeeca59ca891df8406c80ae71ae6a73b57
Possible zlib compression bomb vulnerabilities |
| User & Date: | dkf on 2026-06-24 15:56:56 |
Changes
- icomment:
After thinking about this more, I'm going to be using this sort of thing as a test case rather than as an arbitrary guard rail. Code that reads from really untrusted sources needs to bound the amount that it actually reads. Compression algorithms don't change that at all (after all, checking the file size ahead of time leaves TOCTOU vulnerabilities). Tcl doesn't impose a policy limit on how much is accepted (as it depends on the application) but does give the tools to let user code decide that. We _may_ choose to provide a way to let `zlib inflate` (and `zlib decompress` and `zlib gunzip`, which are really the same thing in this respect) impose a limit on the amount of data produced, but _both the stream and channel APIs already have such capabilities available_ (and streams always store compressed data) in that they allow taking fixed/bounded-size pieces of the data, and the user can decide how many to take before rejecting. The tools for mitigating this sort of thing exist, and have existed all along since the inception of the modern `zlib` command in 8.6. Tcl _does not_ prevent users from writing something silly if they want. Adding arbitrary restrictions, such as on how much data can be compressed or what compression ratio may be used, prevents other conforming applications from doing what they want. High memory consumption _may_ be a problem in some cases, but it's not in all and we shouldn't fussily prevent it.
- login: "dkf"
- mimetype: "text/x-markdown"