@@ -433,6 +433,47 @@ public void testEntityExpansionWReq() throws Exception {
433433 webClient .close ();
434434 }
435435
436+ // Send an entity expansion attack for the wreq value
437+ @ org .junit .Test
438+ public void testEntityExpansionWReq2 () throws Exception {
439+ String url = "https://localhost:" + getIdpHttpsPort () + "/fediz-idp/federation?" ;
440+ url += "wa=wsignin1.0" ;
441+ url += "&whr=urn:org:apache:cxf:fediz:idp:realm-A" ;
442+ url += "&wtrealm=urn:org:apache:cxf:fediz:fedizhelloworld" ;
443+ String wreply = "https://localhost:" + getRpHttpsPort () + "/" + getServletContextName () + "/secure/fedservlet" ;
444+ url += "&wreply=" + wreply ;
445+
446+ InputStream is = this .getClass ().getClassLoader ().getResource ("entity_wreq2.xml" ).openStream ();
447+ String entity = IOUtils .toString (is , "UTF-8" );
448+ is .close ();
449+ String validWreq =
450+ "<RequestSecurityToken xmlns=\" http://docs.oasis-open.org/ws-sx/ws-trust/200512\" >"
451+ + "<TokenType>&m;http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0</TokenType>"
452+ + "</RequestSecurityToken>" ;
453+
454+ url += "&wreq=" + URLEncoder .encode (entity + validWreq , "UTF-8" );
455+
456+ String user = "alice" ;
457+ String password = "ecila" ;
458+
459+ final WebClient webClient = new WebClient ();
460+ webClient .getOptions ().setUseInsecureSSL (true );
461+ webClient .getCredentialsProvider ().setCredentials (
462+ new AuthScope ("localhost" , Integer .parseInt (getIdpHttpsPort ())),
463+ new UsernamePasswordCredentials (user , password ));
464+
465+ webClient .getOptions ().setJavaScriptEnabled (false );
466+
467+ try {
468+ webClient .getPage (url );
469+ Assert .fail ("Failure expected on a bad wreq value" );
470+ } catch (FailingHttpStatusCodeException ex ) {
471+ Assert .assertEquals (ex .getStatusCode (), 400 );
472+ }
473+
474+ webClient .close ();
475+ }
476+
436477 // Send an malformed wreq value
437478 @ org .junit .Test
438479 public void testMalformedWReq () throws Exception {
0 commit comments