Уклонение от защиты CSRF с помощью AJAX - PullRequest
0 голосов
/ 09 июля 2020

Я настроил свой файл Owasp.CsrfGuard.properties так, чтобы все файлы не были защищены, если не указано иное

# All other pages will not be protected. This is useful when the CsrfGuardFilter is aggressively mapped (ex: /*),
# but you only want to protect a few pages.
#
org.owasp.csrfguard.Protect=true

AJAX защита включена

org.owasp.csrfguard.Ajax=true

Затем я настраиваю отдельный файл, подлежащий защите

org.owasp.csrfguard.protected.delPos=/site/pages/pos/ajax/delPos.jsp

Теперь я не настраивал delPos.jsp с токеном

Вызов delPos. jsp из AJAX работает нормально, несмотря на отсутствие токена

    $.post("ajax/delPos.jsp", {
            company: c,
            pos: p
        }, function(response) {
                    
        }
                    
    });

Но ввод delPos. jsp в URL-адрес напрямую приводит к предупреждению CSRF

WARNING: potential cross-site request forgery (CSRF) attack thwarted (user:<anonymous>,
ip:0:0:0:0:0:0:0:1, method:GET, uri:/.../ajax/delPos.jsp, error:required token
is missing from the request)

Почему мне удается «обойти» защиту CSRF, запустив delPos. jsp постранично AJAX?

...