# G5 Password step and login CSRF

[Index](../index.md) | [Tree](../tree.md) | HTML version: [G5.html](G5.html)

Security of the password step: a login-CSRF attack that silently signs the victim into an attacker account is defeated by the password step, plus wrong password, login lockout shared with the login form, a forged confirm form, and the "not you, sign out" line.

<a id="a22"></a>
## A22 Login-CSRF attack is defeated

*Language: EN | Mode: login | Status: PASS | Repo spec: GOL S9*

attack story, one victim video: victim signed in to own account W (name VICTIM), then signed out (the core login ignores a POST while someone is signed in) -> attacker page (fake origin attacker.example.test, served by page.route) auto-POSTs the login of attacker account X (same email as the victim's guest order, name ATTACKER) -> victim is now silently signed in as ATTACKER -> victim opens the genuine link: only the password step "You're signed in as ATTACKER (V)", order stays unlinked. DB/DOM manipulation: both accounts renamed via UPDATE oc_customer.firstname for readability (spec uses E2E), link row inserted directly instead of read from a mail

![01. victim signed in to own account](../media/G5/A22-01-victim-signed-in-to-own-account.png)
*01. victim signed in to own account*

![02. attacker page auto posts login](../media/G5/A22-02-attacker-page-auto-posts-login.png)
*02. attacker page auto posts login*

![03. victim is now signed in as attacker account](../media/G5/A22-03-victim-is-now-signed-in-as-attacker-account.png)
*03. victim is now signed in as attacker account*

![04. password step names attacker account nothing linked](../media/G5/A22-04-password-step-names-attacker-account-nothing-linked.png)
*04. password step names attacker account nothing linked*

Video: [A22-login-csrf-defeated-victim](../media/G5/A22-login-csrf-defeated-victim.webm)

<a id="a23"></a>
## A23 Wrong password

*Language: EN | Mode: login | Status: PASS | Repo spec: GOL S9*

same victim video: wrong password gives "The password is incorrect. Please try again.", state stays confirm, link unused, order unlinked, 1 failed attempt counted

![01. wrong password error](../media/G5/A23-01-wrong-password-error.png)
*01. wrong password error*

Video: [A22-login-csrf-defeated-victim](../media/G5/A22-login-csrf-defeated-victim.webm)

The video for this scenario is the shared A22 victim video (see A22).

<a id="a24"></a>
## A24 Lockout shared with the login form

*Language: EN | Mode: login | Status: PASS | Repo spec: GOL S9*

same victim video: failed-login counter set to 1000 by DB manipulation (oc_customer_login); right password refused with "Too many incorrect password attempts. Please try again in 1 hour."; counter then set to 2 by DB and the right password links 1 order (success shot is in this prefix)

![01. lockout message right password refused](../media/G5/A24-01-lockout-message-right-password-refused.png)
*01. lockout message right password refused*

![02. below limit right password links one order](../media/G5/A24-02-below-limit-right-password-links-one-order.png)
*02. below limit right password links one order*

Video: [A22-login-csrf-defeated-victim](../media/G5/A22-login-csrf-defeated-victim.webm)

The video for this scenario is the shared A22 victim video (see A22).

<a id="a25"></a>
## A25 Forged confirm form

*Language: EN | Mode: login | Status: PASS | Repo spec: GOL S9 (request.post without csrf)*

DOM manipulation (hidden csrf set to "forged" before submit, simulating a cross-site/stale form) with the right password: error "Your session has expired. Please try again.", data-state stays confirm, link unused, order unlinked; reopening the step and submitting the genuine form links 1 order. Link row inserted via DB

![01. password step](../media/G5/A25-01-password-step.png)
*01. password step*

![02. csrf replaced password typed](../media/G5/A25-02-csrf-replaced-password-typed.png)
*02. csrf replaced password typed*

![03. session expired error nothing linked](../media/G5/A25-03-session-expired-error-nothing-linked.png)
*03. session expired error nothing linked*

![04. genuine form succeeds](../media/G5/A25-04-genuine-form-succeeds.png)
*04. genuine form succeeds*

Video: [A25-forged-confirm](../media/G5/A25-forged-confirm.webm)

<a id="a26"></a>
## A26 "If this isn't your account, sign out"

*Language: EN | Mode: login | Status: PASS | Repo spec: GOL S1 (href only)*

password step -> click "sign out" -> logout page -> reopening the confirm route leads to the login page (token kept in session, not re-tested past login here). Link row inserted via DB

![01. not you line](../media/G5/A26-01-not-you-line.png)
*01. not you line*

![02. password step full page](../media/G5/A26-02-password-step-full-page.png)
*02. password step full page*

![03. logged out](../media/G5/A26-03-logged-out.png)
*03. logged out*

![04. reopening confirm leads to login](../media/G5/A26-04-reopening-confirm-leads-to-login.png)
*04. reopening confirm leads to login*

Video: [A26-not-you-sign-out](../media/G5/A26-not-you-sign-out.webm)
