Content-Security-Policy: require-sri-for script;", 143 | "Low", 144 | "
When a script is served from a third-party source such as a public Content Delivery Network (CDN) location, the 'integrity' attribute of the 'script' tag should be used to confirm that the script can be trusted (i.e., it has not been modified from a version known to include only intended functionality and not be malicious). This attribute instructs the browser to load the third-party script, generate a hash of the file, and validate that its hash matches the hash of the exact version of the script known to be trusted before it can be executed. If the hash of the script loaded from the third-party source does not match the hash of the trusted version, most modern browsers will block the script's execution.
In order to enforce the use of subresource integrity for all scripts used across a site, the 'require-sri-for script' Content-Security-Policy directive should be used to instruct the browser to validate that the 'integrity' attribute is in place for all script elements.
" 145 | ) 146 | ); 147 | } 148 | return issues; 149 | } 150 | 151 | // Check for Cross-Domain Script Includes (DOM) 152 | public ListWhen an application includes a script from an external domain, this script is executed by the browser within the security context of the invoking application. The script can therefore do anything that the application's own scripts can do, such as loading additional third-party scripts into DOM, accessing application data, and performing actions within the context of the current user.
If you include a script from an external domain, then you are trusting that domain with the data and functionality of your application, and you are trusting the domain's own security to prevent an attacker from modifying the script to perform malicious actions within your application.
" 168 | ) 169 | ); 170 | } 171 | return issues; 172 | } 173 | 174 | // Check for Cross-Domain Script Includes (DOM) 175 | public ListWhen a script is served from a third-party source such as a public Content Delivery Network (CDN) location, the 'integrity' attribute of the 'script' tag should be used to confirm that the script can be trusted (i.e., it has not been modified from a version known to include only intended functionality and not be malicious). This attribute instructs the browser to load the third-party script, generate a hash of the file, and validate that its hash matches the hash of the exact version of the script known to be trusted before it can be executed. If the hash of the script loaded from the third-party source does not match the hash of the trusted version, most modern browsers will block the script's execution.
In order to enforce the use of subresource integrity for all scripts used across a site, the 'require-sri-for script' Content-Security-Policy directive should be used to instruct the browser to validate that the 'integrity' attribute is in place for all script elements.
" 202 | ) 203 | ); 204 | } 205 | } 206 | 207 | if (sriScripts.size() > 0){ 208 | // For all of the resources which use SRI attributes, check the hash 209 | for (String scriptUrl: sriScripts){ 210 | if (!finder.getScriptObjectFor(scriptUrl).checkIntegrity()){ 211 | // Integrity check failed 212 | ListThe original integrity attribute was: " + integrityAttribute + "
The hashes obtained for the item are:" + theseHashes + "
", 227 | "High", 228 | "When a script is served from a third-party source such as a public Content Delivery Network (CDN) location, the 'integrity' attribute of the 'script' tag should be used to confirm that the script can be trusted (i.e., it has not been modified from a version known to include only intended functionality and not be malicious). This attribute instructs the browser to load the third-party script, generate a hash of the file, and validate that its hash matches the hash of the exact version of the script known to be trusted before it can be executed. If the hash of the script loaded from the third-party source does not match the hash of the trusted version, most modern browsers will block the script's execution.
In order to enforce the use of subresource integrity for all scripts used across a site, the 'require-sri-for script' Content-Security-Policy directive should be used to instruct the browser to validate that the 'integrity' attribute is in place for all script elements.
" 229 | ) 230 | ); 231 | } 232 | } 233 | } 234 | 235 | return issues; 236 | } 237 | 238 | // Check for Cross-Domain Script Includes (DOM) 239 | public ListWhen a script is served from a third-party source such as a public Content Delivery Network (CDN) location, the 'integrity' attribute of the 'script' tag should be used to confirm that the script can be trusted (i.e., it has not been modified from a version known to include only intended functionality and not be malicious). This attribute instructs the browser to load the third-party script, generate a hash of the file, and validate that its hash matches the hash of the exact version of the script known to be trusted before it can be executed. If the hash of the script loaded from the third-party source does not match the hash of the trusted version, most modern browsers will block the script's execution.
In order to enforce the use of subresource integrity for all scripts used across a site, the 'require-sri-for script' Content-Security-Policy directive should be used to instruct the browser to validate that the 'integrity' attribute is in place for all script elements.
" 256 | ) 257 | ); 258 | } 259 | // Check for known, bad JavaScript paths 260 | if (iocChecker.checkUrl(scriptUrl)){ 261 | // This is a bad resource based on the path 262 | ListWhen a script is served from a third-party source such as a public Content Delivery Network (CDN) location, the 'integrity' attribute of the 'script' tag should be used to confirm that the script can be trusted (i.e., it has not been modified from a version known to include only intended functionality and not be malicious). This attribute instructs the browser to load the third-party script, generate a hash of the file, and validate that its hash matches the hash of the exact version of the script known to be trusted before it can be executed. If the hash of the script loaded from the third-party source does not match the hash of the trusted version, most modern browsers will block the script's execution.
In order to enforce the use of subresource integrity for all scripts used across a site, the 'require-sri-for script' Content-Security-Policy directive should be used to instruct the browser to validate that the 'integrity' attribute is in place for all script elements.
" 272 | ) 273 | ); 274 | } 275 | } 276 | 277 | return issues; 278 | } 279 | 280 | // Check for invalid JS links 281 | public ListThe JavaScript at " + scriptUrl + " was not accessible during evaluation, as the hostname in the URL could not be resolved via DNS. This item should be evaluated for the potential of resource takeover.
", 296 | "Low", 297 | "When a script is served from a third-party source and the hostname for the source does not resolve, it may be possible for an attacker to register the domain and host malicious JavaScript at the indicated URL.
" 298 | ) 299 | ); 300 | } 301 | } 302 | return issues; 303 | } 304 | 305 | private void log(Integer currentScanNumber, String urlString, String logString){ 306 | System.out.println("[JS-SRI][" + currentScanNumber + "] " + urlString + " - " + logString); 307 | } 308 | 309 | // 310 | // implement IScannerCheck 311 | // 312 | 313 | @Override 314 | public List