request icon indicating copy to clipboard operation
request copied to clipboard

Is there a security risk in setting httponly to false?

Open tianjk99 opened this issue 1 year ago • 0 comments

The function initCookie sets "httpOnly" to false, allowing client-side JavaScript to access cookies that may contain sensitive data. This introduces potential security risks and vulnerabilities. res.cookie("sid", sid, { expires : new Date(253402300000000), httpOnly: false, path : '/' });

Setting "httpOnly" to false may be due to specific design needs or use cases. In some cases, applications may need to access cookie data via JavaScript to implement specific functionality or to interact with other components. However, to be clear, setting "httpOnly" to false may increase potential security risks. Allowing client-side JavaScript to access cookies containing sensitive data can lead to security issues such as XSS attacks. An attacker could exploit the vulnerability to steal a user's credentials or perform malicious actions.

It is recommended to set "httpOnly" to true to enhance the platform's security and prevent cross-site scripting (XSS) attacks and other security vulnerabilities.

tianjk99 avatar Dec 04 '23 07:12 tianjk99