{"id":"CVE-2021-29510","aliases":["CVE-2021-29510","GHSA-5jqp-qgf6-3pvh","PYSEC-2021-47"],"related":[],"kind":"vulnerability","state":"published","title":"Use of \"infinity\" as an input to datetime and date fields causes infinite loop in pydantic","summary":"Pydantic is a data validation and settings management using Python type hinting. In affected versions passing either `'infinity'`, `'inf'` or `float('inf')` (or their negatives) to `datetime` or `date` fields causes validation to run forever with 100% CPU usage (on one CPU). Pydantic has been patched with fixes available in the following versions: v1.8.2, v1.7.4, v1.6.2. All these versions are available on pypi(https://pypi.org/project/pydantic/#history), and will be available on conda-forge(https://anaconda.org/conda-forge/pydantic) soon. See the changelog(https://pydantic-docs.helpmanual.io/) for details. If you absolutely can't upgrade, you can work around this risk using a validator(https://pydantic-docs.helpmanual.io/usage/validators/) to catch these values. This is not an ideal solution (in particular you'll need a slightly different function for datetimes), instead of a hack like this you should upgrade pydantic. If you are not using v1.8.x, v1.7.x or v1.6.x and are unable to upgrade to a fixed version of pydantic, please create an issue at https://github.com/samuelcolvin/pydantic/issues requesting a back-port, and we will endeavour to release a patch for earlier versions of pydantic.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Pydantic is a data validation and settings management using Python type hinting. In affected versions passing either `'infinity'`, `'inf'` or `float('inf')` (or their negatives) to `datetime` or `date` fields causes validation to run forever with 100% CPU usage (on one CPU). Pydantic has been patched with fixes available in the following versions: v1.8.2, v1.7.4, v1.6.2. All these versions are available on pypi(https://pypi.org/project/pydantic/#history), and will be available on conda-forge(https://anaconda.org/conda-forge/pydantic) soon. See the changelog(https://pydantic-docs.helpmanual.io/) for details. If you absolutely can't upgrade, you can work around this risk using a validator(https://pydantic-docs.helpmanual.io/usage/validators/) to catch these values. This is not an ideal solution (in particular you'll need a slightly different function for datetimes), instead of a hack like this you should upgrade pydantic. If you are not using v1.8.x, v1.7.x or v1.6.x and are unable to upgrade to a fixed version of pydantic, please create an issue at https://github.com/samuelcolvin/pydantic/issues requesting a back-port, and we will endeavour to release a patch for earlier versions of pydantic.","source":"cvelist"},{"lang":"en","text":"Impact\n\nPassing either 'infinity', 'inf' or float('inf') (or their negatives) to datetime or date fields causes validation to run forever with 100% CPU usage (on one CPU).\nPatches\n\nPydantic is be patched with fixes available in the following versions:\n\n    v1.8.2\n    v1.7.4\n    v1.6.2\n\nAll these versions are available on pypi, and will be available on conda-forge soon.\n\nSee the changelog for details.\nWorkarounds\n\nIf you absolutely can't upgrade, you can work around this risk using a validator to catch these values, brief demo:\n\nfrom datetime import date\nfrom pydantic import BaseModel, validator\n\nclass DemoModel(BaseModel):\n    date_of_birth: date\n\n    @validator('date_of_birth', pre=True)\n    def skip_infinite_values(cls, v):\n        try:\n            seconds = float(v)\n        except (ValueError, TypeError):\n            return v\n        else:\n            if seconds == float('inf'):\n                return date.max\n            elif seconds == float('-inf'):\n                return date.min\n            else:\n                return seconds\n\nNote: this is not an ideal solution (in particular you'll need a slightly different function for datetimes), instead of a hack like this you should upgrade pydantic.\n\nIf you are not using v1.8.x, v1.7.x or v1.6.x and are unable to upgrade to a fixed version of pydantic, please create an issue requesting a back-port, and we will endeavour to release a patch for earlier versions of pydantic.\nReferences\n\nThis was fixed in commit 7e83fdd.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Pydantic es un sistema de validación de datos y gestión de configuraciones que utiliza las sugerencias de tipo de Python. En las versiones afectadas, pasar `'infinity'`, `'inf'` o `float('inf')` (o sus negativos) a los campos `datetime` o `date` hace que la validación se ejecute eternamente con un uso del 100% de la CPU (en una CPU). Pydantic ha sido parcheado con correcciones disponibles en las siguientes versiones: v1.8.2, v1.7.4, v1.6.2. Todas estas versiones están disponibles en pypi(https://pypi.org/project/pydantic/#history), y estarán disponibles en conda-forge(https://anaconda.org/conda-forge/pydantic) pronto. Consulta el registro de cambios(https://pydantic-docs.helpmanual.io/) para más detalles. Si no puedes actualizar absolutamente, puedes evitar este riesgo usando un validador(https://pydantic-docs.helpmanual.io/usage/validators/) para capturar estos valores. Esta no es una solución ideal (en particular, necesitarás una función ligeramente diferente para las fechas), en lugar de un hack como este deberías actualizar pydantic. Si no estás usando v1.8.x, v1.7.x o v1.6.x y no puedes actualizar a una versión fija de pydantic, por favor crea un issue en https://github.com/samuelcolvin/pydantic/issues solicitando un back-port, y nos esforzaremos en liberar un parche para versiones anteriores de pydantic","source":"nvd"}],"published":"2021-05-13T18:55:11.000Z","modified":"2026-07-08T06:29:37.051Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L","score":3.3,"rating":"LOW"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L","score":3.3,"rating":"LOW"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L","score":3.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:L/Au:N/C:N/I:N/A:P","score":5,"rating":"MEDIUM"}],"cwes":["CWE-835"],"affected":[{"ranges":[{"version":">= 1.8.0, < 1.8.2","status":"affected"},{"version":">= 1.7.0, < 1.7.4","status":"affected"},{"version":"< 1.6.2","status":"affected"}],"vendor":"samuelcolvin","product":"pydantic","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.6.2"}],"ecosystem":"PyPI","package":"pydantic","purl":"pkg:pypi/pydantic","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"1.8","status":"affected","fixed":"1.8.2"}],"ecosystem":"PyPI","package":"pydantic","purl":"pkg:pypi/pydantic","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"1.7","status":"affected","fixed":"1.7.4"}],"ecosystem":"PyPI","package":"pydantic","purl":"pkg:pypi/pydantic","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"1.6.2"},{"status":"affected","introduced":"1.7","fixed":"1.7.4"},{"status":"affected","introduced":"1.8","fixed":"1.8.2"}],"vendor":"pydantic","product":"pydantic","cpe":"cpe:2.3:a:pydantic:pydantic:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"status":"affected","version":"33"},{"status":"affected","version":"34"}],"vendor":"fedoraproject","product":"fedora","cpe":"cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"git","introduced":"0","status":"affected","fixed":"7e83fdd2563ffac081db7ecdf1affa65ef38c468"},{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.6.2"},{"type":"ecosystem","introduced":"1.7","status":"affected","fixed":"1.7.4"},{"type":"ecosystem","introduced":"1.8","status":"affected","fixed":"1.8.2"}],"ecosystem":"PyPI","package":"pydantic","purl":"pkg:pypi/pydantic","repo":"https://github.com/samuelcolvin/pydantic","source":"pysec"}],"references":[{"url":"https://github.com/samuelcolvin/pydantic/security/advisories/GHSA-5jqp-qgf6-3pvh","tags":["advisory","mitigation","patch","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/samuelcolvin/pydantic/commit/7e83fdd2563ffac081db7ecdf1affa65ef38c468","tags":["fix","patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/UMKAJX4O6IGBBCE32CO2G7PZQCCQSBLV/","tags":["vendor-advisory","x-refsource-fedora","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/S2HT266L6Q7H6ICP7DFGXOGBJHNNKMKB/","tags":["vendor-advisory","x-refsource-fedora","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/UEFWM7DYKD2ZHE7R5YT5EQWJPV4ZKYRB/","tags":["vendor-advisory","x-refsource-fedora","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-29510","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/pydantic/pydantic/commit/1c24f1d74ba95ea985b50bdc001ce96c813229aa","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/pydantic/pydantic/commit/80e0dd3f752bef145dce12f160d262bb40ec8d47","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/pydantic/pydantic/commit/bdde15b7b947c94ca00fd6eb92da8db390a13520","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/pydantic/pydantic","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/pydantic/PYSEC-2021-47.yaml","tags":["web"],"sources":["ghsa"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/S2HT266L6Q7H6ICP7DFGXOGBJHNNKMKB","tags":["web"],"sources":["ghsa"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/UEFWM7DYKD2ZHE7R5YT5EQWJPV4ZKYRB","tags":["web"],"sources":["ghsa"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/UMKAJX4O6IGBBCE32CO2G7PZQCCQSBLV","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-29510","url":"https://www.cve.org/CVERecord?id=CVE-2021-29510","licence":"CVE Terms of Use","modified":"2024-08-03T22:11:05.442Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-5jqp-qgf6-3pvh","url":"https://github.com/advisories/GHSA-5jqp-qgf6-3pvh","licence":"CC-BY-4.0","modified":"2026-07-08T06:29:37.051Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-29510","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-29510","licence":"Public domain","modified":"2026-06-17T03:47:48.193Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2021-47","url":"https://osv.dev/vulnerability/PYSEC-2021-47","licence":"CC-BY-4.0","modified":"2026-06-08T11:15:47.381Z"}],"updatedAt":"2026-11-25T22:58:01.337Z","epss":{"score":0.00975,"percentile":0.6309,"date":"2026-12-01T12:00:22.000Z"}}