How to Confirm XSS When CSP Allows Only Same-Domain Scripts?
Short answer
A Use a script hosted on the application's own domain, since the CSP permits same-domain scripts, to confirm the XSS execution.
Question
Key Takeaways
The exam tests whether you adapt an XSS proof-of-concept to the site's CSP; the trap is treating a benign inline payload as valid confirmation even though inline scripts are explicitly blocked.
This question tests how to validate an XSS finding when a strict Content Security Policy blocks inline and external scripts but permits same-origin sources. It establishes that the ethical hacker should use an application-hosted script to confirm execution rather than attempting a CSP bypass.
Common mistake: Choosing inline injection because it is the usual first XSS probe; under this CSP the browser blocks it, so the failed execution does not confirm or disprove the vulnerability.
Expert Analysis
Why the Answer Is Correct
Option A follows the CSP that the application actually enforces: inline scripts and external domains are disallowed, but scripts from the application's own domain are permitted. To confirm the XSS, the tester must therefore use a same-origin script that the browser will load and execute if the input reaches an executable context. This validates the vulnerability without trying to defeat the security control, keeping the test closer to real exploitable conditions. As insaniunt noted, the approach is valid because "the CSP allows scripts from the application's own domain."
Why the Other Options Are Wrong
Option C is the intuitive first probe, but inline scripts are explicitly blocked by this CSP, so a benign inline payload will not execute and cannot confirm the flaw. Option D fails for the same reason because external-domain scripts are disallowed by the policy. Option B is not a confirmation step: disabling CSP changes the application's security posture, may exceed the assessment scope, and does not prove that the original input handling is vulnerable. HackerTom's question about trying a simple test box reflects the common inline-first habit, but CSP makes that test ineffective here.
Community Comment Notes
Most commenters support A because it matches the policy's only permitted script source. HackerTom asked, "Isn't the first step always trying some type of hello world or test box?" which captures why C attracts votes, though that instinct breaks under a blocking CSP. LordXander suggested B could also apply but leaned toward A; the stronger reading is that A is direct validation while B is a bypass action that does not confirm the XSS under the stated conditions.
Official Reference
- https://owasp.org/www-community/attacks/xss/
- https://cheatsheetseries.owasp.org/cheatsheets/Content_Security_Policy_Cheat_Sheet.html
These links open the official vendor documentation in a new tab.
Exam Strategy
When a CSP is described, first identify which source expressions are allowed and select the test payload that fits that allowlist. Do not choose inline or external-script tests that the policy explicitly blocks, and avoid disabling CSP as a shortcut because it does not validate the original vulnerability.
Frequently Asked Questions
Why is an inline benign script not enough to confirm the XSS under this CSP?
Can a same-domain hosted script still validate the 'Contact Us' XSS?
Community Votes
50% of anonymous learners picked answer A. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 5 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 5
-
insaniunt 👍 2 Answered AA. Utilize a script hosted on the application's domain to test the form Since the CSP allows scripts from the application's own domain, using a script hosted on the same domain would be a valid and ethical way to confirm the XSS vulnerability. This approach aligns with the permitted behavior of the CSP and helps the ethical hacker assess whether the lack of proper user input validation in the 'Contact Us' form leads to the execution of scripts from the same domain.
-
HackerTom 👍 1 Answered CAny idea why this wouldn't be C? Isn't the first step always trying some type of hello world or test box?
-
LordXander 👍 1 Answered BWell, B could be an option however also A. A is more applicable for an insider threat
-
[Removed] 👍 1Could someone please validate this information
-
[Removed] 👍 1Team can you confirm if this is accurate
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.