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/10/14 15:30:00 UTC

(ws-wss4j) branch master updated: Some remaining codeql fixes (#755)

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-wss4j.git


The following commit(s) were added to refs/heads/master by this push:
     new 8c73e3c59 Some remaining codeql fixes (#755)
8c73e3c59 is described below

commit 8c73e3c596d7f4558378cdae0955731581356e99
Author: Colm O hEigeartaigh <co...@users.noreply.github.com>
AuthorDate: Wed Oct 14 16:29:54 2026 +0100

    Some remaining codeql fixes (#755)
---
 .../java/org/apache/wss4j/common/token/SecurityTokenReference.java   | 3 +++
 .../main/java/org/apache/wss4j/dom/processor/SignatureProcessor.java | 5 +++++
 .../src/test/java/org/apache/wss4j/dom/message/AttachmentTest.java   | 2 +-
 .../src/test/java/org/apache/wss4j/stax/test/AttachmentTest.java     | 2 +-
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ws-security-common/src/main/java/org/apache/wss4j/common/token/SecurityTokenReference.java b/ws-security-common/src/main/java/org/apache/wss4j/common/token/SecurityTokenReference.java
index 5eba043be..033ba47ef 100644
--- a/ws-security-common/src/main/java/org/apache/wss4j/common/token/SecurityTokenReference.java
+++ b/ws-security-common/src/main/java/org/apache/wss4j/common/token/SecurityTokenReference.java
@@ -569,6 +569,9 @@ public class SecurityTokenReference {
         if (result != 1) {
             bspEnforcer.handleBSPRule(BSPRule.R3061);
         }
+        if (child == null) {
+            throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY);
+        }
         if ("KeyIdentifier".equals(child.getLocalName())
             && WSS4JConstants.WSSE_NS.equals(child.getNamespaceURI())) {
 
diff --git a/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SignatureProcessor.java b/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SignatureProcessor.java
index fe4ae3370..d038c3069 100644
--- a/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SignatureProcessor.java
+++ b/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SignatureProcessor.java
@@ -169,6 +169,11 @@ public class SignatureProcessor implements Processor {
             if (result != 1) {
                 data.getBSPEnforcer().handleBSPRule(BSPRule.R5402);
             }
+            if (child == null) {
+                throw new WSSecurityException(
+                    WSSecurityException.ErrorCode.INVALID_SECURITY, "unsupportedKeyInfo"
+                );
+            }
 
             if (!(SecurityTokenReference.SECURITY_TOKEN_REFERENCE.equals(child.getLocalName())
                 && WSConstants.WSSE_NS.equals(child.getNamespaceURI()))) {
diff --git a/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/AttachmentTest.java b/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/AttachmentTest.java
index 5e4a1fba4..6538591d1 100644
--- a/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/AttachmentTest.java
+++ b/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/AttachmentTest.java
@@ -882,7 +882,7 @@ public class AttachmentTest {
                 break;
             }
         }
-        assertFalse(attachmentEncData == null);
+        assertNotNull(attachmentEncData);
         attachmentEncData.setAttributeNS(null, "MimeType", "application/malicious");
         encryptedAttachments.get(0).getHeaders().put("X-Attacker-Controlled", "forged");
 
diff --git a/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/AttachmentTest.java b/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/AttachmentTest.java
index 677c80988..889a9ae47 100644
--- a/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/AttachmentTest.java
+++ b/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/AttachmentTest.java
@@ -913,7 +913,7 @@ public class AttachmentTest extends AbstractTestBase {
                 break;
             }
         }
-        assertFalse(attachmentEncData == null);
+        assertNotNull(attachmentEncData);
         attachmentEncData.setAttributeNS(null, "MimeType", "application/malicious");
         encryptedAttachments.get(0).getHeaders().put("X-Attacker-Controlled", "forged");