In fact, in Magento you can use the CSRF token validation interface, which you can use to add a unique session-based form key to your custom form and verify this in the controller action.
To submit a CSRF form key with a request when submitting a form, insert the code <?php echo $this->getBlockHtml('formkey') ?> In the form body.
This will create this input: <input type="hidden" value="unique16codehere" name="form_key"> . To verify the key, use the _validateFormKey() method in the corresponding controller action.
source share