To handle CSRF protection for detail page buttons and Lightning components, follow these guidelines:
1. **Visualforce Pages**: Enable the `confirmationTokenRequired` attribute to ensure GET requests require a CSRF token in the URL. Without the token, the page will be inaccessible.
2. **Lightning Components**: Avoid performing state changes or DML operations during component initialization. Instead, trigger these actions through explicit user interactions, like button clicks.
3. **Action Methods**: Ensure methods called from the action parameter of a Visualforce page or Lightning component do not automatically execute state changes or DML operations.
4. **Component Access**: For Aura components, set the access value to `Private` or `Public` within the namespace to limit exposure to external entities.
5. **User-Triggered Actions**: Always trigger state changes or DML operations through user actions, such as button clicks, rather than during page or component initialization.
These steps will help effectively mitigate CSRF vulnerabilities.