You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: write-ups_unpublished/web_sec101.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -174,10 +174,12 @@ Also:
174
174
175
175
### Headers
176
176
- CSP: block calls from an iframe and block what's included on page (all resources), so good against clickjacking (iframe) and XSS.
177
-
- CSRF protections (not a specific header but often added as e.g. a token in header): recommended to have as it could be dangerous for any other site to make GET / POST request to a URL directly (as it will use active cookies) - "clickjacking".
177
+
- CSRF protections (not a specific header but often added as e.g. a token in header): recommended to have as it could be dangerous for any other site to make GET / POST request to a URL directly - "clickjacking". Basically only a risk if auth. cookies are SameSite=None/Lax (not issue with auth via authorization header / local storage).
178
178
- CORS: CORS headers start with "Access-Control-" and are checked via an extra initial (preflight) request which makes an HTTP OPTION request.
179
179
CORS "determines whether browsers block frontend JavaScript code from accessing responses for cross-origin requests".
180
180
So for instance, allow (javascript) Fetch requests - or equivalent - to make requests and also use cookies etc., when done cross-origin.
181
+
To be clear, it is better to not have any CORS headers at all in which case Fetch will fail.
182
+
If CORS headers are indeed used, this may be an issue if auth is done via cookies with SameSite=None/Lax or via authorization header (local storage), depending on CORS config (such as allowed origin as well as Access-Control-Allow-Headers: Authorization, or for cookies, Access-Control-Allow-Credentials: true)
181
183
- Referer: site where we're coming from
182
184
- Origin: site that makes request (Note: usually same-origin, except cases such as Fetch mentioned above. So CORS does often not "matter": e.g. if following a link on badsite.x to site, or site in an iframe on badsite.x)
183
185
@@ -192,6 +194,8 @@ Note that same site requests are always allowed such as cookies from _monkey.r0x
192
194
Note the definition of SameSite, for instance *.github.com are **different** "sites" (as per https://publicsuffix.org/), while *.r0x.se would all be considered SameSite (see also e.g. https://jub0bs.com/posts/2021-01-29-great-samesite-confusion/).
193
195
194
196
197
+
195
198
### General
196
-
- iframe: is a separate environment "similar to" another tab. An iframe usually includes browser cookies if already logged in to that site elsewhere (if other domain must be SameSite=None),
197
-
however the site outside the iframe cannot read them (or vice versa); however it's possible to communicate between site and iframe if both sides enables this communication.
199
+
- iframe: is a separate environment "similar to" another tab. An iframe usually includes browser cookies if already logged in to that site elsewhere (although if other domain must be SameSite=None),
200
+
however the site outside the iframe cannot read them (or vice versa); however it's possible to communicate between site and iframe if both sides enables this communication. \
201
+
Risks with iframe is mainly that of clickjacking _(attacker can overlay invisible objects, trying to catch user input or otherwise fool the user performing some website action)_ and information leaks _(either if site includes code that allows leakage to site outside of iframe, or, via indirect methods such as timing attacks or where a user clicks via overlays)_.
0 commit comments