Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.
Automatically adds a drupal_get_token query string parameter to any menu links that correspond to a menu router item that has 'token' => TRUE in its hook_menu() definition. This helps prevent certain links from CSRF attack requests.
Protection support for core menu callbacks
By default this module adds token CSRF protection for the following core menu callbacks:
user/logout
Which in turn ensures any menu links are output as:
function mymodule_menu() {
$items['mymodule/path'] = array(
'title' => 'Sample dangerous callback',
'description' => 'A sample menu callback that should be protected from CSRF attacks using tokens.',
'page callback' => 'mymodule_dangerous_callback',
'access arguments' => array('administer mymodule'),
'token' => TRUE, // Add this to automatically have this path protected.
);
return $items;
}