github-advanced-security[bot] commented on code in PR #3654:
URL: https://github.com/apache/cxf/pull/3654#discussion_r4439495322


##########
rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/SamlFormInHandler.java:
##########
@@ -58,9 +98,18 @@
             // containing the actual REQUEST URI client was using before being 
redirected
             // back to IDP - at the moment assume it's URI
             UriInfoImpl ui = new UriInfoImpl(message);
-            if (!samlRequestURI.startsWith(ui.getBaseUri().toString())) {
-                
context.abortWith(Response.status(302).location(URI.create(samlRequestURI)).build());
-                return;
+            URI baseUri = ui.getBaseUri();
+            if (!samlRequestURI.startsWith(baseUri.toString())) {
+                URI location = getRelayStateLocation(samlRequestURI, baseUri);
+                if (location != null) {
+                    
context.abortWith(Response.status(302).location(location).build());
+                    return;
+                }
+                if (LOG.isLoggable(Level.FINE)) {
+                    LOG.fine("Ignoring RelayState " + 
samlRequestURI.replaceAll("\\p{Cntrl}", "_")
+                        + ": it is not relative and its origin matches neither 
" + baseUri
+                        + " nor the allowed RelayState origins");

Review Comment:
   ## CodeQL / Insertion of sensitive information into log files
   
   This [potentially sensitive information](1) is written to a log file.
   This [potentially sensitive information](2) is written to a log file.
   
   [Show more 
details](https://github.com/apache/cxf/security/code-scanning/2257)



##########
rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/SamlFormInHandler.java:
##########
@@ -58,9 +98,18 @@
             // containing the actual REQUEST URI client was using before being 
redirected
             // back to IDP - at the moment assume it's URI
             UriInfoImpl ui = new UriInfoImpl(message);
-            if (!samlRequestURI.startsWith(ui.getBaseUri().toString())) {
-                
context.abortWith(Response.status(302).location(URI.create(samlRequestURI)).build());
-                return;
+            URI baseUri = ui.getBaseUri();
+            if (!samlRequestURI.startsWith(baseUri.toString())) {
+                URI location = getRelayStateLocation(samlRequestURI, baseUri);
+                if (location != null) {
+                    
context.abortWith(Response.status(302).location(location).build());
+                    return;
+                }
+                if (LOG.isLoggable(Level.FINE)) {
+                    LOG.fine("Ignoring RelayState " + 
samlRequestURI.replaceAll("\\p{Cntrl}", "_")
+                        + ": it is not relative and its origin matches neither 
" + baseUri
+                        + " nor the allowed RelayState origins");

Review Comment:
   ## CodeQL / Log Injection
   
   This log entry depends on a [user-provided value](1).
   This log entry depends on a [user-provided value](2).
   This log entry depends on a [user-provided value](3).
   
   [Show more 
details](https://github.com/apache/cxf/security/code-scanning/2258)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to