Description
sanic-cors version 2.2.0 and prior contains an improper regular expression in the try_match() function in sanic_cors/core.py that uses re.match without end-anchoring. This allows an attacker to bypass CORS origin allowlists by registering a domain that begins with a trusted origin string, to gain unauthorized access to cross-origin requests for authenticated resources.
Published: 2026-06-05
Score: 6.5 Medium
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

The Sanic-Cors library, up to and including version 2.2.0, contains an improper regular expression inside the try_match() function in sanic_cors/core.py. The regex uses re.match without an end‑anchor, meaning any string that starts with a trusted origin string will be accepted as a match. This flaw allows an attacker to craft a domain name that prefixes an approved origin, thereby bypassing the CORS origin allowlist and gaining unauthorized access to cross‑origin requests for resources that require authentication. The deficiency is a form of improper authorization compounded by weaknesses in the authentication boundary (CWE‑346) and cryptographic token handling (CWE‑625).

Affected Systems

Any project that incorporates Sanic-Cors 2.2.0 or earlier, typically Sanic web applications that use the library’s default CORS handling, is vulnerable. The impact applies regardless of the specific deployment environment as long as the affected library version is present.

Risk and Exploitability

The static nature of the regex flaw makes exploitation straightforward for an adversary who can register or otherwise introduce a domain that prefixes an allowed origin. While no EPSS score is available, the medium CVSS score of 6.5 reflects the attacker's ability to bypass security boundaries without needing privileged access. The vulnerability is not listed in CISA’s KEV catalog, but the absence of proper end‑anchoring in the regex represents a significant risk in typical deployment contexts.

Generated by OpenCVE AI on June 6, 2026 at 00:21 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade Sanic‑Cors to any release newer than 2.2.0 if such a version exists
  • Replace the try_match() regular expression with a pattern that anchors to the end of the string, such as using re.fullmatch or adding a \$ at the pattern's end
  • Review the CORS origin allowlist to ensure that only complete, fully qualified origins are specified, avoiding prefixes that could be abused

Generated by OpenCVE AI on June 6, 2026 at 00:21 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories yet.

History

Sun, 07 Jun 2026 11:30:00 +0000

Type Values Removed Values Added
First Time appeared Ashleysommer
Ashleysommer sanic-cors
Vendors & Products Ashleysommer
Ashleysommer sanic-cors

Sat, 06 Jun 2026 00:30:00 +0000

Type Values Removed Values Added
Title CORS Allowlist Bypass via Improper Regex in Sanic-Cors 2.2.0

Fri, 05 Jun 2026 23:45:00 +0000

Type Values Removed Values Added
Title CORS Allowlist Bypass in Sanic‑Cors due to Improper Regex
Weaknesses CWE-285

Fri, 05 Jun 2026 21:30:00 +0000

Type Values Removed Values Added
Weaknesses CWE-346
CWE-625
Metrics cvssV3_1

{'score': 6.5, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N'}


Fri, 05 Jun 2026 15:45:00 +0000

Type Values Removed Values Added
Title CORS Allowlist Bypass in Sanic‑Cors due to Improper Regex
Weaknesses CWE-285

Fri, 05 Jun 2026 14:45:00 +0000

Type Values Removed Values Added
Description sanic-cors version 2.2.0 and prior contains an improper regular expression in the try_match() function in sanic_cors/core.py that uses re.match without end-anchoring. This allows an attacker to bypass CORS origin allowlists by registering a domain that begins with a trusted origin string, to gain unauthorized access to cross-origin requests for authenticated resources.
References

Subscriptions

Ashleysommer Sanic-cors
cve-icon MITRE

Status: PUBLISHED

Assigner: mitre

Published:

Updated: 2026-06-05T20:15:39.697Z

Reserved: 2026-04-06T00:00:00.000Z

Link: CVE-2026-37737

cve-icon Vulnrichment

No data.

cve-icon NVD

Status : Deferred

Published: 2026-06-05T15:16:51.720

Modified: 2026-06-05T21:16:30.367

Link: CVE-2026-37737

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-06-07T11:18:23Z

Weaknesses
  • CWE-346

    Origin Validation Error

  • CWE-625

    Permissive Regular Expression