# Leakage of Sensitive Information in Exception Messages

## Overview

* **Rule ID**: `javascript_express_cookie_missing_http_only`
* **Applicable Languages**: Javascript
* **Weakness ID**: CWE-1004

## Description

If the HTTP Only option is not configured, your cookies are at risk. This setting is essential because it prevents client-side JavaScript from accessing cookie values through code like "document.cookie". Enabling HTTP Only is crucial for websites vulnerable to Cross-Site Scripting (XSS) attacks, as it stops malicious scripts from obtaining cookie data.

## Remediation Guidelines

* **Set** the HttpOnly attribute to true in your cookie configuration. This ensures that cookies are protected from unauthorized client-side access.

  ```java
  cookie({ httpOnly: true });
  ```

## References

* [**Express Security Best Practices**](https://expressjs.com/en/advanced/best-practice-security.html#use-cookies-securely)
* [**CWE-1004: Sensitive Cookie Without 'HttpOnly' Flag**](https://cwe.mitre.org/data/definitions/1004.html)
* [**OWASP Top 10: 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/3-javascript/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.
