> ## Documentation Index
> Fetch the complete documentation index at: https://docs.formal.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Seal Claude Desktop session cookies

> Replace Claude Desktop session cookies with sealed values that cannot be used directly against Claude

## Overview

Formal seals the Claude Desktop chat session cookie (`sessionKey` on `.claude.ai`) before Claude Desktop stores it.
For the Code tab, see [Seal Claude Code OAuth Tokens](https://docs.formal.ai/docs/guides/example-use-cases/seal-claude-code-oauth-tokens.md).

## Intercept Claude Desktop

Enable [Transparent Mode](https://docs.formal.ai/docs/guides/client-apps/desktop-app.md#transparent-mode) on macOS.
Transparent Mode [blocks QUIC by default](https://docs.formal.ai/docs/guides/client-apps/configuration.md#configuring-transparent-mode-on-startup). Keep it blocked so the Endpoint can intercept Claude Desktop chat.
In [Network Rules](https://app.formal.ai/network-rules), create an active rule with the following CEL.
Leave **Forward to Connector** unset to seal on the Endpoint.

```cel theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
{
  "condition": {
    "pre_tcp": port == 443,
    "pre_tls": hostname == "claude.ai" || hostname == "api.anthropic.com",
    "post_tls": true
  },
  "outputs": {}
}
```

## Seal the session cookies

In [Policies](https://app.formal.ai/policies), create an active policy with this Rego policy:

```rego theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
package formal.v2

import future.keywords.if

cookie_targets := [
  {"kind": "cookie", "name": "sessionKey"},
  {"kind": "cookie", "name": "sessionKeyV3"}
]

response := {
  "action": "encrypt",
  "targets": cookie_targets,
  "reason": "Seal Claude Desktop session cookies"
} if {
  input.resource.hostname == "claude.ai"
}

request := {
  "action": "decrypt",
  "targets": cookie_targets,
  "reason": "Open Claude Desktop session cookies"
} if {
  input.resource.hostname == "claude.ai"
}

request := {
  "action": "decrypt",
  "targets": [{"kind": "header", "name": "Authorization"}],
  "reason": "Open Claude Desktop session key sent to Anthropic API"
} if {
  input.resource.hostname == "api.anthropic.com"
}
```

**Verify:** Sign out of Claude Desktop and sign in again with Transparent Mode running.
Confirm the policy appears for requests to both hosts in [Logs](https://app.formal.ai/logs).
Send a chat message and confirm it succeeds.
Cookies issued before the policy was active are not sealed retroactively.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.