Skip to content

Suspected breaking change in libmaxminddb v1.13.x #16

Closed

Description

@plivius

Hello @vimt,

First of all thanks for your efforts on this package, it has proven valuable over the last few years. 👍

After we've recently updated libmaxminddb from v1.12.x to v1.13.x on our environments, we encountered a suspected breaking change: MMDB-files generated with this package are no longer readable, possibly due to recently introduced stricter validation in release v1.13.x.

Tested with libmaxminddb v1.13.2:

  • OSX 15.7.4
  • Fedora 43
writer = MMDBWriter()
writer.insert_network(IPSet(['1.1.0.0/24', '1.1.1.0/24']), {'country': 'COUNTRY', 'isp': 'ISP'})
writer.to_db_file('test.mmdb')
$ mmdblookup --file test.mmdb --ip 1.1.0.0
Can't open test.mmdb - The MaxMind DB file's data section contains bad data (unknown data type or corrupt data)

Activity

  1. added a commit that references this issue on Mar 3, 2026
    cc23dcf
  2. vimt commented on Mar 3, 2026

    @vimt
    Owner

    Thanks for reporting this! I've identified the root cause and submitted a fix in #17.

    Root Cause

    libmaxminddb v1.13.0 added a new validation check in get_entry_data_list() (release notes):

    if (offset >= mmdb->data_section_size ||
        size > (mmdb->data_section_size - offset) / 2) {
        return MMDB_INVALID_DATA_ERROR;
    }

    This check is triggered during MMDB_open → read_metadata → populate_description_metadata, which calls MMDB_get_entry_data_list to parse the metadata.

    In our metadata encoding, description was the last field. When description is an empty dict {} (the default when no languages are specified), the metadata section ends with \xe0 (MAP with 0 entries). The offset_to_next after this byte exactly equals metadata_section_size, causing offset >= data_section_size to evaluate to true — hence the "bad data" error.

    Fix

    Reorder metadata fields so that build_epoch (a scalar UINT64, not subject to the MAP/ARRAY validation) is always the last entry. This ensures empty description or languages values are never at the tail of the metadata section.

    The fix is a one-line change in _build_meta() — just swapping the order of description and build_epoch.

  3. added a commit that references this issue on Mar 3, 2026
  4. plivius commented on Mar 4, 2026

    @plivius
    Author

    Hello @vimt,
    Brilliant, thanks for the quick follow up and RCA, much appreciated!
    Confirmed: Everything operational again after upgrading this packages to v0.2.6. 👍

  5. added a commit that references this issue on Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions