CORS Bypass in popular opensource library
The elysia-cors library checked allowed origins using a substring match instead of an exact or subdomain match, so a malicious origin like notexample.com was accepted when example.com was whitelisted. This let unauthorised sites read user data from sites using the library for CORS validation.
medium.com
Published on medium.com
While drilling on a Cross Origin Resource Sharing (CORS) bypass vulnerability in my website, I landed on the library being used — elysia-cors.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The library used a substring check (includes) to validate origins instead of comparing the full origin or checking the subdomain boundary.
Impact
A malicious site could read user data from any site using the vulnerable library version for CORS validation.
What the attacker needed
Site uses elysia-cors ≤1.3.0; victim visits a malicious site
The fix
The maintainer fixed the substring check in version 1.3.1.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
CORS is a browser rule that stops one website from reading data on another unless the other site explicitly allows it. This library was meant to allow only trusted sites, but it used a simple text search, so a lookalike address containing the trusted name was wrongly allowed. That meant a malicious site could read private data from sites using the library.
What is CORS?
A permissive cross-origin policy lets another site read responses with the user's credentials.