Search
RSS Feed
Twitter
« Breaking Password Based Encryption with Azure | Main | Slides from AppSec DC Posted »
Thursday
Nov192009

WCF Binary Soap Plug-In for Burp

Update 2010:  With the official release of Burp Suite v1.3, both plug-ins discussed in this post can be used with either Pro or Free versions of Burp.

If you run into a Silverlight application that consumes WCF, there’s a good chance it will use Binary XML Message Encoding to send data between the Silverlight client and the WCF endpoint. These messages usually include a Content-Type: application/soap+msbin1 header to indicate that they are using Microsoft’s .NET Binary Format for SOAP (NBFS). From an attack perspective, the main problem with this encoding format is that you can’t simply edit requests or responses on-the-fly like you would with text-based SOAP messages, since the recipient of the message expects the data to be properly encoded (otherwise it will throw an exception) and, as such, will throw an exception if it’s not.

My initial research into what security tools support NBFS didn’t turn up much. The only option I found were two WCF Binary Inspectors for Fiddler (one here written by Richard Berg, and another here written by Samuel Jack). Both of these inspectors are essentially plug-ins for Fiddler that add support to view NBFS encoded data. Originally these both looked like the solution I was after, however upon further analysis I realized that while those plug-ins let you VIEW encoded messages, they don’t let you EDIT them. I decided it would be a worthwhile effort to try and leverage the plug-in architecture of Burp Suite (through use of the BurpExtender interface) to write a NBFS plug-in for Burp.

The Solution (sort of)

Not wanting to re-invent the wheel, I figured I would leverage the work that had already been done with Fiddler by calling into one of the existing Fiddler libraries from Burp. I chose to use Richard Berg’s code since it looks like it can be ported entirely to Java down the road if needed (it doesn’t rely on WCF’s built-in decoder). Luckily for me, his code also had all of the methods needed to both encode and decode message data.

The way the plug-in works is pretty simple…when a request comes in, the processProxyMessage method of BurpExtender is used to check whether the requests should be decoded and, if so, passes the request data to the C# library. The C# library decodes the message and returns the plain-text version back to Burp. As requests exit Burp, the processHttpMessage method of BurpExtender is used to determine whether the request needs to be re-encoded and, if so, calls into the C# library again.

There are a couple of interesting points to note here:

  • The processHttpMessage of BurpExtender is currently only supported in the Professional version of Burp Suite. It is my understanding that this method will be supported in the Free version starting with the next release (v1.3) but for now only licensed users of Burp pro have access to this extender method.
  • Both the processProxyMessage AND processHttpMessage methods of BurpExtender alway fire BEFORE a response can be edited by the user. Unfortunately this precludes the Plug-in from being able to re-encode RESPONSE messages should the user want to edit one.

What this means is that you’ll need to resort to the proxy chaining as a workaround for this if you use the Burp Free Edition (explained in more detail below). Additionally, even if you use Burp Professional Edition, you’ll need to use this workaround if you want to edit RESPONSE data (REQUEST data can be edited on the fly with a single instance of Burp Professional).

Plug-In Versions

There are two version of the Burp plug-in available:

Burp Professional Edition Plug-in: Allows binary requests to be edited on the fly. This version does not support editing of response data. Pro users can use the Free Edition Plug-in with Burp Professional for editing response data.

Burp Universal Plug-in: The Universal Plug-in works with both Free and Professional Editions of Burp and supports editing of binary REQUESTS and RESPONSES. The caveat to using this version of the plug-in is that you’ll need to chain two burp instances together as outlined in the diagram below for the plugin to work properly.

The purpose of chaining two proxies together is as follows:

  • The first instance handles decoding requests, intercepting (and editing) requests, and re-encoding edited responses. Set this instance to intercept REQUESTS only (not responses) and to use the 2nd proxy as the next hop.
  • The second instance handles re-encoding edited requests, decoding responses, and intercepting (and editing) responses. Set this instance to intercept RESPONSES only (not requests).

Each proxy will add or remove a custom header (X-WCF-Proxy: must-encode) to edited requests/responses which they use to notify each other of whether re-encoding of a message is necessary. This custom header is removed when read by the plug-in, so it shouldn’t ever get disclosed to the target system.

Albeit it slightly crude, I didn’t see much in the way of a better work around (I am certainly open to suggestions if anyone has any). It should be noted that this workaround is ONLY necessary if you are using the Free Edition (1.2.x) of Burp Suite OR if you want to want to edit WCF binary response content using Burp Professional Edition. Editing WCF binary request data is supported with a single instance of the Burp Professional Plug-In.

Next Steps

These plug-ins were created as a proof of concept for the talk at OWASP AppSec DC 2009. Looking forward, the C# decoding library should easily port to pure Java since it doesn’t make use of the native WCF decoding classes. This would not only eliminate cross-language calls but would also make the plug-in platform independent (since the implementation would be in pure Java). The drawback to this approach, of course, is that we would be using a home grown decoder for a proprietary Microsoft protocol that could change down the road.

In any case, hopefully the plug-ins will be useful in the short term until more security tools include native support for NBFS messages. You can find both versions of the plug-in available for free on our tools page.

Reader Comments (8)

Sweet work Brian, good to see you still doing cool stuff.

April 6, 2010 | Unregistered CommenterNathan McFeters
Brian,

Does this plugin decode the requests with Content-Type: application/msbin1 or it's only applicable for Content-Type: application/soap+msbin1.

Appreciate if you can clarify this.

..
PradM
March 7, 2012 | Unregistered CommenterPradeep
I am having the same issue as PradM. Is there a way to get this to work with msbin1?
May 9, 2012 | Unregistered CommenterAlex
PradM & Alex --

First, my apologies to PradM for the slow response. I saw your question a few months ago and was meaning to respond but completely forgot.

When I originally wrote the plug-in, I intended to eventually port the code to a pure Java implementation. As such, I chose to base it off Richard Berg's code since it did not require reflecting into any internal .NET classes or calling into any of the core .NET libraries. Unfortunately, in its current state the code only supports application/soap+msbin1 and would need to be updated to add support for other formats.

My guess is that if the NBFS.cs code was re-factored to call into the native .NET serialization libraries it could easily support application/msbin1, in addition to application/soap+msbin1 and whatever other native WCF message formats are used by the framework. Probably not the answer you were looking for, but hope it helps in any case.
May 9, 2012 | Unregistered CommenterBrian H.
Great work but there is a problem - command line string limit for nbfs.exe causes truncation for long WCF requests and makes processing impossible. Is it possible to modify decoder, so it can read base64 from std input? or could you provide sources?
October 30, 2012 | Unregistered CommenterJacekM
Please disregard my last comment - just saw src folder on github.
October 30, 2012 | Unregistered Commenterjacekm
There is a bug in java code - in function processWCFMessage one should encode part of message array, instead of converting it to String and than encoding - it may vary depending localization. After modification, plugin works like charm :-)
October 31, 2012 | Unregistered Commenterjacekm
Brian H: I am getting an error message in the "Edited Request" in burp that "the input source is not correctly formatted". I am using Burp pro plugin.

@jacekm: Will you please forward me the updated code or provide code in the comment.

Thanks
December 7, 2012 | Unregistered Commenternb

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
All HTML will be escaped. Hyperlinks will be created for URLs automatically.