csrf-атаки и двойная отправка cookie

Приведенная ниже цитата взята изhttp://www.codinghorror.com/blog/2008/10/preventing-csrf-and-xsrf-attacks.html

When a user visits a site, the site should generate a (cryptographically strong) pseudorandom value and set it as a cookie on the user's machine. The site should require every form submission to include this pseudorandom value as a form value and also as a cookie value. When a POST request is sent to the site, the request should only be considered valid if the form value and the cookie value are the same. When an attacker submits a form on behalf of a user, he can only modify the values of the form. An attacker cannot read any data sent from the server or modify cookie values, per the same-origin policy. This means that while an attacker can send any value he wants with the form, he will be unable to modify or read the value stored in the cookie. Since the cookie value and the form value must be the same, the attacker will be unable to successfully submit a form unless he is able to guess the pseudorandom value.

Вышеупомянутый метод предотвращает атаки CSRF, сравнивая псевдослучайное значение в файле cookie и форме. Однако почему значение должно быть возвращено вместе с формой? Я предполагаю, что и форма, и файл cookie имеют одно и то же зашифрованное значение, которое они возвращают на сервер. И сервер проверяет это, расшифровывая значение.

Таким образом, даже если значение возвращается только файлом cookie, сервер может расшифровать его и проверить запрос. Какой цели служит возврат зашифрованного значения с формой?

12
задан murtaza52 17 July 2012 в 07:56
поделиться