You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2026/04/21 13:49:15 UTC
(ws-neethi) branch master updated (42867c2 -> 9069bcf)
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/ws-neethi.git
from 42867c2 Improving XML processing in tests
new 26f81a6 Don't follow redirects for policies
new 9069bcf Put a limit on the number of nested policies
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/neethi/AbstractPolicyOperator.java | 16 ++++++++++++++++
src/main/java/org/apache/neethi/PolicyReference.java | 2 ++
2 files changed, 18 insertions(+)
(ws-neethi) 02/02: Put a limit on the number of nested policies
Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ws-neethi.git
commit 9069bcf9d401fbcfff834f26248845f8d51da4b5
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Tue Apr 21 14:48:50 2026 +0100
Put a limit on the number of nested policies
---
.../java/org/apache/neethi/AbstractPolicyOperator.java | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/main/java/org/apache/neethi/AbstractPolicyOperator.java b/src/main/java/org/apache/neethi/AbstractPolicyOperator.java
index 015c8b2..bdac65a 100644
--- a/src/main/java/org/apache/neethi/AbstractPolicyOperator.java
+++ b/src/main/java/org/apache/neethi/AbstractPolicyOperator.java
@@ -33,6 +33,15 @@ import org.apache.neethi.util.PolicyComparator;
*/
public abstract class AbstractPolicyOperator implements PolicyOperator {
protected List<PolicyComponent> policyComponents = new ArrayList<PolicyComponent>();
+
+ /**
+ * Maximum number of normalised alternatives (All nodes inside the outermost
+ * ExactlyOne) that policy normalization is permitted to produce. Crafted
+ * WS-Policy documents can trigger an exponential Cartesian cross-product that
+ * exhausts the JVM heap; this cap converts that unbounded allocation into a
+ * fast, predictable RuntimeException.
+ */
+ private static final int MAX_ALTERNATIVES = 10_000;
public AbstractPolicyOperator() {
@@ -233,6 +242,13 @@ public abstract class AbstractPolicyOperator implements PolicyOperator {
crossProductAll.addPolicyComponents(currentAll1.getPolicyComponents());
crossProductAll.addPolicyComponents(currentAll2.getPolicyComponents());
crossProduct.addPolicyComponent(crossProductAll);
+
+ if (crossProduct.getPolicyComponents().size() > MAX_ALTERNATIVES) {
+ throw new RuntimeException(
+ "Policy normalization exceeded the maximum number of alternatives ("
+ + MAX_ALTERNATIVES + "). The policy may be crafted to cause "
+ + "Algorithmic Complexity DoS via exponential cross-product expansion.");
+ }
}
}
(ws-neethi) 01/02: Don't follow redirects for policies
Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ws-neethi.git
commit 26f81a6b860135d557fb161850fb6d47e247a52f
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Tue Apr 21 13:33:01 2026 +0100
Don't follow redirects for policies
---
src/main/java/org/apache/neethi/PolicyReference.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/main/java/org/apache/neethi/PolicyReference.java b/src/main/java/org/apache/neethi/PolicyReference.java
index 8477f50..80c113d 100644
--- a/src/main/java/org/apache/neethi/PolicyReference.java
+++ b/src/main/java/org/apache/neethi/PolicyReference.java
@@ -21,6 +21,7 @@ package org.apache.neethi;
import java.io.IOException;
import java.io.InputStream;
+import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
@@ -171,6 +172,7 @@ public class PolicyReference implements PolicyComponent {
connection.setDoInput(true);
connection.setConnectTimeout(5000);
connection.setReadTimeout(10000);
+ ((HttpURLConnection) connection).setInstanceFollowRedirects(false);
InputStream in = connection.getInputStream();
try {