Consider if something like this was attempted by an attacker injecting XSS:
<script src="https://maps.googleapis.com/foo?callback=alert"></script>
This would execute the foo
function from the Google APIs JavaScript SDK, and upon it's return would call the alert
. This demonstrates that an attacker would be able to inject inline code into the page, which would be executed. Therefore XSS is achieved which bypasses the blocking of unsafe-inline
code.
Of course, what can be called would depend on the arguments passed and how exactly Google sanitise the callback parameter. It appears that CSP Validator just has a simple rule to flag these in the form "does the domain in the CSP support JSONP?" which does not take into account how the callback is executed.
This seems fair, as CSP Validator will never know if any code alterations on the external domain ever introduce or patch such vulnerabilities so I think it is correct that this is flagged.