- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我浏览了很多帖子,但没有成功地确定如何摆脱来 self 的 asmx Web 服务的响应中讨厌的 d,如 {"d":{"Response":"OK","Auth-Key":"JKPYZFZU"}}。
这是由我的类“public Dictionary UserDevice”通过返回 Dictionary 对象创建的。
如果这该死的东西不把它全部放入 d 对象中,我会非常高兴!
最佳答案
基本上,JSON 数组表示法 ['hello']
本身就是有效的 JavaScript,而 JSON 对象表示法 {'d': ['hello'] }
本身不是有效的 JavaScript有效的 JavaScript。这导致数组符号可执行,从而开启了 XSS 攻击的可能性。默认情况下将数据包装在对象中有助于防止这种情况。
您可以在 post by Dave Ward 中阅读更多有关它为何存在的信息。 。 (编辑:正如 @user1334007 所指出的,Chrome 现在将此网站标记为不安全)
戴夫·里德 (Dave Reed) 对该文章的评论特别具有启发性:
It’s one of those security features that has a very easy tomisunderstand purpose. The protection isn’t really againstaccidentally executing the alert in your example. Although that is onebenefit of ‘d’, you’d still have to worry about that while evaluatingthe JSON to convert it to an object.
What it does do is prevent the JSON response from being wholesaleexecuted as the result of a XSS attack. In such an attack, theattacker could insert a script element that calls a JSON webservice,even one on a different domain, since script tags support that. And,since it is a script tag afterall, if the response looks likejavascript it will execute as javascript. The same XSS attack canoverload the object or array constructors (among other possibilities)and thereby get access to that JSON data from the other domain.
To successfully pull that off, you need (1) a xss vulnerable site(good.com) — any site will do, (2) a JSON webservice that returns adesired payload on a GET request (e.g. bank.com/getaccounts), (3) anevil location (evil.com) to which to send the data you captured frombank.com while people visit good.com, (4) an unlucky visitor togood.com that just happened to be logged into bank.com using the samebrowser session.
Protecting your JSON service from returning valid javascript is justone thing you can do to prevent this. Disallowing GET is another(script tags always do GET). Requiring a certain HTTP header isanother (script tags can’t set custom headers or values). Thewebservice stack in ASP.NET AJAX does all of these. Anyone creatingtheir own stack should be careful to do the same.
关于json.net - json asmx 和那个讨厌的 d :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3418013/
我有一个 asmx 服务,它接受一个 int 参数。我可以打开服务的 URL 并查看服务描述屏幕。从这里我可以将查询参数输入表单并调用 Web 服务。 有没有办法直接从 URL/查询字符串调用 Web
我有一个通过 SSL 连接运行良好的 ASMX Web 服务,但我想让这些 Web 服务在没有 SSL 的情况下无法访问。 在网络表单中,我只会使用以下代码: if (!Request.IsSecur
似乎 ASMX 隐含地不允许使用 OPTIONS 动词。我发布这个问题是因为我使用带有 POST 的 jQuery AJAX 调用,它首先在发出 POST 动词**之前向服务器查询可用的选项。 默认情
所以我发现自己遇到了一个难题。我们的应用程序中有一些旧的 asmx Web 服务,多年来一直运行良好。 突然间,他们停止了构建服务器(CI)上的工作。我说停止工作,因为即使当我导航到服务时显示服务描述
我有一个 C# .net Web 服务,需要限制其访问。我已经要求我的消费者使用用户名和密码来调用该服务。但是,有没有办法限制对实际 asmx 页面和 WSDL 的访问?我需要通过用户名/密码和 IP
描述 我有一个遗留类型 HttpRequestScoped以及使用该服务的遗留 Web 服务。为了解决遗留问题中的服务,我有一个全局解析器。这一切在 1.4 中运行良好,现在我正在使用 2.1.12,
有谁知道 SQL Server Reporting Services 中的两个 Web 服务端点 ReportService2005.asmx 和 ReportExecution2005.asmx 之
我有一个基本的 ASMX 服务,我正在尝试运行它(我宁愿使用 WCF,但无法让服务器使用它)。它在没有安全设置的情况下运行良好,但是一旦我打开安全性,我就会得到: The HTTP request i
在设计 ASMX 网络服务时,对您可以使用的类型有某种限制(序列化/反序列化)。 谁能告诉我这些限制是什么?是否可以通过在代码中添加serializable属性来绕过? 最佳答案 没有。传统的 ASM
我已经使用 CheckVat 方法创建了 ASMX 网络服务。如果我从 https://my.domain.com/VatValidation.asmx 调用此方法,我会得到成功的 json 响应,如
我正在通过经典的 asmx 网络服务传输一个大的压缩文本文件。我这样做的原因是文件的大小是 20 MB 解压缩,4MB 压缩。 这是方法。如有必要,我会提供更多信息。 [WebMethod]
我需要在客户端页面中使用 JavaScript 调用我的 Web 服务方法。我认为我没有正确引用这一点,希望您能帮助解决这一问题。 错误消息显示“CalendarHandler 未定义”。
我正在使用 ASP.NET 和 asmx 服务来访问我的 SQL 数据库的数据。 该服务既称为客户端又称为后端。 该网站将供我们的内部员工和我们的客户使用。 asmx 服务中有一些方法,如果它们未通过
我在一台服务器 1 上编写了一个 asmx 服务,在另一台服务器 2 上编写了 asp.net/c#。 我要转一个dictionary从 srv1 到 srv2。我读到 Dictionary is n
所以我在 Visual Studio 2010 中创建了一个 Web 服务。为了将它部署到 IIS Web 服务器上,我将 service.asmx、web.config 和 bin 复制到服务器(w
我有以下 ASMX 网络服务: // removed for brevity // namespace AtomicService { [WebService(Namespace = "htt
我在我的应用程序中使用第三方支付网关。支付网关提供商为集成提供了测试 asmx HTTPS URL,它有一些方法。使用 HttpWebRequest 我集成到我的应用程序中。我正在发送 SOAPReq
我正在尝试将国家/地区 Web 服务添加到下拉列表中。我已经添加了 Web 引用并拥有 discomap 和 wsdl 文件。 这是我的代码隐藏: net.webservicex.www.countr
我有一个扩展名为 .asmx 的网络服务,它指向我的网络应用程序中的一个类。添加一些代码以在应用程序启动时输出调试日志后,我可以看到每次用户访问该页面时都会创建一个新的调试日志。 我希望我可以将此 W
我有一个 asmx 服务,这些方法返回具有原始数据类型属性的自定义类。当这些属性为 null 时,它们将被排除在服务返回的 xml 之外。我希望该服务仍返回 xml 中的属性,但没有值。有办法做到这一
我是一名优秀的程序员,十分优秀!