<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/cookie-chaos-how-to-bypass-host-and-secure-cookie-prefixes-9aodeefwd" -->

---
title: Cookie Chaos: How to bypass __Host and __Secure cookie...
description: Cookie prefixes like __Host- and __Secure- were designed to prevent session hijacking and cookie tossing attacks, but can be bypassed through encoding...
canonical: https://daily.dev/posts/cookie-chaos-how-to-bypass-host-and-secure-cookie-prefixes-9aodeefwd
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Cookie Chaos: How to bypass __Host and __Secure cookie prefixes | daily.dev
og:description: Cookie prefixes like __Host- and __Secure- were designed to prevent session hijacking and cookie tossing attacks, but can be bypassed through encoding...
og:url: https://daily.dev/posts/cookie-chaos-how-to-bypass-host-and-secure-cookie-prefixes-9aodeefwd
og:image: https://api.daily.dev/og/posts/9aOdeeFwd.png
og:image:alt: Cookie Chaos: How to bypass __Host and __Secure cookie prefixes
og:image:width: 1200
og:image:height: 630
og:locale: en
---

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

# Cookie Chaos: How to bypass __Host and __Secure cookie prefixes

**[Tech Lead Digest](https://daily.dev/sources/techleaddigest)** · 5 min read · 2 upvotes · 0 comments

## Summary

Cookie prefixes like __Host- and __Secure- were designed to prevent session hijacking and cookie tossing attacks, but can be bypassed through encoding discrepancies between browsers and servers. By using Unicode whitespace characters (like U+2000) or legacy cookie parsing modes, attackers can inject forged cookies that browsers treat as unrestricted but servers normalize into protected names. Frameworks like Django and ASP.NET trim whitespace from cookie names, allowing subdomain-based attacks that bypass Path and Domain restrictions. These bypasses enable XSS exploitation, session fixation, and CSRF token manipulation even when applications use the strongest cookie protections.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://portswigger.net/research/cookie-chaos-how-to-bypass-host-and-secure-cookie-prefixes>

---

Tags: [#security](https://daily.dev/tags/security), [#django](https://daily.dev/tags/django), [#web-security](https://daily.dev/tags/web-security)

[View this post on daily.dev](https://daily.dev/posts/cookie-chaos-how-to-bypass-host-and-secure-cookie-prefixes-9aodeefwd)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Cookie Chaos: How to bypass __Host and __Secure cookie prefixes","url":"https://daily.dev/posts/cookie-chaos-how-to-bypass-host-and-secure-cookie-prefixes-9aodeefwd","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/cookie-chaos-how-to-bypass-host-and-secure-cookie-prefixes-9aodeefwd"},"datePublished":"2025-10-05T18:20:01.172Z","dateModified":"2025-10-05T18:20:23.985Z","description":"Cookie prefixes like __Host- and __Secure- were designed to prevent session hijacking and cookie tossing attacks, but can be bypassed through encoding...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/b756bb009530b81c88790be5f8981367?_a=AQAEulh","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/b756bb009530b81c88790be5f8981367?_a=AQAEulh","isAccessibleForFree":true,"articleSection":"Tech Lead Digest","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Tech Lead Digest","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/6ed1ee1a2e5c49f698265a6b2912b80d","url":"https://daily.dev/sources/techleaddigest"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/cookie-chaos-how-to-bypass-host-and-secure-cookie-prefixes-9aodeefwd","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"security,django,web-security","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Tech Lead Digest","item":"https://daily.dev/sources/techleaddigest"},{"@type":"ListItem","position":3,"name":"Cookie Chaos: How to bypass __Host and __Secure cookie prefixes"}]}
```

