Unit 6: The browser security model · Lesson 1 of 5 · 14 min
Same origin
Scheme, host and port together decide what a page may read.
mission
- You are
- The analyst reviewing the shop.
- Situation
- Every browser rule in this unit starts from one question: do two URLs share an origin?
- Goal
- Learn the rule well enough to answer instantly.
- Hand in
- Correct answers for the shop's own addresses.
Origins as apartment blocks
An origin
https://shop.example.com:443/account
- 1
httpsscheme - 2
shop.example.comhost - 3
443port, implied by https - 4
/accountpath, not part of the origin
Same origin or not?
Page origin http://127.0.0.1:8000
| URL | Scheme | Host | Port | Result |
|---|---|---|---|---|
| http://127.0.0.1:8000/api/products | http | 127.0.0.1 | 8000 | same origin |
| https://127.0.0.1:8443/shop | https | 127.0.0.1 | 8443 | cross origin |
| http://localhost:8000/shop | http | localhost | 8000 | cross origin |
| http://127.0.0.1:8001/ | http | 127.0.0.1 | 8001 | cross origin |
| https://shop.internal:8443/ | https | shop.internal | 8443 | cross origin |
What same origin protects
page on http://127.0.0.1:8000
fetch("/api/orders")
reads the answerSame origin: full access.
page on https://other.example
fetch("http://127.0.0.1:8000/api/orders")
cannot read the answerDifferent origin: the request may go, the answer stays hidden unless CORS allows it.
What a defender takes away
- 1An origin is scheme, host and port. Nothing else.
- 2
localhostand127.0.0.1are different origins, even on the same machine. - 3Same origin stops reading, not sending. That gap is why CSRF and CORS exist.
Questions
0 of 3 solved
Answer each one from what you find on your lab machine.