Aller au contenu

Cookie Missing HttpOnly (ARCH5124)

Ce contenu n’est pas encore disponible dans votre langue.

Key go.security.cookie-missing-httponly · Severity warning · Category security · CWE CWE-1004

Session or auth cookies without the HttpOnly flag are readable by JavaScript. This makes them stealable via XSS if the application has a cross-site scripting flaw.

http.SetCookie(w, &http.Cookie{
Name: "session",
Value: token,
})
http.SetCookie(w, &http.Cookie{
Name: "session",
Value: token,
HttpOnly: true,
Secure: true,
})

Set session and auth cookies with HttpOnly: true to block JavaScript access.