I have been researching various techniques for preventing CSRF attacks, such as SOP, SameSite, Secure, Referer validation, and CSRF Tokens, and their potential bypasses. During my research, I discovered the following vulnerabilities:
- A website's subdomain or sibling domain is vulnerable to XSS or HTML Injection. For instance:
- Subdomain:
a.comandvulnerable.a.com - Sibling:
a.a.comandvulnerable.a.com
- Subdomain:
- A subdomain takeover (SDTO) attack
- A Man-in-the-middle (MITM) attack
However, I'm unsure if correctly implemented Signed Double Submit Cookie and Referer validation are vulnerable to those?
What I mean by correctly implemented:
- With Signed Double Submit is meant a session-bound and signed (HMAC) CSRF token, stored in a non-
HttpOnlycookie with theSecureflag. - With
Referervalidation is meant a Strict (block requests that have noRefererheader) and Strong (handles subdomain and URL queries)Referervalidation.
Questions:
Is Signed Double Submit Cookie & Strict & Strong
Referervalidation vulnerable to MITM?According to this SO answer:
... If an application is hosted at
https://secure.example.com, even if the cookies are set with the secure flag, a man in the middle can force connections tohttp://secure.example.comand set (overwrite) any arbitrary cookies (even though the secure flag prevents the attacker from reading those cookies)...If I read this correctly, this would mean that a MITM can initiate requests from
http://b.comtohttp://a.com, but make the request look like it came fromhttp://a.com. If that is true, then:- Signed Double Submit Cookie is vulnerable. The attacker doesn't even need to overwrite the CSRF cookie, since the original one is passed along automatically
- Strict & Strong
Referervalidation is vulnerable. The request, even if made fromb.comhas the valuea.comas theReferervalue.
Is Signed Double Submit Cookie vulnerable to a vulnerable subdomain?
If an attacker gains access tovulnerable.a.com, they can read and write any cookie.Is it true that only cookie prefixes prevent such an attack, or am I missing something where the Signed Double Submit Cookie pattern would prevent this?
Is Strict & Strong
Referervalidation vulnerable to vulnerable subdomain?
Let's look over some facts:- The
Refererheader is a forbidden header name meaning it cannot be changed programmatically. - The session cookie or JWT are commonly protected with the
HttpOnlyflag, preventing the attacker from reading or writing to it, even on subdomains.
With that in mind, does this mean that Strict & Strong
Referervalidation is not vulnerable to vulnerable subdomains?- The
Is OWASP's recommendation false?
The Signed Double Submit Cookie pattern is categorized as a mitigation technique. The Strict & StrongReferervalidation pattern is only categorized as a Defence in Depth (DiD) technique.Depending on the above questions, it may seem that only a combination of a Signed Double Submit Cookie and Strict & Strong
Referervalidation is a true mitigation technique, while alone both are DiD's?