Jupyter Server CORS Origin Validation Bypass via Regex
Jupyter Server versions 2.17.0 and earlier are vulnerable to a CORS origin validation bypass due to improper use of `re.match()` in validating the Origin header against the `allow_origin_pat` configuration, allowing attackers to bypass CORS restrictions.
Jupyter Server, a web-based interactive development environment, is susceptible to a CORS (Cross-Origin Resource Sharing) bypass vulnerability. This flaw arises from the server’s reliance on the re.match() function in Python’s regular expression library for validating the Origin header against the configured allow_origin_pat. The re.match() function, unlike re.fullmatch(), only anchors the regex at the beginning of the string, not the end. Consequently, an attacker can craft a malicious domain, such as http://trusted.example.com.evil.com/, which will pass the regex validation if the allow_origin_pat is intended to match trusted.example.com. This vulnerability impacts Jupyter Server versions 2.17.0 and prior. The fix was implemented in pull request #603 and patched in commits 057869a327c46730afede3eab0ca2d2e3e74acea and 49b34392feaa97735b3b777e3baf8f22f2a14ed8. Successful exploitation allows an attacker to bypass CORS restrictions, potentially leading to unauthorized data access or actions on behalf of legitimate users.
Attack Chain
- An attacker identifies a Jupyter Server instance running version 2.17.0 or earlier.
- The attacker crafts a malicious website with a domain name designed to bypass the
allow_origin_patregex. For instance, if the intended origin istrusted.example.com, the attacker usestrusted.example.com.evil.com. - A victim user visits the attacker’s malicious website in their browser.
- The malicious website sends a cross-origin HTTP request to the vulnerable Jupyter Server. The
Originheader in the request is set to the attacker-controlled domain (trusted.example.com.evil.com). - The Jupyter Server receives the request and validates the
Originheader against theallow_origin_patconfiguration usingre.match(). - Due to the behavior of
re.match(), the attacker’s origin passes the validation, as the regex only checks for a match at the beginning of the string. - The Jupyter Server processes the cross-origin request, effectively bypassing the intended CORS restrictions.
- The attacker can then potentially perform unauthorized actions or access sensitive data within the Jupyter Server, as if the request originated from a trusted source.
Impact
Successful exploitation of this vulnerability allows attackers to bypass CORS restrictions on vulnerable Jupyter Server instances. This could lead to unauthorized access to sensitive data, modification of user settings, or execution of arbitrary code within the Jupyter environment, all performed under the guise of a legitimate user. The number of affected instances depends on the prevalence of vulnerable Jupyter Server versions and the use of misconfigured allow_origin_pat settings.
Recommendation
- Upgrade Jupyter Server to a version greater than 2.17.0, which includes the fix for CVE-2026-40110.
- As a workaround, wrap your
allow_origin_patconfiguration value with^and$to ensure the regex matches the entire string, as suggested in the advisory. - Monitor web server logs for requests with
Originheaders matching the patterntrusted.example.com.*(adjusting thetrusted.example.comto your actual configured pattern) to detect potential exploitation attempts. Implement this detection using the provided Sigma rule targeting webserver logs.
Detection coverage 2
Detect Jupyter Server CORS Bypass Attempt via Origin Header
highDetects potential CORS bypass attempts against Jupyter Server by monitoring the Origin header in web server logs for patterns that may indicate exploitation of CVE-2026-40110.
Detect Jupyter Server Regex Misconfiguration
mediumDetects potentially vulnerable Jupyter Server configurations by identifying instances where the allow_origin_pat setting is not properly anchored with ^ and $.
Detection queries are kept inside the platform. Get full rules →