Help us learn about your current experience with the documentation. Take the survey.
检测到无效的子资源完整性(Sub-Resource Integrity)值
描述
JavaScript 或 CSS 源文件被发现包含无效的
子资源完整性(Sub-Resource Integrity, SRI)
integrity 值或缺失的 crossorigin 值。这些脚本或链接应被调查,以确保它们没有被恶意篡改。如有疑问,请联系脚本所有者或将其替换为已知良好的版本。
修复建议
所有已识别的资源应来自与目标应用程序相同的域名。如果无法实现,强烈建议所有实现 src 值的 script 标签,或实现 href 值的 link 标签都包含子资源完整性(Sub-Resource Integrity)。要生成 SRI 完整性值,可以使用 SRI hash 工具,或运行以下命令之一:
cat FILENAME.js | openssl dgst -sha384 -binary | openssl base64 -Ashasum -b -a 384 FILENAME.js | awk '{ print $1 }' | xxd -r -p | base64
这些工具的输出必须作为附加属性添加,特别是:integrity 和 crossorigin=anonymous 或 crossorigin=use-credentials。
有效的 SRI 保护脚本标签示例如下:
<script src="https://example.com/example-framework.js"
integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC"
crossorigin="anonymous"></script>详情
| ID | Aggregated | CWE | Type | Risk |
|---|---|---|---|---|
| 829.2 | true | 829 | Passive | Medium |