Enabling Cookie Security Attributes
The cookie security attribute function is designed to enhance the security of web service cookies. It automatically adds the HttpOnly and Secure attributes (both set to true) to cookies returned by the origin server. This helps prevent security risks such as cross-site scripting (XSS) attacks, cookie hijacking, and man-in-the-middle (MITM) attacks that tamper with cookies. It also ensures compliance with security regulations and prevents web security scanners like AppScan, AWVS, and NSFOCUS from flagging the lack of security configuration fields such as HttpOnly and Secure in cookies as security threats.
If you set Client Protocol to HTTPS, you can enable Cookie Security Attributes. If you enable this, the HttpOnly and Secure attributes of cookies will be set to true.
Principles
WAF cookie security attributes function operates through Layer 7 response rewriting. It does not change the service logic of the origin server or generate cookies. Instead, it automatically enhances the security of the Set-Cookie response headers returned by the origin server to the client. This is a passive hardening measure and does not affect the request forwarding efficiency.
Figure 1 shows the process.
- The client initiates an HTTPS request.
- WAF receives the request and checks for attacks and compliance risks.
- WAF forwards the normal service requests to the origin server.
- The origin server processes the request.
- The origin server returns response data containing the Set-Cookie response header. (Cookies are inserted by the backend web server through framework configuration or Set-Cookie instructions.)
- WAF blocks the origin server's response, parses the Set-Cookie response header, and checks whether the Cookie contains the HttpOnly and Secure attributes.
- If the cookie already contains the corresponding attributes, WAF does not modify the response and directly forwards it.
- If the cookie does not contain the corresponding attributes, WAF automatically adds the attributes, without changing core information such as the cookie value and validity period.
- WAF forwards the enhanced response data to the client. The client browser identifies and applies the HttpOnly and Secure attributes.
Typical Application Scenarios
- All HTTPS web services, such as e-commerce websites, management backends, payment systems, and user login websites
- Services that require security scanning, DJCP compliance, and PCI DSS certification
- Services that store login status and sensitive user information in cookies
Constraints
| Function | Constraint |
|---|---|
| Access mode restrictions |
|
| Other | If the Client Protocol is set to HTTP, the Cookie Security Attributes function is disabled by default and cannot be enabled. |
Prerequisites
You have selected Dedicated or Cloud CNAME and added the website you want to protect to WAF.
Enabling Cookie Security Attributes
- Log in to the WAF console.
- Click
in the upper left corner and select a region or project. - (Optional) If you have enabled the enterprise project function, in the upper part of the navigation pane on the left, select your enterprise project from the Filter by enterprise project drop-down list. Then, WAF will display the related security data in the enterprise project on the page.
- In the navigation pane on the left, choose .
- On the Protected Objects page, click the target domain name.
- In the Advanced Settings area, click
next to Cookie Security Attributes to enable it. Figure 2 Cookie Security Attributes
After completing the above configuration, access the protected domain name through a browser, open the developer tool, and check whether the HttpOnly and Secure attributes of the cookie are set to true.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot
