Hint: Frames blocked by X-Frame-Options header [OK]
Common Mistakes:
Confusing Strict-Transport-Security with frame protection
Thinking Content-Security-Policy blocks framing by default
Assuming Cache-Control affects framing
2. Which of the following is the correct syntax to set the Strict-Transport-Security header to enforce HTTPS for one year?
easy
A. Strict-Transport-Security: max-age=3600
B. Strict-Transport-Security: secure=yes
C. Strict-Transport-Security: enable=true
D. Strict-Transport-Security: max-age=31536000
Solution
Step 1: Recall the max-age value meaning
max-age is the time in seconds the browser should enforce HTTPS. One year equals 31,536,000 seconds.
Step 2: Check the options for correct syntax
Strict-Transport-Security: max-age=31536000 uses max-age=31536000 which is one year. Others use wrong values or invalid syntax.
Final Answer:
Strict-Transport-Security: max-age=31536000 -> Option D
Quick Check:
One year max-age = 31536000 seconds [OK]
Hint: One year in seconds is 31536000 for max-age [OK]
Common Mistakes:
Using max-age=3600 which is only one hour
Using invalid parameters like enable or secure
Confusing max-age units (seconds vs minutes)
3. Given this HTTP response header: Content-Security-Policy: default-src 'self'; img-src https://images.example.com; What will happen if the webpage tries to load an image from https://cdn.example.com/pic.jpg?
medium
A. The image will be blocked by the browser.
B. The entire page will fail to load.
C. The image will load successfully.
D. The browser will ignore the Content-Security-Policy header.
Solution
Step 1: Analyze the Content-Security-Policy rules
default-src 'self' allows resources only from the same origin. img-src allows images only from https://images.example.com.
Step 2: Check the image source against allowed domains
https://cdn.example.com is not allowed by img-src, so the browser blocks the image.
Final Answer:
The image will be blocked by the browser. -> Option A
Quick Check:
Image source not in img-src whitelist = blocked [OK]
Hint: Only allowed domains in img-src load images [OK]
Common Mistakes:
Assuming default-src allows all images
Thinking browser ignores CSP headers
Believing the whole page fails if one image blocked
4. A website sets the header X-Content-Type-Options: nosniff but users report some images are not displaying. What is the most likely cause?
medium
A. The images are blocked by Content-Security-Policy.
B. The browser does not support the nosniff option.
C. The server is sending incorrect MIME types for images.
D. The Strict-Transport-Security header is missing.
Solution
Step 1: Understand the effect of X-Content-Type-Options: nosniff
This header tells browsers to trust the declared MIME type and not guess the content type.
Step 2: Identify why images might not display
If the server sends wrong MIME types for images, browsers will block them due to nosniff enforcement.
Final Answer:
The server is sending incorrect MIME types for images. -> Option C
Quick Check:
nosniff blocks mismatched MIME types [OK]
Hint: nosniff blocks wrong MIME types from loading [OK]
Common Mistakes:
Blaming browser support instead of server MIME types