[Security] Checkout's anonymous basket cookie path skips GUID validation (unreachable today)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- Half a day
- Newbie friendliness
- 62/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- csharp
- Domain
- authentication, security
Research direction
Compare GetOrSetBasketCookieAndUserName() in src/Web/Pages/Basket/Checkout.cshtml.cs against the version in Pages/Basket/Index.cshtml.cs; the latter is the reference for the GUID check. Read Program.cs to confirm the [Authorize]/AuthorizePage("/Basket/Checkout") wiring that makes the anonymous branch unreachable, then decide where one shared cookie helper should live so the HttpOnly/Secure/SameSite/IsEssential flags are set in one place. Done means the dead branch is gone or consolidated with the GUID check, and a functional test under the Web functional tests asserts an anonymous request to Checkout redirects to login.
Written by the indexing model from the issue text.
Description
Summary
src/Web/Pages/Basket/Checkout.cshtml.cs has its own GetOrSetBasketCookieAndUserName() for anonymous users. Unlike the version in Pages/Basket/Index.cshtml.cs, it does not check that the basket cookie value is a GUID. It uses whatever the cookie contains as the basket owner's "username". The basket cookie it creates also has no HttpOnly, Secure, SameSite or IsEssential settings.
Why it is not exploitable today
The page is [Authorize], and Program.cs also adds AuthorizePage("/Basket/Checkout"). So SetBasketModelAsync() always takes the signed-in branch and the anonymous branch never runs.
Why it is still worth fixing
If authorization on Checkout were ever relaxed (for example to support guest checkout), an anonymous attacker could set the basket cookie to a victim's email address. They could then view the victim's basket and place an order from it, which also deletes the basket. The missing GUID check is exactly what prevents this on the Basket page.
Suggested fix
- Remove the unreachable anonymous branch from Checkout, or share one helper with
Basket/Indexthat includes the GUID check. - Give the basket cookie
HttpOnly = true,Secure = true,SameSite = LaxandIsEssential = true, in one place. - Add a functional test that an anonymous request to Checkout redirects to login, so the protection this relies on is covered.
- Dominant language
- C#
- Stars
- 643
- Forks
- 329
- Avg merge
- 1h 48m
- Merged PRs (30d)
- 21
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NimblePros/eShopOnWeb
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 57/100
NimblePros/eShopOnWeb#342 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
NimblePros/eShopOnWeb#331 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
NimblePros/eShopOnWeb#233 · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
NimblePros/eShopOnWeb#232 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 52/100
NimblePros/eShopOnWeb#212 ·
Maintainers usually reply within 1 day
All issues in NimblePros/eShopOnWeb
Similar issues
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
unoplatform/uno#26555 ·
Maintainers usually reply within 1 day
-
chore project-system small
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
vikramlearning/blazorbootstrap#1388 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
GamaEdtech/gamatrain-back#977 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jhaizhou-ops/S2Arm#1396 · 1 comment ·
Maintainers usually reply within 1 day