Java Missing Secure Cookie Flag
Description
Identifies Micronaut HTTP cookies that are created without the secure flag set, which makes them vulnerable to interception over insecure connections. Cookies without the secure flag can be transmitted over HTTP, potentially exposing sensitive information to attackers performing man-in-the-middle attacks.
Detection Strategy
• Check if the application imports Micronaut HTTP packages (io.micronaut.http)
• Look for cookie creation using NettyCookie, SimpleCookie, or Cookie.of() methods
• Verify if the secure() method is called on the cookie instance
• Report a vulnerability if a cookie is created without subsequently calling the secure() method
Vulnerable code example
package com.example;
import io.micronaut.http.*;
import io.micronaut.http.cookie.Cookie;
import io.micronaut.http.netty.cookies.NettyCookie;
import io.micronaut.http.simple.cookies.SimpleCookie;
@Controller("/api")...✅ Secure code example
package com.example;
import io.micronaut.http.*;
import io.micronaut.http.cookie.Cookie;
import io.micronaut.http.netty.cookies.NettyCookie;
import io.micronaut.http.simple.cookies.SimpleCookie;
@Controller("/api")...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.