Skip to content

Commit c573804

Browse files
authored
Merge pull request #1083 from kabalin/sesskey
[docs] Make clear that sesskey is CSRF token.
2 parents c83a2df + feb0af5 commit c573804

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

general/development/policies/security/crosssite-request-forgery.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,20 @@ It may be a bit surprising, but this type of attack may be used against servers
3131

3232
## How Moodle avoids this problem
3333

34-
### Session key
34+
### Session key (CSRF token) {#session-key}
3535

36-
The most important protection is the concept of a **sesskey**, short for session key.
36+
The most important protection is the concept CSRF token, which is for historic reasons called **`sesskey`** in Moodle.
3737

38-
When you log in, Moodle adds a random string to your session. Whenever it prints a link or a button to perform a significant action, it adds the sesskey value to the submitted data. Before performing the action, it checks the sesskey value in the request with the one in the session, and the action is only performed if the two match.
38+
When you log in, Moodle generates a random string and stores it in the session. Whenever it prints a link or a button to perform a significant action, it adds the sesskey value to the submitted data. Before performing the action, it checks the sesskey value in the request with the one in the session, and the action is only performed if the two match.
3939

4040
Therefore, the request to delete a user is actually something like below and there is no way for Evil Hacker to know what the sesskey is, so they cannot construct an URL that tricks the admin into deleting a user: `http://example.com/moodle/user/delete.php?id=123&confirm=1&sesskey=E8i5BCxLJR`
4141

42+
:::info
43+
44+
The `sesskey` should not be confused with Moodle Session ID, which a PHP session cookie responsible for session continuity (remaining logged in).
45+
46+
:::
47+
4248
### Use HTTP correctly
4349

4450
Web applications use HTTP to encode requests from the user. In HTTP, there are various types of request. The two most important are GET and POST.

0 commit comments

Comments
 (0)