Issues (538)

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/EncryptedElementTrait.php (2 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML;
6
7
use DOMElement;
8
use SimpleSAML\SAML2\Assert\Assert;
9
use SimpleSAML\SAML2\Compat\ContainerSingleton;
10
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
11
use SimpleSAML\XML\AbstractElement;
12
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
13
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
14
use SimpleSAML\XMLSecurity\Backend\EncryptionBackend;
15
use SimpleSAML\XMLSecurity\Constants as C;
0 ignored issues
show
The type SimpleSAML\XMLSecurity\Constants was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use SimpleSAML\XMLSecurity\XML\EncryptedElementTrait as ParentEncryptedElementTrait;
17
use SimpleSAML\XMLSecurity\XML\xenc\EncryptedData;
18
use SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey;
19
20
/**
21
 * Trait aggregating functionality for elements that are encrypted.
22
 *
23
 * @package simplesamlphp/saml2
24
 */
25
trait EncryptedElementTrait
26
{
27
    use ParentEncryptedElementTrait;
28
29
30
    /**
31
     * Constructor for encrypted elements.
32
     *
33
     * @param \SimpleSAML\XMLSecurity\XML\xenc\EncryptedData $encryptedData The EncryptedData object.
34
     * @param \SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey[] $decryptionKeys The EncryptedKey objects.
35
     */
36
    final public function __construct(
37
        protected EncryptedData $encryptedData,
38
        protected array $decryptionKeys = [],
39
    ) {
40
        Assert::allIsInstanceOf($decryptionKeys, EncryptedKey::class, ProtocolViolationException::class);
41
42
        /**
43
         * 6.2: The <EncryptedData> element's Type attribute SHOULD be used and, if it is
44
         * present, MUST have the value http://www.w3.org/2001/04/xmlenc#Element.
45
         */
46
        Assert::nullOrSame($encryptedData->getType()->getValue(), C::XMLENC_ELEMENT);
47
48
        $keyInfo = $this->encryptedData->getKeyInfo();
49
        if ($keyInfo === null) {
50
            return;
51
        }
52
53
        foreach ($keyInfo->getInfo() as $info) {
54
            if ($info instanceof EncryptedKey) {
55
                $this->encryptedKey = [$info];
56
                break;
57
            }
58
        }
59
    }
60
61
62
    /**
63
     * @return array|null
64
     */
65
    public function getBlacklistedAlgorithms(): ?array
66
    {
67
        $container = ContainerSingleton::getInstance();
68
        return $container->getBlacklistedEncryptionAlgorithms();
69
    }
70
71
72
    /**
73
     * @return \SimpleSAML\XMLSecurity\Backend\EncryptionBackend|null
74
     */
75
    public function getEncryptionBackend(): ?EncryptionBackend
76
    {
77
        // return the encryption backend you want to use,
78
        // or null if you are fine with the default
79
        return null;
80
    }
81
82
83
    public function getDecryptionKeys(): array
84
    {
85
        return $this->decryptionKeys;
86
    }
87
88
89
    /**
90
     * @inheritDoc
91
     *
92
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
93
     *   If the qualified name of the supplied element is wrong
94
     */
95
    public static function fromXML(DOMElement $xml): static
96
    {
97
        Assert::same(
98
            $xml->localName,
99
            AbstractElement::getClassName(static::class),
100
            InvalidDOMElementException::class,
101
        );
102
        Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
0 ignored issues
show
The constant SimpleSAML\SAML2\XML\EncryptedElementTrait::NS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
103
104
        $ed = EncryptedData::getChildrenOfClass($xml);
105
        Assert::count(
106
            $ed,
107
            1,
108
            sprintf(
109
                'No more or less than one EncryptedData element allowed in %s.',
110
                AbstractElement::getClassName(static::class),
111
            ),
112
            TooManyElementsException::class,
113
        );
114
115
        $ek = EncryptedKey::getChildrenOfClass($xml);
116
        return new static($ed[0], $ek);
117
    }
118
119
120
    /**
121
     * @inheritDoc
122
     */
123
    public function toXML(?DOMElement $parent = null): DOMElement
124
    {
125
        $e = $this->instantiateParentElement($parent);
126
127
        $this->encryptedData->toXML($e);
128
129
        foreach ($this->getDecryptionKeys() as $key) {
130
            $key->toXML($e);
131
        }
132
133
        return $e;
134
    }
135
}
136