Multiple choice technology security

Which method among the below could be used as a defense against Cross Site Request Forgery?

  1. encryptHiddenField(java.lang.String value)

  2. addCSRFToken(final java.lang.String href)

  3. verifySecureComm(javax.servlet.http.HttpServletRequest request)

  4. setSafeContentType(javax.servlet.http.HttpServletResponse response)

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

CSRF (Cross-Site Request Forgery) attacks trick authenticated users into performing unwanted actions. Adding CSRF tokens to URLs is a primary defense because the token is unpredictable and tied to the user's session, making forged requests invalid. encryptHiddenField, verifySecureComm, and setSafeContentType address different security concerns like data encryption or transport security, not CSRF specifically.