✅CSRF
CSRF Nedir?
Cross-site request forgery, bir saldırganın kullanıcıları gerçekleştirmek istemedikleri işlemleri gerçekleştirmeye sevk etmesine olanak tanıyan bir web güvenlik açığıdır. Bir saldırganın, farklı web sitelerinin birbirine müdahale etmesini önlemek için tasarlanan same origin policy'yi kısmen atlatmasına olanak tanır.
SameSite Cookie Değerleri
SameSite=None: Hiçbir koruma yoktur istek nereden gelirse gelsin cookie isteğe eklenir. Eğer csrf token koruması yoksa saldırı yapılabilir.
SameSite=Lax: Default değerdir. Eğer istek başka bir domainden geliyorsa sadece GET isteklerine çerezi ekler.
SameSite=Strict: Başka domainden gelen hiçbir isteğe çerezi eklemez.
Yöntemler
Korumasız CSRF
GET Metodu ile CSRF
CSRF Token Silme
CSRF Token silindiğinde istek halen kabul ediliyor olabilir.
CSRF Token Session'a Bağlı Olmayabilir
CSRF token eğer bir session'a bağlı değil ise kendi csrf tokenimizi başka kullanıcılarda kullanabiliriz.
CSRF Token Session Dışında Bir Cookie'ye Bağlı Olabilir
Eğer CSRF Token Session çerezi dışında bir çerez ile ilişkili ise bu çerezi kurbanın almasını sağlayabiliriz. Bunun için CRLF (%0d%0a) kullanabiliriz.
CSRF Token Bir Çerezde Tekrar Ediliyor Olabilir
Eğer CSRF Token bir cookie'de tekrar ediyorsa bu çerezi kurbana aktarabiliriz. Bunun için CRLF (%0d%0a) kullanabiliriz.
CSRF Koruması Olarak Referer Header Kontrolü
Sistem kullanıcının kendisinin isteği attığını kontrol etmek için referer başlığını kullanıyor olabilir. Bu korumayı atlatmak için başlığı silmeyi deneyebiliriz.
Eğer referer header kontrolünde parser yanlış yapılmış olabilir. Burada url'ye parametre olarak sitenin adresini girdiğimizde korumayı aşmış oluyoruz.
CSRF Method Override SameSite Lax Bypass
Eğer istek sadece POST metodu ile gönderiliyorsa ve Lax ile cookie işaretlenmiş ise isteği GET yapmamız gerekir. Bunu _method parametresi ile yapmayı deneyebiliriz.
Cookie Yenileyerek SameSite Lax Bypass
Eğer session çerezi lax ile işaretli ise bu çerezi yenileyen sayfaya istek atabiliriz.
Eğer hedefte popup blocker var ise aşağıdaki kodu kullanabiliriz.
CSRF Open Redirect SameSite Strict Bypass
Eğer session cookie stric
CSRF Subdomain SameSite Strict Bypass
Eğer session çerezi SameSite Strict ise bu korumayı başka bir domainde xss açığı bularak atlatabiliriz.
Websocket CSRF
Araçlar
Burp CSRF Scanner: https://github.com/portswigger/csrf-scanner
Kaynaklar
Portswigger Academy: https://portswigger.net/web-security/csrf
Last updated