First pass to reword security doc for word flow.
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Ron DuPlain · committed by Armin Ronacher · parent 6875a05 · Browse files · 1 file·+21 added−21 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+21 added−21 removed
- other:+21 added−21 removed
Provenance
- Commit
085faf2- Tree
5f56be0- Author
Ron DuPlain <ron.duplain@gmail.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
6875a05
1 file changed+21 added−21 removed
modified:docs/security.rst+21 added-21 removed
60 unmodified lines61 Another big problem is CSRF. This is a very complex topic and I won't62 outline it here in detail just mention what it is and how to theoretically63 prevent it.64 65-So if your authentication information is stored in cookies you have66-implicit state management. By that I mean that the state of "being logged67-in" is controlled by a cookie and that cookie is sent with each request to68-a page. Unfortunately that really means "each request" so also requests69-triggered by 3rd party sites. If you don't keep that in mind some people70-might be able to trick your application's users with social engineering to71-do stupid things without them knowing.65+If your authentication information is stored in cookies, you have implicit66+state management. The state of "being logged in" is controlled by a67+cookie, and that cookie is sent with each request to a page.68+Unfortunately that includes requests triggered by 3rd party sites. If you69+don't keep that in mind, some people might be able to trick your70+application's users with social engineering to do stupid things without71+them knowing.72 73 Say you have a specific URL that, when you sent `POST` requests to will74 delete a user's profile (say `http://example.com/user/delete`). If an75 attacker now creates a page that sends a post request to that page with76-some JavaScript he just has to trick some users to that page and their77-profiles will end up being deleted.76+some JavaScript he just has to trick some users to load that page and77+their profiles will end up being deleted.78 79-Imagine you would run Facebook with millions of concurrent users and80-someone would send out links to images of little kittens. When a user81-would go to that page their profiles would get deleted while they are79+Imagine you were to run Facebook with millions of concurrent users and80+someone would send out links to images of little kittens. When users81+would go to that page, their profiles would get deleted while they are82 looking at images of fluffy cats.83 84-So how can you prevent yourself from that? Basically for each request85-that modifies content on the server you would have to either use a86-one-time token and store that in the cookie **and** also transmit it with87-the form data. After recieving the data on the server again you would88-then have to compare the two tokens and ensure they are equal.84+How can you prevent that? Basically for each request that modifies85+content on the server you would have to either use a one-time token and86+store that in the cookie **and** also transmit it with the form data.87+After receiving the data on the server again, you would then have to88+compare the two tokens and ensure they are equal.89 90-Why does not Flask do that for you? The ideal place for this to happen is91-the form validation framework which does not exist in Flask.90+Why does Flask not do that for you? The ideal place for this to happen is91+the form validation framework, which does not exist in Flask.92 93 .. _json-security:94 95 JSON Security14 unmodified lines110 generate JSON.111 112 So what is the issue and how to avoid it? The problem are arrays at113 toplevel in JSON. Imagine you send the following data out in a JSON114-request. Say that's exporting the names and email adresses of all your115-friends for a part of the userinterface that is written in JavaScript.114+request. Say that's exporting the names and email addresses of all your115+friends for a part of the user interface that is written in JavaScript.116 Not very uncommon:117 118 .. sourcecode:: javascript119 49 unmodified lines