Protecting POST data in a web application

I have a web application that has basic authentication - username, password, session, and more. However, I have a definite need to prevent users from substituting POST requests (even for registered users). In my application, I specifically check the user session before accepting POST data (also taking care of XSS, etc.).

how

if(user session exists)
{
    // handle the data POSTed
}

else {
   // ...
}

I store session identifiers in a database. Is there anything else I should know about to prevent false POST requests or is that enough?

+3
source share
8 answers

I specifically check the user session before taking POST

, ": , cookie, , , . cookie , POST () .

, , - XSRF, ( ), GET POST . . ( , HTTP-, .)

, (SQL, ) (HTML, JavaScript) , , : - , , , XSRF.

XSRF, , . , .

. , , . , PHP:

<form method="post" action="delete.php"><div>
    <input type="hidden" name="key" value="<?php echo(htmlspecialchars($user['key'])); ?>"/>
    <input type="submit" value="Delete" />
</div></form>

if ($_POST['key']!=$user['key'])
    // error

, /, .

- , . , , . , , , ( ).

+3

. , , .

+2

POST- Javascript , , POST . , POST. , .

, . . , .

+1

CAPTCHA .

REST, . - POST, .

, CAPTCHA .

+1

, , . , , - , SHA1 , , . , .NET .

0
0

, , , , , mysql_real_escape_string ($ MyPostData).

, /, POST, , .

, , "" : , , , , .

0

( , ), (, , - , ), /guid, , , cookie. , , , GUID , . XSRF.

0

Source: https://habr.com/ru/post/1717561/


All Articles