diff -Nru pymongo-3.11.0/debian/changelog pymongo-3.11.0/debian/changelog --- pymongo-3.11.0/debian/changelog 2024-06-16 19:42:49.000000000 +0200 +++ pymongo-3.11.0/debian/changelog 2026-11-22 20:13:51.000000000 +0100 @@ -1,3 +1,17 @@ +pymongo (3.11.0-1+deb12u2) UNRELEASED; urgency=medium + + * Backport seven upstream security fixes to bookworm: + - Bound BSON regex reads and check buffer size arithmetic + (CVE-2026-106435, CVE-2026-96749). + - Restrict URI host decoding and reject Unix sockets as KMS endpoints + (CVE-2026-96748, CVE-2026-96747). + - Use explicit equality for GridFS file identifiers (CVE-2026-88029). + - Reject NUL characters in SASL PLAIN credentials (CVE-2026-129926). + - Redact sensitive client options and URI diagnostics (CVE-2026-129927). + * Exercise the installed driver and C extensions in autopkgtest. + + -- Federico Molara Sun, 22 Nov 2026 20:13:51 +0100 + pymongo (3.11.0-1+deb12u1) bookworm; urgency=medium * QA upload diff -Nru pymongo-3.11.0/debian/patches/CVE-2026-106435.patch pymongo-3.11.0/debian/patches/CVE-2026-106435.patch --- pymongo-3.11.0/debian/patches/CVE-2026-106435.patch 1970-01-01 01:00:00.000000000 +0100 +++ pymongo-3.11.0/debian/patches/CVE-2026-106435.patch 2026-11-22 20:13:51.000000000 +0100 @@ -0,0 +1,68 @@ +Description: Bound BSON regex scans to the current document or array +Origin: backport, https://github.com/mongodb/mongo-python-driver/commit/bb8d4e195275e75bd94ebeffb53cc747d357fcf4 +Bug-Debian: https://bugs.debian.org/1150462 +Last-Update: 2026-11-22 + +diff --git a/bson/_cbsonmodule.c b/bson/_cbsonmodule.c +index 02d9105..0712307 100644 +--- a/bson/_cbsonmodule.c ++++ b/bson/_cbsonmodule.c +@@ -1931,7 +1931,7 @@ static PyObject* get_value(PyObject* self, PyObject* name, const char* buffer, + unsigned char bson_type = (unsigned char)buffer[(*position)++]; + + size_t key_size = strlen(buffer + *position); +- if (max < key_size) { ++ if (key_size >= end - *position) { + Py_DECREF(value); + goto invalid; + } +@@ -1942,7 +1942,7 @@ static PyObject* get_value(PyObject* self, PyObject* name, const char* buffer, + goto invalid; + } + to_append = get_value(self, name, buffer, position, bson_type, +- max - (unsigned)key_size, options); ++ end - *position, options); + Py_LeaveRecursiveCall(); + if (!to_append) { + Py_DECREF(value); +@@ -2199,24 +2199,33 @@ static PyObject* get_value(PyObject* self, PyObject* name, const char* buffer, + PyObject* pattern; + int flags; + size_t flags_length, i; +- size_t pattern_length = strlen(buffer + *position); +- if (pattern_length > BSON_MAX_SIZE || max < pattern_length) { ++ /* PYTHON-6110: Search for each NUL within the bytes remaining ++ * in the document rather than scanning the buffer. */ ++ const char* start = buffer + *position; ++ const char* pattern_nul = memchr(start, 0, max); ++ if (!pattern_nul) { ++ goto invalid; ++ } ++ size_t pattern_length = (size_t)(pattern_nul - start); ++ if (pattern_length > BSON_MAX_SIZE) { + goto invalid; + } + pattern = PyUnicode_DecodeUTF8( +- buffer + *position, pattern_length, ++ start, pattern_length, + options->unicode_decode_error_handler); + if (!pattern) { + goto invalid; + } + *position += (unsigned)pattern_length + 1; +- flags_length = strlen(buffer + *position); +- if (flags_length > BSON_MAX_SIZE || +- (BSON_MAX_SIZE - pattern_length) < flags_length) { ++ start += pattern_length + 1; ++ const char* flags_nul = memchr(start, 0, max - pattern_length - 1); ++ if (!flags_nul) { + Py_DECREF(pattern); + goto invalid; + } +- if (max < pattern_length + flags_length) { ++ flags_length = (size_t)(flags_nul - start); ++ if (flags_length > BSON_MAX_SIZE || ++ (BSON_MAX_SIZE - pattern_length) < flags_length) { + Py_DECREF(pattern); + goto invalid; + } diff -Nru pymongo-3.11.0/debian/patches/CVE-2026-129926.patch pymongo-3.11.0/debian/patches/CVE-2026-129926.patch --- pymongo-3.11.0/debian/patches/CVE-2026-129926.patch 1970-01-01 01:00:00.000000000 +0100 +++ pymongo-3.11.0/debian/patches/CVE-2026-129926.patch 2026-11-22 20:13:51.000000000 +0100 @@ -0,0 +1,17 @@ +Description: Reject NUL characters in SASL PLAIN credentials +Origin: backport, https://github.com/mongodb/mongo-python-driver/commit/138396e204acc90bacd482d612d84bd781e54542 +Last-Update: 2026-11-22 + +diff --git a/pymongo/auth.py b/pymongo/auth.py +index 3052b73..3d6ed85 100644 +--- a/pymongo/auth.py ++++ b/pymongo/auth.py +@@ -149,6 +149,8 @@ def _build_credentials_tuple(mech, source, user, passwd, extra, database): + # user can be None for temporary link-local EC2 credentials. + return MongoCredential(mech, '$external', user, passwd, props, None) + elif mech == 'PLAIN': ++ if (user and '\x00' in user) or (passwd and '\x00' in passwd): ++ raise ConfigurationError('PLAIN credentials cannot contain NUL characters.') + source_database = source or database or '$external' + return MongoCredential(mech, source_database, user, passwd, None, None) + else: diff -Nru pymongo-3.11.0/debian/patches/CVE-2026-129927.patch pymongo-3.11.0/debian/patches/CVE-2026-129927.patch --- pymongo-3.11.0/debian/patches/CVE-2026-129927.patch 1970-01-01 01:00:00.000000000 +0100 +++ pymongo-3.11.0/debian/patches/CVE-2026-129927.patch 2026-11-22 20:13:51.000000000 +0100 @@ -0,0 +1,222 @@ +Description: Redact sensitive client options and URI validation diagnostics +Origin: backport, https://github.com/mongodb/mongo-python-driver/commit/a663e8451e705206650a70f8ebf6386096fea041 +Last-Update: 2026-11-22 + +diff --git a/pymongo/common.py b/pymongo/common.py +index cab9d52..c4e9309 100644 +--- a/pymongo/common.py ++++ b/pymongo/common.py +@@ -751,7 +751,7 @@ def validate(option, value): + return option, value + + +-def get_validated_options(options, warn=True): ++def get_validated_options(options, warn=True, from_uri=False): + """Validate each entry in options and raise a warning if it is not valid. + Returns a copy of options with invalid entries removed. + +@@ -775,14 +775,43 @@ def get_validated_options(options, warn=True): + try: + validator = URI_OPTIONS_VALIDATOR_MAP.get( + normed_key, raise_config_error) +- value = validator(opt, value) +- except (ValueError, TypeError, ConfigurationError) as exc: +- if warn: +- warnings.warn(str(exc)) ++ if validator is validate_compressors: ++ value = validator(opt, value, from_uri=from_uri) + else: ++ value = validator(opt, value) ++ except OSError as exc: ++ if not from_uri: ++ raise ++ # Keep the file error and errno, but omit the supplied path. ++ error = type(exc)(exc.errno, "The %s file is not readable" % normed_key) ++ except (ValueError, TypeError, ConfigurationError) as exc: ++ if from_uri: ++ # Only known option names are safe in URI diagnostics. ++ if validator is raise_config_error: ++ message = "Unknown option" ++ elif validator in (validate_max_staleness, validate_positive_integer_or_none, ++ validate_non_negative_integer, validate_non_negative_integer_or_none, ++ validate_boolean_or_string, validate_timeout_or_none, ++ validate_timeout_or_zero, validate_timeout_or_none_or_zero, ++ validate_positive_float_or_zero): ++ # These diagnostics describe the expected type or range ++ # and never interpolate the rejected value. ++ message = str(exc) ++ else: ++ message = "Invalid value for %s" % normed_key ++ error = type(exc)(message) ++ elif not warn: + raise ++ else: ++ error = exc + else: + validated_options[get_setter_key(normed_key)] = value ++ continue ++ # Raise outside the handler so that the original text is not chained. ++ if warn and not isinstance(error, OSError): ++ warnings.warn(str(error)) ++ else: ++ raise error + return validated_options + + +diff --git a/pymongo/compression_support.py b/pymongo/compression_support.py +index b6662f2..c22ea71 100644 +--- a/pymongo/compression_support.py ++++ b/pymongo/compression_support.py +@@ -41,7 +41,7 @@ _NO_COMPRESSION = set(['ismaster']) + _NO_COMPRESSION.update(_SENSITIVE_COMMANDS) + + +-def validate_compressors(dummy, value): ++def validate_compressors(dummy, value, from_uri=False): + try: + # `value` is string. + compressors = value.split(",") +@@ -52,7 +52,8 @@ def validate_compressors(dummy, value): + for compressor in compressors[:]: + if compressor not in _SUPPORTED_COMPRESSORS: + compressors.remove(compressor) +- warnings.warn("Unsupported compressor: %s" % (compressor,)) ++ warnings.warn("Unsupported compressor" if from_uri else ++ "Unsupported compressor: %s" % (compressor,)) + elif compressor == "snappy" and not _HAVE_SNAPPY: + compressors.remove(compressor) + warnings.warn( +diff --git a/pymongo/mongo_client.py b/pymongo/mongo_client.py +index ef39cfc..f578e34 100644 +--- a/pymongo/mongo_client.py ++++ b/pymongo/mongo_client.py +@@ -1518,6 +1518,11 @@ class MongoClient(common.BaseObject): + else: + return 'document_class=%s.%s' % (value.__module__, + value.__name__) ++ if option in ('tlscertificatekeyfilepassword', 'ssl_pem_passphrase', ++ 'proxyusername', 'proxypassword'): ++ value = '' ++ elif option == 'authmechanismproperties' and 'AWS_SESSION_TOKEN' in value: ++ value = dict(value, AWS_SESSION_TOKEN='') + if option in common.TIMEOUT_OPTIONS and value is not None: + return "%s=%s" % (option, int(value * 1000)) + +diff --git a/pymongo/uri_parser.py b/pymongo/uri_parser.py +index 707fd14..fce1302 100644 +--- a/pymongo/uri_parser.py ++++ b/pymongo/uri_parser.py +@@ -26,7 +26,8 @@ else: + + from pymongo.common import ( + get_validated_options, INTERNAL_URI_OPTION_NAME_MAP, +- URI_OPTIONS_DEPRECATION_MAP, _CaseInsensitiveDictionary) ++ URI_OPTIONS_DEPRECATION_MAP, URI_OPTIONS_VALIDATOR_MAP, ++ _CaseInsensitiveDictionary) + from pymongo.errors import ConfigurationError, InvalidURI + from pymongo.srv_resolver import _HAVE_DNSPYTHON, _SrvResolver + +@@ -114,10 +115,13 @@ def parse_host(entity, default_port=DEFAULT_PORT): + "and ']' according to RFC 2732.") + host, port = host.split(':', 1) + if isinstance(port, string_type): +- if not port.isdigit() or int(port) > 65535 or int(port) <= 0: +- raise ValueError("Port must be an integer between 0 and 65535: %s" +- % (port,)) +- port = int(port) ++ try: ++ number = int(port) if port.isdigit() else 0 ++ except ValueError: ++ number = 0 ++ if not 0 < number <= 65535: ++ raise ValueError("Port must be an integer between 0 and 65535") ++ port = number + + # Normalize hostname to lowercase, since DNS is case-insensitive: + # http://tools.ietf.org/html/rfc4343 +@@ -149,7 +153,10 @@ def _parse_options(opts, delim): + options.setdefault(key, []).append(value) + else: + if key in options: +- warnings.warn("Duplicate URI option '%s'." % (key,)) ++ if key.lower() in URI_OPTIONS_VALIDATOR_MAP: ++ warnings.warn("Duplicate URI option '%s'." % key.lower()) ++ else: ++ warnings.warn("Duplicate URI option.") + if key.lower() == 'authmechanismproperties': + val = value + else: +@@ -278,7 +285,7 @@ def _normalize_options(options): + return options + + +-def validate_options(opts, warn=False): ++def validate_options(opts, warn=False, from_uri=False): + """Validates and normalizes options passed in a MongoDB URI. + + Returns a new dictionary of validated and normalized options. If warn is +@@ -291,10 +298,10 @@ def validate_options(opts, warn=False): + invalid options will be ignored. Otherwise invalid options will + cause errors. + """ +- return get_validated_options(opts, warn) ++ return get_validated_options(opts, warn, from_uri=from_uri) + + +-def split_options(opts, validate=True, warn=False, normalize=True): ++def split_options(opts, validate=True, warn=False, normalize=True, from_uri=True): + """Takes the options portion of a MongoDB URI, validates each option + and returns the options in a dictionary. + +@@ -328,7 +335,7 @@ def split_options(opts, validate=True, warn=False, normalize=True): + options = _handle_option_deprecations(options) + + if validate: +- options = validate_options(options, warn) ++ options = validate_options(options, warn, from_uri=from_uri) + if options.get('authsource') == '': + raise InvalidURI( + "the authSource database cannot be an empty string") +@@ -464,7 +471,7 @@ def parse_uri(uri, default_port=DEFAULT_PORT, validate=True, warn=False, + if '.' in dbase: + dbase, collection = dbase.split('.', 1) + if _BAD_DB_CHARS.search(dbase): +- raise InvalidURI('Bad database name "%s"' % dbase) ++ raise InvalidURI('Bad database name') + else: + dbase = None + +@@ -479,7 +486,7 @@ def parse_uri(uri, default_port=DEFAULT_PORT, validate=True, warn=False, + + if '/' in hosts: + raise InvalidURI("Any '/' in a unix domain socket must be" +- " percent-encoded: %s" % host_part) ++ " percent-encoded") + + fqdn = None + +@@ -506,7 +513,7 @@ def parse_uri(uri, default_port=DEFAULT_PORT, validate=True, warn=False, + dns_options = dns_resolver.get_options() + if dns_options: + parsed_dns_options = split_options( +- dns_options, validate, warn, normalize) ++ dns_options, validate, warn, normalize, from_uri=False) + if set(parsed_dns_options) - _ALLOWED_TXT_OPTS: + raise ConfigurationError( + "Only authSource and replicaSet are supported from DNS") +diff --git a/test/test_uri_parser.py b/test/test_uri_parser.py +index 8d1f55a..4972f25 100644 +--- a/test/test_uri_parser.py ++++ b/test/test_uri_parser.py +@@ -529,10 +529,7 @@ class TestURI(unittest.TestCase): + "&authMechanismProperties=AWS_SESSION_TOKEN:"+unquoted_colon) + with self.assertRaisesRegex( + ValueError, +- 'auth mechanism properties must be key:value pairs like ' +- 'SERVICE_NAME:mongodb, not AWS_SESSION_TOKEN:' +- ', did you forget to percent-escape the token with ' +- 'quote_plus?'): ++ '^Invalid value for authmechanismproperties$'): + parse_uri(uri) + + diff -Nru pymongo-3.11.0/debian/patches/CVE-2026-88029.patch pymongo-3.11.0/debian/patches/CVE-2026-88029.patch --- pymongo-3.11.0/debian/patches/CVE-2026-88029.patch 1970-01-01 01:00:00.000000000 +0100 +++ pymongo-3.11.0/debian/patches/CVE-2026-88029.patch 2026-11-22 20:13:51.000000000 +0100 @@ -0,0 +1,110 @@ +Description: Match GridFS file identifiers using explicit equality +Origin: backport, https://github.com/mongodb/mongo-python-driver/commit/fa676586ba4b399168a4d1d41c30dc2166cc44fd +Bug-Debian: https://bugs.debian.org/1147408 +Last-Update: 2026-11-22 + +diff --git a/gridfs/__init__.py b/gridfs/__init__.py +index f291e8c..3d976ad 100644 +--- a/gridfs/__init__.py ++++ b/gridfs/__init__.py +@@ -253,8 +253,8 @@ class GridFS(object): + ``delete`` no longer ensures indexes. + """ + _disallow_transactions(session) +- self.__files.delete_one({"_id": file_id}, session=session) +- self.__chunks.delete_many({"files_id": file_id}, session=session) ++ self.__files.delete_one({"_id": {"$eq": file_id}}, session=session) ++ self.__chunks.delete_many({"files_id": {"$eq": file_id}}, session=session) + + def list(self, session=None): + """List the names of all files stored in this instance of +@@ -302,7 +302,7 @@ class GridFS(object): + Added ``session`` parameter. + """ + if filter is not None and not isinstance(filter, abc.Mapping): +- filter = {"_id": filter} ++ filter = {"_id": {"$eq": filter}} + + _disallow_transactions(session) + for f in self.find(filter, *args, session=session, **kwargs): +@@ -413,6 +413,8 @@ class GridFS(object): + if kwargs: + f = self.__files.find_one(kwargs, ["_id"], session=session) + else: ++ if document_or_id is not None and not isinstance(document_or_id, abc.Mapping): ++ document_or_id = {"_id": {"$eq": document_or_id}} + f = self.__files.find_one(document_or_id, ["_id"], session=session) + + return f is not None +@@ -757,8 +759,8 @@ class GridFSBucket(object): + Added ``session`` parameter. + """ + _disallow_transactions(session) +- res = self._files.delete_one({"_id": file_id}, session=session) +- self._chunks.delete_many({"files_id": file_id}, session=session) ++ res = self._files.delete_one({"_id": {"$eq": file_id}}, session=session) ++ self._chunks.delete_many({"files_id": {"$eq": file_id}}, session=session) + if not res.deleted_count: + raise NoFile( + "no file could be deleted because none matched %s" % file_id) +@@ -933,7 +935,7 @@ class GridFSBucket(object): + Added ``session`` parameter. + """ + _disallow_transactions(session) +- result = self._files.update_one({"_id": file_id}, ++ result = self._files.update_one({"_id": {"$eq": file_id}}, + {"$set": {"filename": new_filename}}, + session=session) + if not result.matched_count: +diff --git a/gridfs/grid_file.py b/gridfs/grid_file.py +index 23c629b..4a14754 100644 +--- a/gridfs/grid_file.py ++++ b/gridfs/grid_file.py +@@ -70,7 +70,7 @@ def _grid_in_property(field_name, docstring, read_only=False, + + def setter(self, value): + if self._closed: +- self._coll.files.update_one({"_id": self._file["_id"]}, ++ self._coll.files.update_one({"_id": {"$eq": self._file["_id"]}}, + {"$set": {field_name: value}}) + self._file[field_name] = value + +@@ -224,9 +224,9 @@ class GridIn(object): + """Remove all chunks/files that may have been uploaded and close. + """ + self._coll.chunks.delete_many( +- {"files_id": self._file['_id']}, session=self._session) ++ {"files_id": {"$eq": self._file['_id']}}, session=self._session) + self._coll.files.delete_one( +- {"_id": self._file['_id']}, session=self._session) ++ {"_id": {"$eq": self._file['_id']}}, session=self._session) + object.__setattr__(self, "_closed", True) + + @property +@@ -267,7 +267,7 @@ class GridIn(object): + # them now. + self._file[name] = value + if self._closed: +- self._coll.files.update_one({"_id": self._file["_id"]}, ++ self._coll.files.update_one({"_id": {"$eq": self._file["_id"]}}, + {"$set": {name: value}}) + + def __flush_data(self, data): +@@ -494,7 +494,7 @@ class GridOut(object): + def _ensure_file(self): + if not self._file: + _disallow_transactions(self._session) +- self._file = self.__files.find_one({"_id": self.__file_id}, ++ self._file = self.__files.find_one({"_id": {"$eq": self.__file_id}}, + session=self._session) + if not self._file: + raise NoFile("no file in gridfs collection %r with _id %r" % +@@ -726,7 +726,7 @@ class _GridOutChunkIterator(object): + return self + + def _create_cursor(self): +- filter = {"files_id": self._id} ++ filter = {"files_id": {"$eq": self._id}} + if self._next_chunk > 0: + filter["n"] = {"$gte": self._next_chunk} + _disallow_transactions(self._session) diff -Nru pymongo-3.11.0/debian/patches/CVE-2026-96747.patch pymongo-3.11.0/debian/patches/CVE-2026-96747.patch --- pymongo-3.11.0/debian/patches/CVE-2026-96747.patch 1970-01-01 01:00:00.000000000 +0100 +++ pymongo-3.11.0/debian/patches/CVE-2026-96747.patch 2026-11-22 20:13:51.000000000 +0100 @@ -0,0 +1,18 @@ +Description: Reject Unix domain sockets in the KMS callback +Origin: backport, https://github.com/mongodb/mongo-python-driver/commit/44119d0f9dfa0224d84b03be702a6d9a5ef1dea7 +Bug-Debian: https://bugs.debian.org/1148967 +Last-Update: 2026-11-22 + +diff --git a/pymongo/encryption.py b/pymongo/encryption.py +index 9524708..730af52 100644 +--- a/pymongo/encryption.py ++++ b/pymongo/encryption.py +@@ -107,6 +107,8 @@ class _EncryptionIO(MongoCryptCallback): + endpoint = kms_context.endpoint + message = kms_context.message + host, port = parse_host(endpoint, _HTTPS_PORT) ++ if host.endswith(".sock"): ++ raise ConfigurationError("Invalid KMS endpoint") + ctx = get_ssl_context(None, None, None, None, None, None, True, True) + opts = PoolOptions(connect_timeout=_KMS_CONNECT_TIMEOUT, + socket_timeout=_KMS_CONNECT_TIMEOUT, diff -Nru pymongo-3.11.0/debian/patches/CVE-2026-96748.patch pymongo-3.11.0/debian/patches/CVE-2026-96748.patch --- pymongo-3.11.0/debian/patches/CVE-2026-96748.patch 1970-01-01 01:00:00.000000000 +0100 +++ pymongo-3.11.0/debian/patches/CVE-2026-96748.patch 2026-11-22 20:13:51.000000000 +0100 @@ -0,0 +1,64 @@ +Description: Decode host escapes only for socket paths and IPv6 zones +Origin: backport, https://github.com/mongodb/mongo-python-driver/commit/1e7a56db4649b14c4c9a6ac20aa4a8d0d1bb238a +Bug-Debian: https://bugs.debian.org/1148967 +Last-Update: 2026-11-22 + +diff --git a/pymongo/uri_parser.py b/pymongo/uri_parser.py +index 9c782ac..4077471 100644 +--- a/pymongo/uri_parser.py ++++ b/pymongo/uri_parser.py +@@ -339,7 +339,7 @@ def split_options(opts, validate=True, warn=False, normalize=True): + return options + + +-def split_hosts(hosts, default_port=DEFAULT_PORT): ++def split_hosts(hosts, default_port=DEFAULT_PORT, from_uri=False): + """Takes a string of the form host1[:port],host2[:port]... and + splits it into (host, port) tuples. If [:port] isn't present the + default_port is used. +@@ -358,10 +358,17 @@ def split_hosts(hosts, default_port=DEFAULT_PORT): + raise ConfigurationError("Empty host " + "(or extra comma in host list).") + port = default_port +- # Unix socket entities don't have ports ++ node = entity + if entity.endswith('.sock'): ++ if from_uri: ++ node = unquote_plus(entity) + port = None +- nodes.append(parse_host(entity, port)) ++ elif from_uri and entity.startswith('['): ++ node = entity.replace('%25', '%') ++ elif from_uri and '%' in entity: ++ raise InvalidURI("Percent-encoding is only allowed in Unix domain " ++ "socket paths and IPv6 zone indexes") ++ nodes.append(parse_host(node, port)) + return nodes + + +@@ -475,7 +482,6 @@ def parse_uri(uri, default_port=DEFAULT_PORT, validate=True, warn=False, + raise InvalidURI("Any '/' in a unix domain socket must be" + " percent-encoded: %s" % host_part) + +- hosts = unquote_plus(hosts) + fqdn = None + + if is_srv: +@@ -483,7 +489,7 @@ def parse_uri(uri, default_port=DEFAULT_PORT, validate=True, warn=False, + raise ConfigurationError( + "Cannot specify directConnection=true with " + "%s URIs" % (SRV_SCHEME,)) +- nodes = split_hosts(hosts, default_port=None) ++ nodes = split_hosts(hosts, default_port=None, from_uri=True) + if len(nodes) != 1: + raise InvalidURI( + "%s URIs must include one, " +@@ -511,7 +517,7 @@ def parse_uri(uri, default_port=DEFAULT_PORT, validate=True, warn=False, + if "ssl" not in options: + options["ssl"] = True if validate else 'true' + else: +- nodes = split_hosts(hosts, default_port=default_port) ++ nodes = split_hosts(hosts, default_port=default_port, from_uri=True) + if len(nodes) > 1 and options.get('directConnection'): + raise ConfigurationError( + "Cannot specify multiple hosts with directConnection=true") diff -Nru pymongo-3.11.0/debian/patches/CVE-2026-96749.patch pymongo-3.11.0/debian/patches/CVE-2026-96749.patch --- pymongo-3.11.0/debian/patches/CVE-2026-96749.patch 1970-01-01 01:00:00.000000000 +0100 +++ pymongo-3.11.0/debian/patches/CVE-2026-96749.patch 2026-11-22 20:13:51.000000000 +0100 @@ -0,0 +1,48 @@ +Description: Check the BSON buffer size before narrowing to int +Origin: backport, https://github.com/mongodb/mongo-python-driver/commit/6ab44be0e97c9d1d5a23725c4978fb25f3249485 +Bug-Debian: https://bugs.debian.org/1148967 +Last-Update: 2026-11-22 + +diff --git a/bson/buffer.c b/bson/buffer.c +index bb92ab3..df3900b 100644 +--- a/bson/buffer.c ++++ b/bson/buffer.c +@@ -18,6 +18,7 @@ + #define PY_SSIZE_T_CLEAN + #include "Python.h" + ++#include + #include + #include + +@@ -105,18 +106,25 @@ static int buffer_grow(buffer_t buffer, int min_length) { + * Return non-zero and sets MemoryError on allocation failure. + * Return non-zero and sets ValueError if `size` would exceed 2GiB. */ + static int buffer_assure_space(buffer_t buffer, int size) { +- int new_size = buffer->position + size; +- /* Check for overflow. */ +- if (new_size < buffer->position) { ++ long long new_size; ++ if (size < 0) { + PyErr_SetString(PyExc_ValueError, + "Document would overflow BSON size limit"); + return 1; + } + +- if (new_size <= buffer->size) { ++ /* Compute in a wider type so the addition cannot overflow `int`. */ ++ new_size = (long long)buffer->position + (long long)size; ++ if (new_size > INT_MAX) { ++ PyErr_SetString(PyExc_ValueError, ++ "Document would overflow BSON size limit"); ++ return 1; ++ } ++ ++ if ((int)new_size <= buffer->size) { + return 0; + } +- return buffer_grow(buffer, new_size); ++ return buffer_grow(buffer, (int)new_size); + } + + /* Save `size` bytes from the current position in `buffer` (and grow if needed). diff -Nru pymongo-3.11.0/debian/patches/series pymongo-3.11.0/debian/patches/series --- pymongo-3.11.0/debian/patches/series 2024-06-16 19:42:49.000000000 +0200 +++ pymongo-3.11.0/debian/patches/series 2026-11-22 20:13:51.000000000 +0100 @@ -1,2 +1,9 @@ fcb6a8ecbc98fceca138d74fb09b516b172bb4e0.patch 0002-CVE-2024-5629-PYTHON-4305-Fix-bson-size-check.patch +CVE-2026-106435.patch +CVE-2026-96749.patch +CVE-2026-96748.patch +CVE-2026-96747.patch +CVE-2026-88029.patch +CVE-2026-129926.patch +CVE-2026-129927.patch diff -Nru pymongo-3.11.0/debian/salsa-ci.yml pymongo-3.11.0/debian/salsa-ci.yml --- pymongo-3.11.0/debian/salsa-ci.yml 1970-01-01 01:00:00.000000000 +0100 +++ pymongo-3.11.0/debian/salsa-ci.yml 2026-11-22 20:13:51.000000000 +0100 @@ -0,0 +1,3 @@ +--- +include: + - local: '/debian/gitlab-ci.yml' diff -Nru pymongo-3.11.0/debian/tests/control pymongo-3.11.0/debian/tests/control --- pymongo-3.11.0/debian/tests/control 1970-01-01 01:00:00.000000000 +0100 +++ pymongo-3.11.0/debian/tests/control 2026-11-22 20:13:51.000000000 +0100 @@ -0,0 +1,3 @@ +Tests: driver +Depends: python3-pymongo, python3-gridfs, python3-bson-ext [any-amd64 any-armel any-armhf any-i386 any-ia64 any-mipsel any-ppc64el], python3-pymongo-ext [any-amd64 any-armel any-armhf any-i386 any-ia64 any-mipsel any-ppc64el] +Restrictions: allow-stderr diff -Nru pymongo-3.11.0/debian/tests/driver pymongo-3.11.0/debian/tests/driver --- pymongo-3.11.0/debian/tests/driver 1970-01-01 01:00:00.000000000 +0100 +++ pymongo-3.11.0/debian/tests/driver 2026-11-22 20:13:51.000000000 +0100 @@ -0,0 +1,49 @@ +#!/usr/bin/python3 -I +import os +import subprocess +import unittest +from unittest.mock import Mock + +import bson +import gridfs +import pymongo +from bson.regex import Regex +from pymongo.uri_parser import parse_uri, split_hosts + + +class InstalledDriverTest(unittest.TestCase): + def test_bson_roundtrip(self): + doc = {"entries": [Regex("abc", "i"), {"n": 42}], "label": "bookworm"} + self.assertEqual(doc, bson.BSON.encode(doc).decode()) + interpreter_dir = "/usr/lib/python3/dist-packages/" + for module in (bson, gridfs, pymongo): + self.assertTrue(os.path.realpath(module.__file__).startswith(interpreter_dir)) + status = subprocess.run( + ["dpkg-query", "-W", "-f=${db:Status-Status}", "python3-bson-ext"], + capture_output=True, text=True) + if status.stdout == "installed": + self.assertTrue(bson.has_c()) + self.assertTrue(pymongo.has_c()) + + def test_client_options(self): + with pymongo.MongoClient(connect=False, tlsCertificateKeyFilePassword="example") as client: + self.assertIn("ssl_pem_passphrase=''", repr(client)) + client = pymongo.MongoClient(username="alice", password="example", + authMechanism="PLAIN", connect=False) + client.close() + self.assertEqual(split_hosts("/tmp/a+b.sock"), [("/tmp/a+b.sock", None)]) + self.assertEqual(parse_uri("mongodb://%2Ftmp%2Fmongodb.sock/")["nodelist"], + [("/tmp/mongodb.sock", None)]) + + def test_gridfs_identifier_filter(self): + # Exercise the installed GridFS method without requiring a MongoDB server. + bucket = object.__new__(gridfs.GridFSBucket) + bucket._files = Mock() + bucket._chunks = Mock() + bucket.delete(42) + bucket._files.delete_one.assert_called_once_with({"_id": {"$eq": 42}}, session=None) + bucket._chunks.delete_many.assert_called_once_with({"files_id": {"$eq": 42}}, session=None) + + +if __name__ == "__main__": + unittest.main()