[cpp-opensaml] branch main updated: XML handling improvements
Codeberg
noreply at shibboleth.net
Mon Nov 30 14:30:28 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository cpp-opensaml.
View the commit online:
https://codeberg.org/Shibboleth/cpp-opensaml/commit/ba8fb40945176567b50a01c77787f432ddb662cf
The following commit(s) were added to refs/heads/main by this push:
new ba8fb40 XML handling improvements
ba8fb40 is described below
commit ba8fb40945176567b50a01c77787f432ddb662cf
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Mon Nov 30 08:29:54 2026 -0500
XML handling improvements
---
saml/binding/impl/SimpleSigningRule.cpp | 12 ++++++++++++
saml/saml1/binding/impl/SAML1SOAPDecoder.cpp | 8 +++++++-
saml/saml2/binding/impl/SAML2ECPDecoder.cpp | 4 ++++
saml/saml2/binding/impl/SAML2SOAPDecoder.cpp | 6 ++++++
saml/signature/SignatureProfileValidator.cpp | 2 +-
5 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/saml/binding/impl/SimpleSigningRule.cpp b/saml/binding/impl/SimpleSigningRule.cpp
index 9c2122e..8cd7d5c 100644
--- a/saml/binding/impl/SimpleSigningRule.cpp
+++ b/saml/binding/impl/SimpleSigningRule.cpp
@@ -153,6 +153,18 @@ bool SimpleSigningRule::evaluate(const XMLObject& message, const GenericRequest*
return false;
}
+ const char* method = httpRequest->getMethod();
+ if (!strcmp(method, "POST")) {
+ if (httpRequest->getContentType().find("application/x-www-form-urlencoded") == string::npos) {
+ log.debug("ignoring message, POST without form-urlencoded content type");
+ return false;
+ }
+ }
+ else if (strcmp(method, "GET")) {
+ log.debug("ignoring message, unsupported HTTP method (%s)", method);
+ return false;
+ }
+
// Make sure Signature only shows up once.
vector<const char*> valueHolder;
request->getParameters("Signature", valueHolder);
diff --git a/saml/saml1/binding/impl/SAML1SOAPDecoder.cpp b/saml/saml1/binding/impl/SAML1SOAPDecoder.cpp
index 5525490..9dd17a0 100644
--- a/saml/saml1/binding/impl/SAML1SOAPDecoder.cpp
+++ b/saml/saml1/binding/impl/SAML1SOAPDecoder.cpp
@@ -33,6 +33,7 @@
#include <xmltooling/logging.h>
#include <xmltooling/XMLToolingConfig.h>
#include <xmltooling/io/GenericRequest.h>
+#include <xmltooling/io/HTTPRequest.h>
#include <xmltooling/soap/SOAP.h>
#include <xmltooling/util/NDC.h>
#include <xmltooling/util/ParserPool.h>
@@ -85,8 +86,13 @@ XMLObject* SAML1SOAPDecoder::decode(
Category& log = Category::getInstance(SAML_LOGCAT ".MessageDecoder.SAML1SOAP");
log.debug("validating input");
+ const HTTPRequest* httpRequest = dynamic_cast<const HTTPRequest*>(&genericRequest);
+ if (httpRequest && strcmp(httpRequest->getMethod(), "POST")) {
+ log.warn("ignoring non-POST request (%s)", httpRequest->getMethod());
+ throw BindingException("Invalid HTTP method ($1).", params(1, httpRequest->getMethod()));
+ }
string s = genericRequest.getContentType();
- if (s.find("text/xml") == string::npos) {
+ if (s.find("text/xml") == string::npos || s.find("application/x-www-form-urlencoded") != string::npos) {
log.warn("ignoring incorrect content type (%s)", s.c_str() ? s.c_str() : "none");
throw BindingException("Invalid content type for SOAP message.");
}
diff --git a/saml/saml2/binding/impl/SAML2ECPDecoder.cpp b/saml/saml2/binding/impl/SAML2ECPDecoder.cpp
index 3d1c180..b88142b 100644
--- a/saml/saml2/binding/impl/SAML2ECPDecoder.cpp
+++ b/saml/saml2/binding/impl/SAML2ECPDecoder.cpp
@@ -85,6 +85,10 @@ XMLObject* SAML2ECPDecoder::decode(
log.debug("validating input");
const HTTPRequest* httpRequest = dynamic_cast<const HTTPRequest*>(&genericRequest);
if (httpRequest) {
+ if (strcmp(httpRequest->getMethod(), "POST")) {
+ log.warn("ignoring non-POST request (%s)", httpRequest->getMethod());
+ throw BindingException("Invalid HTTP method ($1).", params(1, httpRequest->getMethod()));
+ }
string s = httpRequest->getContentType();
if (s.find("application/vnd.paos+xml") == string::npos ||
s.find("application/x-www-form-urlencoded") != string::npos) {
diff --git a/saml/saml2/binding/impl/SAML2SOAPDecoder.cpp b/saml/saml2/binding/impl/SAML2SOAPDecoder.cpp
index 62bffd5..241bff2 100644
--- a/saml/saml2/binding/impl/SAML2SOAPDecoder.cpp
+++ b/saml/saml2/binding/impl/SAML2SOAPDecoder.cpp
@@ -33,6 +33,7 @@
#include <xmltooling/logging.h>
#include <xmltooling/XMLToolingConfig.h>
#include <xmltooling/io/GenericRequest.h>
+#include <xmltooling/io/HTTPRequest.h>
#include <xmltooling/soap/SOAP.h>
#include <xmltooling/util/NDC.h>
#include <xmltooling/util/ParserPool.h>
@@ -85,6 +86,11 @@ XMLObject* SAML2SOAPDecoder::decode(
Category& log = Category::getInstance(SAML_LOGCAT ".MessageDecoder.SAML2SOAP");
log.debug("validating input");
+ const HTTPRequest* httpRequest = dynamic_cast<const HTTPRequest*>(&genericRequest);
+ if (httpRequest && strcmp(httpRequest->getMethod(), "POST")) {
+ log.warn("ignoring non-POST request (%s)", httpRequest->getMethod());
+ throw BindingException("Invalid HTTP method ($1).", params(1, httpRequest->getMethod()));
+ }
string s = genericRequest.getContentType();
if (s.find("text/xml") == string::npos || s.find("application/x-www-form-urlencoded") != string::npos) {
log.warn("ignoring incorrect content type (%s)", s.c_str() ? s.c_str() : "none");
diff --git a/saml/signature/SignatureProfileValidator.cpp b/saml/signature/SignatureProfileValidator.cpp
index 5bc0ebb..76d7728 100644
--- a/saml/signature/SignatureProfileValidator.cpp
+++ b/saml/signature/SignatureProfileValidator.cpp
@@ -87,7 +87,7 @@ void SignatureProfileValidator::validateSignature(const Signature& sigObj) const
const XMLCh* ID=signableObj->getXMLID();
if (URI==nullptr || *URI==0 || (*URI==chPound && ID && !XMLString::compareString(URI+1,ID))) {
const DSIGTransformList* tlist=ref->getTransforms();
- if (tlist->getSize() <= 2) {
+ if (tlist && tlist->getSize() <= 2) {
for (unsigned int i=0; tlist && i<tlist->getSize(); i++) {
const DSIGTransform* t = tlist->item(i);
if (dynamic_cast<const DSIGTransformEnvelope*>(t)) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list