PEGACPLSA23V1 practice question 1 of 15

[Security Design] An application has a web page where users can upload and view images. The application uses a Content Security Policy (CSP) to…

Full set: 60 questions
[Security Design] An application has a web page where users can upload and view images. The application uses a Content Security Policy (CSP) to prevent cross-site scripting attacks by restricting the sources of scripts and images that the browser can load. The CSP has the following directives: default-src 'self'; script-src 'self'https://cdn.example.com; img-src 'self' data: blob:. What happens if a user tries to upload and view an image fromhttps://malicious.comon the web page?
Answer options
A: The browser blocks the image from loading and displays an error message. Correct answer
B: The browser loads the image but does not display it on the web page.
C: The browser ignores the CSP and loads the image from any source.
D: The browser loads and displays the image without any issues.
Correct Answer:
A. The browser blocks the image from loading and displays an error message.
Explanation

The configured Content Security Policy (CSP) includes the directive img-src 'self' data: blob:. This directive instructs the browser to only load images from the application's own origin ('self'), as data: URIs, or as blob: URIs. The attempt to load an image from an external domain, https://malicious.com, violates this policy. A compliant browser enforces the CSP by blocking the request to the unauthorized domain. As a result, the image will fail to load, and the browser will typically log a security violation error in its developer console.

Why Incorrect

B: The browser blocks the network request entirely; it does not load the resource and then decide against displaying it. C: A compliant browser's function is to enforce the CSP, not ignore it. Ignoring the policy would render it useless. D: The image will not load because its source, https://malicious.com, is not on the whitelist defined by the img-src directive.

References

1. Pega Platform™ Documentation, "Content security policies": This document outlines that a CSP adds a layer of protection to mitigate attacks like cross-site scripting by specifying the domains that the browser should consider valid sources for resources. The browser is responsible for enforcing this policy.

2. Pega Platform™ Documentation, "Content security policy management": This section details the configuration of CSP directives, including img-src. It explains that these directives create a whitelist of allowed sources, and any resource from a non-whitelisted source will be blocked by the browser.

3. Pega Platform™ Documentation, "Security Checklist": The Pega security checklist emphasizes implementing a strict Content Security Policy as a critical measure to secure the application, confirming that policies are meant to be enforced to prevent loading of untrusted assets.

Scroll to Top