matchu
New member
Quick preface: I'm assuming that Mafia validates Referer headers to ensure that evil.com can't send an evil request to the KoLMafia relay browser. Is that right? If there's some other reason, well, disregard the rest of this post, kthx 
If that's the intent of the security feature, then here's a technique to bypass it:
Therefore, since an evil site can strip a Referer header, Mafia should assume that all requests with no Referer header are evil and therefore block them. (I can understand a compatibility argument, since not all clients send Referer headers at all, but those clients are also uncommon and/or ancient. Security wins here.)
Then again, I'm not entirely sure what the Referer check gains us, because KoL itself already has plenty of CSRF protection. Is this to defend against relay scripts that don't bother with these kinds of protections? I don't know enough about the relay browser infrastructure to comment on that :/
Anyway, hope this helps
Love all the hard work y'all do 

If that's the intent of the security feature, then here's a technique to bypass it:
- evil.com creates an anonymous iframe that points to a page with no real URL (e.g., with a "javascript:'HTML goes here'" src)
- The anonymous iframe then submits a request to "http://127.0.0.1:60080/do-something-evil"
- Mafia receives the request, which has no Referer header because the anonymous iframe has no URL.
- Mafia therefore misidentifies the request as valid and it is processed, even though it's actually evil and therefore should be rejected.
Therefore, since an evil site can strip a Referer header, Mafia should assume that all requests with no Referer header are evil and therefore block them. (I can understand a compatibility argument, since not all clients send Referer headers at all, but those clients are also uncommon and/or ancient. Security wins here.)
Then again, I'm not entirely sure what the Referer check gains us, because KoL itself already has plenty of CSRF protection. Is this to defend against relay scripts that don't bother with these kinds of protections? I don't know enough about the relay browser infrastructure to comment on that :/
Anyway, hope this helps


Last edited: