To prevent CSRF vulnerabilities in managed packages, here are the recommended approaches:
1. **Enable `confirmationTokenRequired` in Visualforce Pages**: Set the `confirmationTokenRequired` boolean metadata field to `true` in the Visualforce page settings. This ensures that GET requests to the page require a CSRF token in the URL, preventing unauthorized access.
2. **Avoid Automated DML Operations on Page Load**: Do not perform state changes or DML operations in Apex controllers during the initialization of Lightning or LWC components. Instead, trigger these operations through user actions, such as button clicks.
3. **Use Custom Headers with Random Tokens**: Implement a completely random token in custom headers for requests. This adds an additional layer of security against CSRF attacks.
4. **Follow Secure Coding Practices**: Adhere to secure server-side development guidelines, such as those provided in the Secure Server-Side Development module on Trailhead, to ensure robust protection against CSRF vulnerabilities.
5. **Review and Test Thoroughly**: Regularly review and test the managed package for CSRF vulnerabilities, ensuring that all identified issues are addressed before submission for security review.
For more details, you can refer to the [Salesforce documentation](/).