Advanced CORS Mechanisms and Security Implications
An in-depth quiz on advanced concepts of Cross-Origin Resource Sharing (CORS) and its security implications.
Questions in this quiz
10 questions on Advanced CORS Mechanisms and Security Implications. Work through them here, then start the quiz to answer them and see your score.
1.Which HTTP header is used by the server to indicate which origins are allowed to access its resources?
- AAccess-Control-Max-Age
- BAccess-Control-Allow-Origin
- CAccess-Control-Allow-Headers
- DAccess-Control-Request-Method
2.What is the purpose of the 'Vary: Origin' header in the context of CORS?
- ATo list all allowed headers
- BTo specify allowed HTTP methods
- CTo set the preflight cache duration
- DTo cache responses based on the Origin header
3.In a CORS preflight request, which HTTP method is used?
- AOPTIONS
- BGET
- CPOST
- DHEAD
4.What does the 'Access-Control-Allow-Credentials' header do?
- ASpecifies allowed HTTP methods
- BLists allowed request headers
- CSets the maximum age for preflight requests
- DAllows cookies to be sent with requests
5.Which of the following is NOT a valid value for the 'Access-Control-Allow-Origin' header?
- Alocalhost
- B*
- Chttp://example.com
- Dnull
6.How does CORS enhance security in web applications?
- ABy allowing only same-origin requests
- BBy blocking all cross-origin requests
- CBy encrypting all HTTP requests
- DBy specifying which cross-origin requests are permitted
7.What is the role of the 'Access-Control-Expose-Headers' header in CORS?
- ATo specify allowed HTTP methods
- BTo define the allowed origins
- CTo list headers that can be exposed to the client
- DTo set the preflight cache duration
8.Which CORS header is used to specify the HTTP methods allowed when accessing the resource?
- AAccess-Control-Allow-Headers
- BAccess-Control-Allow-Methods
- CAccess-Control-Allow-Origin
- DAccess-Control-Max-Age
9.What does the 'Access-Control-Max-Age' header specify?
- AThe maximum age of the resource
- BThe maximum number of allowed headers
- CThe maximum number of allowed origins
- DThe maximum time a preflight request can be cached
10.Which of the following scenarios would trigger a CORS preflight request?
- AA DELETE request with no custom headers
- BA POST request with 'Content-Type: application/json'
- CA PUT request with 'Content-Type: text/plain'
- DA simple GET request