Add check for decompression bomb vulnerabilities

Open
#1,339 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
security

Research direction

Start with the linked gosec G110 rule and CWE-409 context, then review Bandit’s existing check conventions for standard-library decompression calls. Done means the requested direct calls and unbounded compressed-file reads are detected with appropriate coverage for the supported cases.

Written by the indexing model from the issue text.

Description

enhancement

Is your feature request related to a problem? Please describe.

Bandit currently does not detect potential decompression bomb vulnerabilities.

Describe the solution you'd like

Add a new check (for example, B114) that detects:

  1. Direct dangerous calls:

    • gzip.decompress()
    • zlib.decompress()
    • bz2.decompress()
    • lzma.decompress()
    • and other standard libs.
  2. Reading from compressed files without size limit:

    • gzip.open() followed by .read() without size argument

Describe alternatives you've considered

gosec (Go security checker) has a similar rule (G110).

Additional context

Dominant language
Python
Stars
8.4k
Forks
893
Avg merge
6h 52m
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PyCQA/bandit

All issues in PyCQA/bandit

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.