在将字符串存储到数据库之前,我可以使用什么来清除恶意Markdown Vectors中的字符串?
我在后端使用spring boot,我需要在字符串保存到数据库中之后用于跨站点脚本攻击之前对字符串进行消毒。以下是恶意降价的示例:
[clickme](javascript:prompt(document.domain))
保存后,它将显示为链接并可以单击。
发布于 2021-02-10 21:49:50
OWASP是最老的库,可以防止这种或任何其他类型的恶意用户输入,就您的情况而言,here是您需要浏览的页面。
下面是一个例子
var sanitizer = new HtmlSanitizer();
var html = @"<script>alert('xss')</script><div onload=""alert('xss')"""
+ @"style=""background-color: test"">Test<img src=""test.gif"""
+ @"style=""background-image: url(javascript:alert('xss')); margin: 10px""></div>";
var sanitized = sanitizer.Sanitize(html, "http://www.example.com");
Assert.That(sanitized, Is.EqualTo(@"<div style=""background-color: test"">"
+ @"Test<img style=""margin: 10px"" src=""http://www.example.com/test.gif""></div>"));请检查web应用程序防火墙是否为https://owasp.org/www-community/Web_Application_Firewall
https://stackoverflow.com/questions/66061452
复制相似问题