skip to content

Browser Trust Boundaries

The rules a browser enforces above HTTP: cross-origin read grants, script-source limits, and defences against forged requests. Interviewers probe them because the server asks but the browser decides.

part ofWeb protocols & securityoverview, primer and where to startread it →
on this pageshow

explore

questions

77 · 3 sections

Why does a cross-origin request the browser blocks reach the calling script with no status code and no body?

level: juniorimportance: must knowfreq 66%
basics
~20 s

A failed CORS check replaces the server's response with a network error before script sees it - type "error", status 0, an empty header list, a null body - so the call rejects with a bare TypeError that carries no protocol detail at all.

open as a page

A cross-origin lookup shows an OPTIONS request on the wire before the real one - what does the browser put in it?

level: juniorimportance: must knowfreq 72%
basics
~10 s

A CORS-preflight request: method OPTIONS, the calling page's Origin, Access-Control-Request-Method naming the method the real call will use, Access-Control-Request-Headers listing any CORS-unsafe request-header names, and Accept: /. It carries no body.

open as a page

A cross-origin response carries a custom X-Gauge-Reported-At header that script cannot read - which response field makes it readable?

level: juniorimportance: must knowfreq 58%
basics
~10 s

Access-Control-Expose-Headers, sent by the server on that response, names the extra fields script may read. Without it a cross-origin caller sees only seven names: Cache-Control, Content-Language, Content-Length, Content-Type, Expires, Last-Modified and Pragma.

open as a page

What exact value does a browser put in the `Origin` request header for a page at `https://board.example.org/embed/arrivals?stop=42`?

level: juniorimportance: must knowfreq 72%
basics
~10 s

The Origin request header carries only scheme, host and a non-default port: https://board.example.org. The path, the query, the fragment and any trailing slash are absent, and scheme and host are ASCII-lower-cased.

open as a page

Your picking API answers its OPTIONS preflight with 401 - why can that cross-origin call never succeed?

level: middleimportance: must knowfreq 57%
basics
~20 s

For two independent reasons. The preflight is sent in credentials mode "same-origin", so cross-origin it carries no cookie and no authentication entry and cannot meet the WWW-Authenticate challenge; and 401 is not an ok status, so the preflight fails regardless.

open as a page

In a Content-Security-Policy, what does default-src do for the fetch directives you did not write?

level: juniorimportance: must knowfreq 76%
basics
~20 s

default-src supplies the source list for any fetch directive absent from the policy. A directive you do write takes nothing from it - the written list replaces the default wholly for that resource type, and an empty list blocks everything.

open as a page

In a Content-Security-Policy source list, what do the keyword sources 'self' and 'none' each mean?

level: juniorimportance: must knowfreq 72%
basics
~20 s

'self' matches the protected document's own origin - same scheme, host and port. 'none' matches nothing, so the directive carrying it permits no source at all. Both are keyword-sources, and the single quotes are part of the grammar.

open as a page

A Content-Security-Policy sends script-src 'nonce-abc123'; what must an inline script element carry, and how is that value matched?

level: juniorimportance: must knowfreq 62%
basics
~10 s

The element needs a nonce content attribute holding exactly the base64-value from the policy: 'nonce-abc123' matches nonce="abc123". The comparison is a literal ASCII case-sensitive string match, with no base64 decoding and no normalisation.

open as a page

What does the Content-Security-Policy-Report-Only response header do to a resource that the policy it carries would forbid?

level: juniorimportance: must knowfreq 70%
basics
~20 s

Content-Security-Policy-Report-Only enforces nothing. A conforming browser loads and runs the resource the policy forbids, records the violation, and sends a report to the destination the policy names. It measures a policy; it does not apply one.

open as a page

What does an external `<script>` element's `integrity` attribute add when the Content-Security-Policy already allows that third-party host?

level: juniorimportance: must knowfreq 64%
basics
~20 s

Subresource Integrity pins the bytes rather than the origin: a conforming browser digests the fetched file and refuses it unless a hash in the integrity attribute matches. An allowlist only settles where script may come from.

open as a page

Your claim upload is rejected by the built-in CSRF token filter - why does answering 401 Unauthorized instead of 403 Forbidden mislead the client?

level: juniorimportance: must knowfreq 58%
basics
~20 s

A CSRF token mismatch is a provenance failure, not a credential one: the session cookie was valid, so 403 Forbidden fits. A 401 Unauthorized tells the client its credential is bad, so it discards a good session and forces a needless login.

open as a page

What does the Origin request header tell a server about an incoming POST, and what does it not?

level: juniorimportance: must knowfreq 58%
basics
~20 s

A conforming user agent, not page script, writes the Origin request header, so a value that is not yours means another document initiated the request. Its absence proves nothing, and a client that is not a browser can send any value.

open as a page

A booking form posts a hidden field holding an unpredictable value the server stored against the session - what does checking it prove?

level: juniorimportance: must knowfreq 74%
basics
~20 s

A matching value proves the request was composed by a page this site served: the value is unpredictable and its authoritative copy lives in server-side session state, so a document from elsewhere can neither read nor guess it.

open as a page

With no script at all, what requests can a hostile page emit at a clinic's cookie-authenticated booking endpoints?

level: middleimportance: must knowfreq 60%
basics
~20 s

Plain markup can emit a GET through any subresource or navigation, and a form POST whose body is one of three encodings: application/x-www-form-urlencoded, multipart/form-data or text/plain. It cannot add a request header field of its own.

open as a page