Cookies without Secure attribute - Detect
ID: cookies-without-secure
Severity: info
Author: vthiery,RJ Coleman
Tags: misconfig,http,cookie,generic
Description
Section titled “Description”Checks whether cookies in the HTTP response contain the Secure attribute. If the Secure flag is set, it means that the cookie can only be transmitted over HTTPS
YAML Source
Section titled “YAML Source”id: cookies-without-secure
info: name: Cookies without Secure attribute - Detect author: vthiery,RJ Coleman severity: info description: | Checks whether cookies in the HTTP response contain the Secure attribute. If the Secure flag is set, it means that the cookie can only be transmitted over HTTPS impact: | Lack of Secure flag on cookies allows the cookie to be sent over unsecure HTTP, making it vulnerable to man-in-the-middle (MITM) attacks. remediation: | Ensure that all cookies are set with the Secure attribute to prevent MITM attacks. reference: - https://owasp.org/www-community/controls/SecureCookieAttribute classification: cvss-metrics: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N cvss-score: 0 metadata: verified: true max-request: 1 tags: misconfig,http,cookie,generic
flow: | http() javascript()
http: - method: GET path: - "{{BaseURL}}" host-redirects: true max-redirects: 2
javascript: - code: | content = template.http_all_headers const setCookieLines = content .split(/\r\n/) .filter(line => line.trim().toLowerCase().startsWith('set-cookie:')); const nonSecureCookies = setCookieLines.filter(line => !line.toLowerCase().includes('secure')); const cookieNames = nonSecureCookies.map(line => { const match = line.match(/set-cookie:\s*([^=]+)=/i); return match ? match[1] : null; }).filter(Boolean); cookieNames
extractors: - type: regex regex: - '[a-zA-Z0-9_-]+'# digest: 490a0046304402203c40f31794d6d2667d13faa55d201451ba8eee9cf390a4fe6c7d62b06031880b02205d896a6a3cab707c824d7092f7a346e8c38e30fcac61e935c09eb26e40cdad94:922c64590222798bb761d5b6d8e72950Guide to check the vulnerabilities
Section titled “Guide to check the vulnerabilities”This template is used to detect vulnerabilities in web applications. It can be used with the Nuclei tool to scan for specific patterns or behaviors.
$ nuclei -u "URL" -t "http/misconfiguration/cookies-without-secure.yaml"