Issues (85)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/XML/SignableElementTrait.php (2 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\SAML2\Compat\ContainerSingleton;
10
use SimpleSAML\XML\DOMDocumentFactory;
11
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmInterface;
12
use SimpleSAML\XMLSecurity\Constants as C;
13
use SimpleSAML\XMLSecurity\Exception\RuntimeException;
14
use SimpleSAML\XMLSecurity\Exception\UnsupportedAlgorithmException;
15
use SimpleSAML\XMLSecurity\Utils\XML;
16
use SimpleSAML\XMLSecurity\XML\ds\CanonicalizationMethod;
17
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
18
use SimpleSAML\XMLSecurity\XML\ds\Signature;
19
use SimpleSAML\XMLSecurity\XML\ds\SignatureMethod;
20
use SimpleSAML\XMLSecurity\XML\ds\SignatureValue;
21
use SimpleSAML\XMLSecurity\XML\ds\SignedInfo;
22
use SimpleSAML\XMLSecurity\XML\ds\Transform;
23
use SimpleSAML\XMLSecurity\XML\ds\Transforms;
24
use SimpleSAML\XMLSecurity\XML\SignableElementTrait as BaseSignableElementTrait;
25
26
use function base64_encode;
27
28
/**
29
 * Helper trait for processing signable elements.
30
 *
31
 * @package simplesamlphp/saml2
32
 */
33
trait SignableElementTrait
34
{
35
    use BaseSignableElementTrait;
36
37
38
    /**
39
     * Sign the current element.
40
     *
41
     * The signature will not be applied until toXML() is called.
42
     *
43
     * @param \SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmInterface $signer The actual signer implementation
44
     * to use.
45
     * @param string $canonicalizationAlg The identifier of the canonicalization algorithm to use.
46
     * @param \SimpleSAML\XMLSecurity\XML\ds\KeyInfo|null $keyInfo A KeyInfo object to add to the signature.
47
     */
48
    public function sign(
49
        SignatureAlgorithmInterface $signer,
50
        string $canonicalizationAlg = C::C14N_EXCLUSIVE_WITHOUT_COMMENTS,
51
        ?KeyInfo $keyInfo = null,
52
    ): void {
53
        /**
54
         * 5.4.2: SAML assertions and protocol messages MUST supply a value for the ID attribute
55
         * on the root element of the assertion or protocol message being signed.
56
         */
57
        Assert::notNull($this->getID(), "Signable element must have an ID set before it can be signed.");
58
59
        $this->signer = $signer;
60
        $this->keyInfo = $keyInfo;
61
        Assert::oneOf(
62
            $canonicalizationAlg,
63
            [
64
                C::C14N_INCLUSIVE_WITH_COMMENTS,
65
                C::C14N_INCLUSIVE_WITHOUT_COMMENTS,
66
                C::C14N_EXCLUSIVE_WITH_COMMENTS,
67
                C::C14N_EXCLUSIVE_WITHOUT_COMMENTS,
68
            ],
69
            'Unsupported canonicalization algorithm: %s',
70
            UnsupportedAlgorithmException::class,
71
        );
72
        $this->c14nAlg = $canonicalizationAlg;
73
    }
74
75
76
    /**
77
     * Do the actual signing of the document.
78
     *
79
     * Note that this method does not insert the signature in the returned \DOMElement. The signature will be available
80
     * in $this->signature as a \SimpleSAML\XMLSecurity\XML\ds\Signature object, which can then be converted to XML
81
     * calling toXML() on it, passing the \DOMElement value returned here as a parameter. The resulting \DOMElement
82
     * can then be inserted in the position desired.
83
     *
84
     * E.g.:
85
     *     $xml = // our XML to sign
86
     *     $signedXML = $this->doSign($xml);
87
     *     $signedXML->appendChild($this->signature->toXML($signedXML));
88
     *
89
     * @param \DOMElement $xml The element to sign.
90
     * @return \DOMElement The signed element, without the signature attached to it just yet.
91
     */
92
    protected function doSign(DOMElement $xml): DOMElement
93
    {
94
        Assert::notNull(
95
            $this->signer,
96
            'Cannot call toSignedXML() without calling sign() first.',
97
            RuntimeException::class,
98
        );
99
100
        $algorithm = $this->signer->getAlgorithmId();
0 ignored issues
show
The method getAlgorithmId() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

100
        /** @scrutinizer ignore-call */ 
101
        $algorithm = $this->signer->getAlgorithmId();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
101
        $digest = $this->signer->getDigest();
102
103
        $transforms = new Transforms([
104
            /**
105
             * 5.4.1: SAML assertions and protocols MUST use enveloped signatures when
106
             * signing assertions and protocol messages
107
             */
108
            new Transform(C::XMLDSIG_ENVELOPED),
109
            new Transform($this->c14nAlg),
110
        ]);
111
112
        $canonicalDocument = XML::processTransforms($transforms, $xml);
113
114
        $signedInfo = new SignedInfo(
115
            new CanonicalizationMethod($this->c14nAlg),
116
            new SignatureMethod($algorithm),
117
            [$this->getReference($digest, $transforms, $xml, $canonicalDocument)],
118
        );
119
120
        $signingData = $signedInfo->canonicalize($this->c14nAlg);
121
        $signedData = base64_encode($this->signer->sign($signingData));
0 ignored issues
show
It seems like $this->signer->sign($signingData) can also be of type false; however, parameter $string of base64_encode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

121
        $signedData = base64_encode(/** @scrutinizer ignore-type */ $this->signer->sign($signingData));
Loading history...
122
123
        $this->signature = new Signature($signedInfo, new SignatureValue($signedData), $this->keyInfo);
124
        return DOMDocumentFactory::fromString($canonicalDocument)->documentElement;
125
    }
126
127
128
    public function getBlacklistedAlgorithms(): ?array
129
    {
130
        $container = ContainerSingleton::getInstance();
131
        return $container->getBlacklistedEncryptionAlgorithms();
132
    }
133
}
134