SOAP Web Services Attacks: Are Your Web Applications Vulnerable?
SOAP Web Services Attacks: Are Your Web Applications Vulnerable?
Table of Contents
Introduction 1
Background 1
Limitations 1
Prevention 23
Incoming Data Validation 24
Outgoing Data Validation 24
Appendix A: References 25
Contact Information 28
Introduction
The World Wide Web is being used increasingly for application-to-application
communication, thanks to programmatic interfaces known as web services.
In conjunction with current technology, web services are ideal for companies
clamoring to join the e-commerce revolution.
Background
Simple Object Access Protocol (SOAP) was defined jointly by Microsoft and
DevelopMentor, and has become a World Wide Web Consortium (W3C)
recommendation. The purpose of SOAP is to allow various components to
communicate using remote functionality as if they were local. SOAP
messages consist of XML-formatted data and are described in Understanding
SOAP Communication (below).
Limitations
This white paper discusses various types of attacks based on the SOAP
implementation of Web services over HTTP and describes how you can shield
your applications from these assaults. Other types of attacks are possible and
detailed descriptions of those will be available in upcoming white papers. This
paper is not intended to fully describe SOAP, but rather to present a brief
overview of key web services concepts. For in-depth information about web
services, visit the links cited in Appendix A: References and Appendix B:
Further Reading.
Request Envelope
The Request envelope contains the information required to process the
remote call. Each request message contains a message header and a
message body. The header stores processing information such as message
routing, requirements information, and security information. The body of the
message stores the information required to process the call. The payload
contains the following items:
Figure 1 shows a simple request envelope for the BabelFish web service
defined at http://www.xmethods.net/sd/2001/BabelFishService.wsdl (see
Anatomy of a SOAP Web Service for instructions on reading WSDL
definitions). The request specifies the translation mode to be English to
French (as defined by the en_fr value) and asks the service to translate the
word “hi” to its French equivalent. The request does not specify any special
server handling, so it has no data in the Header field.
Response Envelope
The response envelope is used to return data regarding a previous request
message sent to the server. The information in a successful request contains
the following elements the method called, the return value type, and the
return data
To make things a bit more clear, Figures 3 and 4 illustrate the server’s
response to the request depicted in Figures 1 and 2.
When an error occurs on the server side, the SOAP service returns an
envelope type of Fault, which may contain more specific information about the
error. Figures 5 and 6 illustrate a Fault message returned by the BabelFish
web service when it receives a request with no data in any of the required
parameters.
As we can see, the service gives us a quick description of what went wrong.
We will see later how we could benefit from services that could generate too
much information.
By obtaining a copy of the WSDL definition file for a specific web service, we
are now able to get a clear view of how we can interact with the web service
Test Application
The test application is a simple SOAP service written in C# and running under
Microsoft Information Server 5.0 with ASP.NET support. The test web service
simulates a simple product inventory system with provider information and
discount given by the provider. The service exposes the following methods to
the users:
GetProducts
GetProductInformationByID
GetProductInformationByName
GetProviderInfo
For a complete WSDL definition of the web service, refer to Appendix C: Test
application WSDL. By reviewing the WSDL, we see that a user ID and
password parameter is required for every call. For our testing, the user ID is
551-457-4487 and the password is 123456.
Parameter Tampering
SQL injection and cross-site scripting are two types of attacks that use
parameter tampering. Refer to Appendix B: Further Reading for more
information about these types of attacks.
Web services, however, require somewhat less rigor because the web service
methods specify the data type for each of their arguments. For example, if
an attacker tries to perform SQL injection on a web services method that
expects an integer as an argument, adding a single quotation mark will cause
the SOAP implementation to return a client error and the data will not reach
the actual method called.
Now that we have more information about the server and parameters, let’s
send to the GetProductInformationByName method a few characters that are
known to be in most input validation code and see how the server responds.
This is a good method to use for initial testing because its name argument is a
string, which is more susceptible to parameter injection. Figures 9 through
11 demonstrate how the server reacts to some of the characters.
It is clear that the methods do not perform even the simplest input validation
on the productName argument. We can also confirm, by looking at the faultstring
returned by the server, that the information accessed by the web service is
stored in a backend database.
A closer look at the faultstring reveals more information about some of the
internal processing the web service performs and where the problem occurs.
Let’s review the faultstring the server returned.
In this test scenario, the faultstring we receive from the server tells us
exactly how the application uses the uid and password to validate our
credentials. It passes the authentication data to the
ProductInfo.ProductDBAccess.VerifyAuthentication(String uid, String password) method. It
does not perform sanity checking on the data because the single quotation
mark we appended to the uid parameter was directly used in the SQL query
and generated a syntax error. The faultstring also gives us most of the query
used for validating credentials by returning userid = ‘551-457-4487’’ and password =
‘1123456’ in the syntax error. From the query portion returned by the server,
we can quickly generate a valid SQL injection to bypass the password
verification. We simply force a true condition after the password value.
The newly formatted SQL should internally look like select something from
sometable where userid = ‘551-457-4487’ and password = somevalue or true. The injection
value for our test will be ' or 1=1 or password = ' ; this should force the web
service to generate a query that will look like select something from sometable where
userid = ‘551-457-4487’ and password = ‘’ or 1=1 or password = ‘’.
The same injection worked fine. We received our user information, including
our password and the discount we give to the company. What could be
interesting is to get the same information from another uid, either one we
might know already or one we could acquire through brute force by forcing a
LIKE statement on the uid. For the sake of brevity, let’s say we have prior
knowledge that there is a uid 787-457-1154. Now our injection would look
something like select something from sometable where uid = ‘’or ‘’ = ‘’ and password = ‘’ or
uid =’787-457-1154’. To force that SQL query format, we will inject ' or ''=' in the
uid parameter and ' or providerid = '787-457-1154 in the password parameter.
Prevention
Protecting web services requires the collaboration of developers, system
administrators, and management. Though effective at reducing the risk of
such an attack, the approaches discussed in the next section are not
complete solutions. It is best to remember that web application security must
be a continually evolving process. As hackers change their methodologies,
so must those who want to implement a secure Web application.
Appendix A: References
For more information on web services, refer to these additional resources.
http://www.w3.org/TR/SOAP/
http://www.w3.org/TR/wsdl
SPI Dynamics uses direct research from SPI Labs to provide daily updates to
WebInspect, the leading Web application security assessment software. SPI
Labs engineers comply with the standards proposed by the Internet
Engineering Task Force (IETF) for responsible security vulnerability
disclosure. SPI Labs policies and procedures for disclosure are outlined on the
SPI Dynamics web site at: http://www.spidynamics.com/spilabs.html.
exclusively on web application security. SPI Labs, the internal research group
of SPI Dynamics, is recognized as the industry’s foremost authority in this
area.
Macromedia ColdFusion
Lotus Domino
Macromedia JRun
BEA Weblogic
Jakarta Tomcat
Contact Information