SOAP messages towards a SOAP service should include both the operation and the related parameters. This operation resides in the first child element of the SOAP message’s body. If HTTP is the transport of choice, it is allowed to use an additional HTTP header called SOAPAction, which contains the operation’s name. The receiving web service can identify the operation within the SOAP body through this header without parsing any XML.
If a web service considers only the SOAPAction attribute when determining the operation to execute, then it may be vulnerable to SOAPAction spoofing.
Exploitation
Suppose we are assessing a SOAP web service, whose WSDL file resides in http://<TARGET IP>:3002/wsdl?wsdl.
The first thing to pay attention is the SOAPAction operation called ExecuteCommand:
Let us take a look at the parameters.
What is interesting is that there is a cmd parameter.
Let us build a Python script to issue requests (save it as client.py). Note that the below script will try to have the SOAP service execute a whoami command.
The Python script can be executed, as follows.
We get an error mentioning This function is only allowed in internal networks. But we don’t have access to the internal network.
This is way SOAPAction Spoofing attack comes to place.
Let us build a new Python script for our SOAPAction spoofing attack (save it as client_soapaction_spoofing.py).
We specify LoginRequest in <soap:Body>, so that our request goes through. This operation is allowed from the outside.
We specify the parameters of ExecuteCommand because we want to have the SOAP service execute a whoami command.
We specify the blocked operation (ExecuteCommand) in the SOAPAction header
If the web service determines the operation to be executed based solely on the SOAPAction header, we may bypass the restrictions and have the SOAP service execute a whoami command.
Let us execute the new script.
Above successfully executed whoami command.
If you want to be able to specify multiple commands and see the result each time, use the following Python script (save it as automate.py).