> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/web/csrf/samesite-lax-bypass-via-cookie-refresh.md).

# SameSite Lax Bypass via Cookie Refresh

SameSite Lax Bypass via Cookie Refresh notes for PortSwigger Web Security Academy labs, including exploitation workflow, payload testing, Burp Suite validation, and remediation context.

### SameSite Lax Bypass via Cookie Refresh

The email modification function of the application is vulnerable to a CSRF attack. The goal of the lab is to force the change of email address of a victim user by hosting the demonstration on the provided exploit server.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6cc4231baa3ff91edadc6840891adebc00d278a2%2Fimage%20(374).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

The lab supports OAuth authentication via an external provider. You can connect with the given identifier (`wiener:peter`). During the authentication process, a different domain page is used for OAuth identification.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-66fed4ca14fd9ba8651584d38076800754f7b814%2Fimage%20(373).png?alt=media" alt="" width="553"><figcaption></figcaption></figure>

`You have successfully logged in with your social media account`

* After connecting via the social provider, the answer contains an authentication cookie whose `SameSite` attribute is set to `Lax`.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5daa88eb78310244ca9d4001fe60266867438c1c%2Fimage%20(375).png?alt=media" alt=""><figcaption></figcaption></figure>

If you log out and then restart the authentication stream without retagging the password, the session is reset: a **new** session cookie is issued.

* → In practice, this means that if a user clicked on "logout", they will have to click again on " login" to be redirected to the site and retrieve the new session cookie.
* Thanks to this cookie "refresh" behavior during authentication via the third-party domain, it is possible to consider a sequence where an initial request to the authentication page allows to recover/establish the session cookie, then a second action (client side) triggers the request that modifies the email in the user account.

```html
<form class="login-form" name="change-email-form"
      action="https://0a6100a60304c671804803f0005200d7.web-security-academy.net/my-account/change-email"
      method="POST">
  <input type="hidden" name="email" value="hacked@byjordan" />
</form>

<script>
  window.open("https://0a6100a60304c671804803f0005200d7.web-security-academy.net/social-login", "_blank");
  setTimeout("document.forms['change-email-form'].submit()", 5000);
</script>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/web/csrf/samesite-lax-bypass-via-cookie-refresh.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
