I have a problem with the web services in Java. I created this web service:
1. Web service interface
Code:
@ WebService (name = "MyWebService")
@ SOAPBinding (style = Style.RPC)
public interface MyWebService {
@ WebMethod
public String doLogin (@ WebParam (name = "lastname") String lastname,
@ WebParam (name = "firstname") String firstname,
@ WebParam (name = "password") String password);
// ... other methods ...
}
2. Enpoint web service
Code:
@ Stateless
@ WebService (
endpointInterface = "webservice.MyWebService"
portName = "MyWebServicePort"
serviceName = "MyWebService")
public class MyWebServiceEndpoint implements MyWebService {
public String doLogin(String lastname, String firstname, String password) {
createLogin (lastname, firstname, password);
}
// ... implementation of other methods ...
}
I then deployed my EAR application on Sun Java Application Server, the deployment works correctly and use SoapUI methods to test my web service, everything is working properly, where is my problem is that I can do an XML injection (injection or Tag) with my soap request.
If I take the example below, you can see my soap request that is sent to my server from SoapUI.
Code:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="web:">
<soapenv:Header>
</soapenv: Header>
<soapenv:Body>
<web1:doLogin xmlns:web1="http://webservice.example.com/">
<firstname> John </firstname>
<lastname> Brown </lastname>
<password> john_pass33 </password>
<lastname> Kennedy </lastname>
</web1: doLogin>
</soapenv: Body>
</soapenv: Envelope>
As you can see I managed to inject 2 tags <lastname> my server accepts this and takes into account the 2nd tag, ie in this example the name "Kennedy" will be used and not name "Brown".
I tried to use XML schema but nothing changes I can always send a query with 2 tags with the same name and is always the last tag is taken into account by the server.
I would like to know if someone could help me by telling me how he can not have this kind of problem, ie it is possible to create a soap request with the same 2 name as parameter or ignore the 2nd tag, etc?
Bookmarks