Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.4.15
H2
Fat Jar
No response
SVG 文件包含 JS 脚本可能会引发的 XSS 漏洞,当然目前也仅仅只有在管理端会触发,但有一定必要做优化。
SVG 文件示例:
<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg"> <rect width="500" height="500" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" /> <script type="text/javascript"> alert("POC"); </script> </svg>
The text was updated successfully, but these errors were encountered:
业界有成熟的规避方案吗?还是说简单粗暴直接禁止SVG上传。
我目前找到了这个帖子: https://security.stackexchange.com/questions/148507/how-to-prevent-xss-in-svg-file-upload
Direct view with content-disposition: attachment - not vulnerable - Headers are sent to force the file to be downloaded. Direct view with CSP - not vulnerable - The Content Security Policy is set to disallow inline JavaScript. Image Tags - not vulnerable - The SVG is referenced through image tags which prevent scripts. Tags With CSP - not vulnerable - Image tags and the same CSP as above for double protection.
Direct view with content-disposition: attachment - not vulnerable - Headers are sent to force the file to be downloaded.
Direct view with CSP - not vulnerable - The Content Security Policy is set to disallow inline JavaScript.
Image Tags - not vulnerable - The SVG is referenced through image tags which prevent scripts.
Tags With CSP - not vulnerable - Image tags and the same CSP as above for double protection.
主要是: 1.访问该文件时加上content-disposition: attachment头,强制下载后才能访问 2.页面内引用该SVG的地方采用CSP规范禁用行内JS 3.页面内引用该SVG的地方使用img标签防止JS脚本 4.使用CSP和img标签进行双重保护
那我理解第2点的行内JS禁用的话可能不太方便开发和访问,有时候还是需要使用行内JS的,
第3点 引用的地方都保证使用img标签(不知道目前前端页面是否都能达到这个要求)。
关键就是1和4两点了,访问的地方加上content-disposition: attachment头,这个后端如果把上传文件存在本地的话可以单独用filter做处理,上传到OSS的话不太清楚,还请大佬们指点。
Sorry, something went wrong.
@guqing 要强行杠一下的话也能算,万一博主也不知道svg有问题,不过可以算是个不紧急的BUG吧,可以缓缓。
@guqing 要强行杠一下的话也能算,万一博主也不知道 svg 有问题,不过可以算是个不紧急的 BUG 吧,可以缓缓。
刚刚没注意看这个issue已经回复过这不是问题了 发现我回复的答非所问所以我删除了回复 svg的问题后续或许多重考虑 例如后台预览时使用沙箱,博主可以设置允许上传的文件格式 预览时将svg转png等方式来避免
No branches or pull requests
是什么版本出现了此问题?
1.4.15
使用的什么数据库?
H2
使用的哪种方式部署?
Fat Jar
在线站点地址
No response
发生了什么?
SVG 文件包含 JS 脚本可能会引发的 XSS 漏洞,当然目前也仅仅只有在管理端会触发,但有一定必要做优化。
SVG 文件示例:
相关日志输出
No response
附加信息
No response
The text was updated successfully, but these errors were encountered: