# Missing HTTP Only Option in Cookie Configuration

## Overview

* **Rule ID**: `java_lang_cookie_missing_http_only`
* **Applicable Languages**: Java
* **Weakness ID**: CWE-1004

## Description

Not configuring the HTTP Only attribute as `true` in cookie settings exposes the cookie to potential access by client-side JavaScript. This oversight can lead to the exposure of sensitive cookie values, especially on websites vulnerable to Cross-Site Scripting (XSS) attacks. Enabling HTTP Only is critical to prevent malicious scripts from accessing cookie values through JavaScript.

## Remediation Guidelines

To protect cookies from unauthorized access by client-side JavaScript, always set the HTTP Only attribute to `true`. This is a crucial measure in safeguarding your cookies against XSS vulnerabilities.

```java
cookie.setHttpOnly(true);
```

## Refrences

* [**CWE-1004: Sensitive Cookie Without 'HttpOnly' Flag**](https://cwe.mitre.org/data/definitions/1004.html)
* [**A05:2021 - Security Misconfiguration**](https://owasp.org/Top10/A05_2021-Security_Misconfiguration/)

## Configuration

To omit this rule during a scan, and to provide you with continuous 24/7 code-level scanning, you can employ our [**SAST TOOL**](https://scopy.sec1.io/login)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sec1.io/user-docs/4-sast/2-java/missing-http-only-option-in-cookie-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
