waf subresource-integrity-rule
Use this command to configure a Subresource Integrity (SRI) Rule for use in a Subresource Integrity Policy.
A Subresource Integrity (SRI) Rule defines a single external resource that should be validated by the browser before execution. The rule specifies the resource’s expected cryptographic hash and how cross-origin credentials should be handled during the load process. This is useful for JavaScript files, stylesheets, and other assets hosted on third-party CDNs or untrusted sources.
FortiWeb uses this rule to inject integrity and cross-origin attributes into the corresponding <script>, <link>, or other resource tags in server responses. This ensures that only untampered content is executed on the client side, protecting against risks such as supply chain compromise or JavaScript drift.
Each rule targets a specific URL and must be referenced by a Subresource Integrity Policy to be enforced.
Note: A Subresource Integrity Policy is also required to enable full enforcement capabilities in Client-Side Protection. When used together, SRI and Client-Side Protection provide comprehensive in-browser defense against content manipulation and unauthorized script execution.
Syntax
config waf subresource-integrity-rule
edit <name>
set url <string>
set cross-origin {anonymous|use-credentials}
next
end
Example
config waf subresource-integrity-rule
edit "trusted-jquery"
set url https://cdn.example.com/js/jquery-3.6.0.min.js
set integrity-hash sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxEMn5Dj8WHz03a+0I4AfA+d+dXbYwK
set cross-origin anonymous
next
end