Skip to content

Commit 4be1670

Browse files
authored
Merge pull request #439 from maxmind/greg/stf-1488
Bound decoder resource use to prevent denial of service (STF-1488)
2 parents 95df7b5 + 976b641 commit 4be1670

8 files changed

Lines changed: 970 additions & 146 deletions

File tree

‎HISTORY.rst‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33
History
44
-------
55

6+
3.2.0
7+
+++++
8+
9+
* Added limits to pure Python record and metadata decoding to prevent denial
10+
of service from crafted databases: 65,536 values, 512 nesting levels, and
11+
2 MiB of string and bytes payload. Exceeding a limit raises
12+
``InvalidDatabaseError``. CPython may reach its recursion limit earlier,
13+
which raises the same error.
14+
* Rejected unsigned integers longer than 16 bytes and signed integers longer
15+
than 4 bytes before reading their payload.
16+
* Updated the vendored libmaxminddb to 1.14.0, which adds the same resource
17+
limits to the C extension.
18+
* Truncated reads that previously raised ``IndexError`` or ``struct.error``
19+
now raise ``InvalidDatabaseError``.
20+
* The pure Python reader now rejects invalid search tree sizes when opening
21+
a database.
22+
* Improved pure Python lookup performance.
23+
624
3.1.1 (2026-03-05)
725
++++++++++++++++++
826

‎README.rst‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ The module will return an ``InvalidDatabaseError`` if the database is corrupt
9494
or otherwise invalid. A ``ValueError`` will be thrown if you look up an
9595
invalid IP address or an IPv6 address in an IPv4 database.
9696

97+
The reader also raises ``InvalidDatabaseError`` when one record, or the
98+
database metadata, exceeds its resource limits: 65,536 decoded values, 512
99+
levels of nesting, or 2 MiB of string and bytes data. Real databases stay far
100+
below these limits. Python's recursion limit may stop decoding sooner.
101+
97102
Thread Safety
98103
-------------
99104

0 commit comments

Comments
 (0)