Reducing Information Disclosure in WCF Data Services

本文介绍了如何通过配置来增强WCFDataService的安全性,包括错误处理、禁止敏感信息泄露、移除WSDL及帮助页面等内容,并提供了禁用元数据交换(MEX)的方法。

Previously, I wrote an article titled "Reducing Information Disclosure in ASP.NET Web Services". The article identified steps developers can take to eliminate detailed error messages, stack traces, web service description pages, and WSDLs from their production applications.This article will offer similar recommendations for WCF Data Services. Since this article builds of the previous one, I will not repeat the background information.

Reference WCF Service
We will use the following WCF service as a starting point.


Here is a successful SOAP request.


The WCF Help Page and WSDL are accessible as shown below.


The following two errors occur when parameters are omitted in the web service call or when we try to divide by zero.


ASP.NET Custom Errors: No Help At All
Unlike ASP.NET web services, exception handling in WCF data services is not the least bit affected by enabling custom errors. When custom errors are enabled, full stack traces, local file paths, and other information is returned to the consumer.

Explicit Try/Catch Blocks: 100% Effective, But What If You Miss One
Try/Catch blocks are just as effective as in ASP.NET Web Services. Here's the code.


And the result.


As stated in the ASP.NET Web Services article, there is always a chance that we could miss a try/catch block. We need some sort of backup solution to catch any exceptions that we miss.

includeExceptionDetailInFaults="false": A Great Backup to Try/Catch Blocks
In WCF Data Services, this functionality seems more complete and it is just as easy to implement as in the last article. Simply set the "includeExceptionDetailInFaults" attribute to "false" in the "serviceDebug" XML element of the Web.config file.


Stack traces and other detailed error information are now suppressed.


Removing the WSDL and WCF Help Pages
Help pages and the WSDL can easily be removed for WCF services. The "serviceMetadata" and "serviceDebug" XML elements in the Web.config file have attributes to specifically control these items.


When the appropriate attributes are set to "false", the help page and the WSDL show up as blank pages.


Once this change has been made, it will be necessary to communicate WSDLs or web service signatures with partners through some other channel.

WCF Metadata Exchange (MEX)
There is one additional issue to address with WCF Data Services, and that is to disable the Metadata Exchange (MEX) endpoint. Clients and attackers can query MEX endpoints to learn about web service signatures and configuration. For more information about MEX, see the following articles:

An example HTTP request and response used to query a MEX endpoint is shown below.


Additionally, an attacker can utilize the WCF Test Client to capture this data and query the service.



This behavior can be disabled by removing the MEX end-point. In the Web.Config file below, the end-point is commented out.


After the configuration change, the MEX endpoint is no longer accessible.

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值