Appearance
Cookies Since v0.1
Cookie protection adds the attributes the application forgot (Secure, HttpOnly, SameSite) and can seal cookies. A sealed cookie is encrypted, so the browser cannot read or change it, or signed, so it is readable but changes are detected. The application sees its own plain values.
Before you begin
- Role:
operatorfor the application. - Add the application on an HTTPS listener so
Securecan be set. - Know the cookie names the application sets. The inventory lists them.
See the cookies first
Turn cookie protection on in detect mode. Nothing changes. The Inventory tab lists the cookies the application sets, with Secure, HttpOnly and SameSite as it sets them, lifetime and size. It also lists cookies clients send that the application never sets: set by page scripts or another site. Values are never kept.
text
1. Open Applications > All applications > the application > Response checks > Cookies.
2. On the Attributes tab, set Protection mode to detect, then select Preview changes and Apply.
3. Open the Inventory tab.sh
waap cookies set -app shop -m "cookie inventory" mode=detect
waap cookies inventory -app shop -window 7dyaml
# applications[].policy.cookies
cookies:
mode: detectHarden attributes
In block mode: Secure on HTTPS answers, HttpOnly (not on names containing csrf or xsrf, which scripts read) and SameSite=Lax when the cookie has none. The application's own SameSite is never replaced.
text
1. On the Attributes tab, set Add Secure, Add HttpOnly, Add SameSite, and list Cookies left as they are.
2. Set Protection mode to block, then select Preview changes and Apply.sh
waap cookies set -app shop -m "attributes" mode=block attributes.same_site=strict attributes.except=ui_*yaml
cookies:
mode: block
attributes:
same_site: strict
except: ["ui_*"]Seal cookies
Add an entry with the cookie names (exact, or ending in *) and a method: encrypt (the default) or sign. Name only cookies the application sets, from the inventory.
text
1. Open the Protected cookies tab and add an entry: the cookie names and the method.
2. Select Preview changes, then Apply.sh
waap cookies list set -app shop -list protect -f protect.yaml -m "seal session cookies"yaml
# policy.cookies.protect
- names: [sid, "remember_*"]
method: encryptGrace period
Browsers still hold unsealed cookies from before. Protecting cookies sets Grace until seven days ahead when none is set. Until then unsealed copies pass and are logged once a minute per cookie (cookie.unprotected). Change it with waap cookies set -app shop grace_until=72h. The Protected cookies tab shows the time left.
Handle tampered cookies
A seal that does not verify (cookie.tampered), a key no longer kept (cookie.expired_key) or an unsealed copy after the grace period (cookie.unprotected) is handled by When a cookie is tampered: remove (default: the cookie is dropped and the user appears logged out), block or log. The event names the cookie and its size, never the value. Exceptions can ignore these rules (cookie.*).
Rotate the keys
The active node makes the first key within seconds and rotates it every Rotate the key every. Keys kept keys open cookies, so a cookie opens for at most rotation times keys kept. The inventory marks cookies that live longer as "outlives its keys": raise Keys kept or the rotation. Keys are shared with the standby and in backups, so a failover keeps sessions.
text
1. Open the Keys tab.
2. Select Rotate now and confirm.sh
waap cookies keys list -app shop
waap cookies keys rotate -app shopDetect mode and turning it off
Detect mode seals, hardens and removes nothing, but sealed cookies clients already hold are still opened. Setting enabled=false keeps opening them too. Only removing the whole section stops that, and clients then send sealed values to the application until they expire. Set on_tamper=log and wait out the cookies' lifetime first, or accept that users log in again.
Settings reference
General and attributes
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
Cookie protection (policy.cookies.enabled) | Adds attributes and seals protected cookies. Off still opens sealed cookies. | true | true, false | all |
Protection mode (mode) | detect changes nothing; block changes cookies. | empty (same as the application) | detect, block, empty | detect wins |
Add Secure (attributes.secure) | Marks cookies Secure on HTTPS answers. | true | true, false | block mode |
Add HttpOnly (attributes.http_only) | Hides cookies from page scripts. | true | true, false | block mode |
Add SameSite (attributes.same_site) | Added only when the cookie has none. | lax | lax, strict, none, off | block mode; none needs HTTPS |
Cookies left as they are (attributes.except) | Names (prefix with *) that get no attributes. | none | cookie names | block mode |
Sealing and keys
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
Grace until (grace_until) | Until then unsealed copies pass. | 7 days after protecting | a time or a duration from now | protected cookies |
When a cookie is tampered (on_tamper) | The action on a bad seal. | remove | remove, block, log | protected cookies |
Rotate the key every (keys.rotation) | A new key seals new cookies. | 720h (30 days) | 1h to 8760h | protected cookies |
Keys kept (keys.keep) | How many keys open cookies. | 4 | up to 12 | protected cookies |
protect[].names | Cookies to seal. | none (required) | up to 32 names, exact or ending in * | all |
protect[].method | How they are sealed. | encrypt | encrypt, sign | all |
Limits
| Limit | Value |
|---|---|
| Protected entries | 64, each with up to 32 names |
| Keys kept | 12 |
| Metric | waap_cookie_verdicts_total{app,result} (sealed, opened, tampered, expired_key, grace, unprotected, too_large, no_key) |
Troubleshooting
Users are logged out after protection is turned on
- Cause: a cookie was tampered, its key expired, or the grace period ended with unsealed copies left.
- Check: events with rules
cookie.tampered,cookie.expired_key,cookie.unprotected. - Fix: lengthen Grace until, raise Keys kept, or set When a cookie is tampered to
logwhile you investigate.