You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2026/07/08 08:51:12 UTC

(cxf) branch 3.6.x-fixes updated (19d20f756fa -> 867804a2f73)

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a change to branch 3.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


    from 19d20f756fa Switch XML Security CryptoLoader to use URIResolver (#3280)
     new 05d70a96fc8 Plug URIResolver into AttachmentUtil (#3289)
     new 867804a2f73 Encode LDAP query parameter names as well (#3288)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/cxf/attachment/AttachmentUtil.java    |  7 ++++++-
 .../apache/cxf/attachment/AttachmentDeserializerTest.java | 12 ++++++++++++
 .../org/apache/cxf/aegis/type/mtom/AttachmentUtil.java    |  8 +++++---
 .../cxf/jaxrs/ext/search/ldap/LdapQueryVisitor.java       |  3 ++-
 .../cxf/jaxrs/ext/search/ldap/LdapQueryVisitorTest.java   | 15 +++++++++++++++
 5 files changed, 40 insertions(+), 5 deletions(-)


(cxf) 02/02: Encode LDAP query parameter names as well (#3288)

Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch 3.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 867804a2f73ba326fce7dfff83f38a894b6e079c
Author: Colm O hEigeartaigh <co...@users.noreply.github.com>
AuthorDate: Tue Jul 7 17:10:30 2026 +0100

    Encode LDAP query parameter names as well (#3288)
    
    (cherry picked from commit c2c5619b06586023cd212fbdf967a13c80b6036b)
---
 .../cxf/jaxrs/ext/search/ldap/LdapQueryVisitor.java       |  3 ++-
 .../cxf/jaxrs/ext/search/ldap/LdapQueryVisitorTest.java   | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/ldap/LdapQueryVisitor.java b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/ldap/LdapQueryVisitor.java
index 35dc2f49008..73742097edc 100644
--- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/ldap/LdapQueryVisitor.java
+++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/ldap/LdapQueryVisitor.java
@@ -60,8 +60,9 @@ public class LdapQueryVisitor<T> extends AbstractUntypedSearchConditionVisitor<T
                 }
 
                 String ldapOperator = conditionTypeToLdapOperator(sc.getConditionType());
+                String encodedName = encodeQueryValues ? Util.doRFC2254Encoding(name) : name;
                 String encodedRValStr = encodeQueryValues ? Util.doRFC2254Encoding(rvalStr) : rvalStr;
-                sb.append(name).append(ldapOperator).append(encodedRValStr);
+                sb.append(encodedName).append(ldapOperator).append(encodedRValStr);
 
                 sb.append(')');
             }
diff --git a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/ldap/LdapQueryVisitorTest.java b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/ldap/LdapQueryVisitorTest.java
index dc3481ffadd..2db56d7c7a7 100644
--- a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/ldap/LdapQueryVisitorTest.java
+++ b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/ldap/LdapQueryVisitorTest.java
@@ -20,8 +20,11 @@ package org.apache.cxf.jaxrs.ext.search.ldap;
 
 import java.util.Date;
 
+import org.apache.cxf.jaxrs.ext.search.ConditionType;
+import org.apache.cxf.jaxrs.ext.search.SearchBean;
 import org.apache.cxf.jaxrs.ext.search.SearchCondition;
 import org.apache.cxf.jaxrs.ext.search.SearchParseException;
+import org.apache.cxf.jaxrs.ext.search.SimpleSearchCondition;
 import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
 
 import org.junit.Ignore;
@@ -86,6 +89,18 @@ public class LdapQueryVisitorTest {
         assertEquals("(&(|(name=test)(level=18))(|(name=test1)(!level=19)))", ldap);
     }
 
+    @Test
+    public void testLdapFilterInjectionViaUnencodedPropertyName() throws SearchParseException {
+        SearchBean bean = new SearchBean();
+        bean.set("cn)(|(sn", "admin");
+
+        SearchCondition<SearchBean> filter =
+            new SimpleSearchCondition<>(ConditionType.EQUALS, bean);
+        LdapQueryVisitor<SearchBean> visitor = new LdapQueryVisitor<>();
+        filter.accept(visitor.visitor());
+
+        assertEquals("(cn\\29\\28|\\28sn=admin)", visitor.getQuery());
+    }
 
     @Ignore
     public static class Condition {


(cxf) 01/02: Plug URIResolver into AttachmentUtil (#3289)

Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch 3.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 05d70a96fc89285f7cacd9a336cb07d508a0176a
Author: Colm O hEigeartaigh <co...@users.noreply.github.com>
AuthorDate: Tue Jul 7 17:10:16 2026 +0100

    Plug URIResolver into AttachmentUtil (#3289)
    
    (cherry picked from commit 50918830ece560c374387230fbcd8791e26582b9)
---
 .../main/java/org/apache/cxf/attachment/AttachmentUtil.java  |  7 ++++++-
 .../apache/cxf/attachment/AttachmentDeserializerTest.java    | 12 ++++++++++++
 .../java/org/apache/cxf/aegis/type/mtom/AttachmentUtil.java  |  8 +++++---
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java b/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
index ff4bc10584c..499ba0fc777 100644
--- a/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
+++ b/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
@@ -64,6 +64,7 @@ import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
+import org.apache.cxf.resource.URIResolver;
 
 public final class AttachmentUtil {
     // The default values for {@link AttachmentDataSource} content type in case when
@@ -594,12 +595,16 @@ public final class AttachmentUtil {
                     final boolean followUrls = Boolean.valueOf(SystemPropertyAction
                         .getProperty(ATTACHMENT_XOP_FOLLOW_URLS_PROPERTY, "false"));
                     if (followUrls) {
-                        return new URLDataSource(new URL(contentId));
+                        final URL remoteUrl = new URL(contentId);
+                        URIResolver.checkAllowedScheme(remoteUrl);
+                        return new URLDataSource(remoteUrl);
                     } else {
                         return loadDataSource(contentId, atts);
                     }
                 } catch (MalformedURLException e) {
                     throw new Fault(e);
+                } catch (IOException e) {
+                    throw new Fault(e);
                 }
             }
         } else {
diff --git a/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java b/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
index 7f1c3c7d50c..0027569dcc5 100644
--- a/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
+++ b/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
@@ -43,6 +43,7 @@ import javax.xml.parsers.SAXParserFactory;
 import org.xml.sax.helpers.DefaultHandler;
 
 import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.io.CacheSizeExceededException;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.message.Exchange;
@@ -942,4 +943,15 @@ public class AttachmentDeserializerTest {
             System.clearProperty(AttachmentUtil.ATTACHMENT_XOP_FOLLOW_URLS_PROPERTY);
         }
     }
+
+    @Test
+    public void testCXF8706followUrlRejectsDisallowedScheme() {
+        System.setProperty(AttachmentUtil.ATTACHMENT_XOP_FOLLOW_URLS_PROPERTY, "true");
+        try {
+            assertThrows(Fault.class, () -> AttachmentUtil
+                .getAttachmentDataSource("cid:gopher://image.com/1.gif", Collections.emptyList()));
+        } finally {
+            System.clearProperty(AttachmentUtil.ATTACHMENT_XOP_FOLLOW_URLS_PROPERTY);
+        }
+    }
 }
diff --git a/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AttachmentUtil.java b/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AttachmentUtil.java
index 5474d573690..87e75adc0da 100644
--- a/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AttachmentUtil.java
+++ b/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AttachmentUtil.java
@@ -18,7 +18,6 @@
  */
 package org.apache.cxf.aegis.type.mtom;
 
-import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -33,6 +32,7 @@ import org.apache.cxf.aegis.util.UID;
 import org.apache.cxf.attachment.AttachmentImpl;
 import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.message.Attachment;
+import org.apache.cxf.resource.URIResolver;
 
 public final class AttachmentUtil {
     // The xop:include "href" attribute (https://www.w3.org/TR/xop10/#xop_href) may include 
@@ -79,9 +79,11 @@ public final class AttachmentUtil {
         if (followUrls) {
             // Try loading the URL remotely
             try {
-                URLDataSource source = new URLDataSource(new URL(id));
+                final URL remoteUrl = new URL(id);
+                URIResolver.checkAllowedScheme(remoteUrl);
+                URLDataSource source = new URLDataSource(remoteUrl);
                 return new AttachmentImpl(id, new DataHandler(source));
-            } catch (MalformedURLException e) {
+            } catch (java.io.IOException e) {
                 return null;
             }
         }