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/saml/NameID.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\saml;
6
7
use SimpleSAML\Assert\Assert;
8
use SimpleSAML\SAML2\Constants as C;
9
use SimpleSAML\SAML2\Exception\ArrayValidationException;
10
use SimpleSAML\SAML2\XML\EncryptableElementTrait;
11
use SimpleSAML\XML\SchemaValidatableElementInterface;
12
use SimpleSAML\XML\SchemaValidatableElementTrait;
13
use SimpleSAML\XMLSecurity\Backend\EncryptionBackend;
14
use SimpleSAML\XMLSecurity\XML\EncryptableElementInterface;
15
16
use function array_change_key_case;
17
use function array_filter;
18
use function array_key_exists;
19
use function array_keys;
20
21
/**
22
 * Class representing the saml:NameID element.
23
 *
24
 * @package simplesamlphp/saml2
25
 */
26
final class NameID extends NameIDType implements
27
    EncryptableElementInterface,
28
    SchemaValidatableElementInterface
29
{
30
    use EncryptableElementTrait;
0 ignored issues
show
The trait SimpleSAML\SAML2\XML\EncryptableElementTrait requires the property $ownerDocument which is not provided by SimpleSAML\SAML2\XML\saml\NameID.
Loading history...
31
    use SchemaValidatableElementTrait;
32
33
    /**
34
     * Initialize a saml:NameID
35
     *
36
     * @param string $value
37
     * @param string|null $NameQualifier
38
     * @param string|null $SPNameQualifier
39
     * @param string|null $Format
40
     * @param string|null $SPProvidedID
41
     */
42
    public function __construct(
43
        string $value,
44
        ?string $NameQualifier = null,
45
        ?string $SPNameQualifier = null,
46
        ?string $Format = null,
47
        ?string $SPProvidedID = null,
48
    ) {
49
        switch ($Format) {
50
            case C::NAMEID_EMAIL_ADDRESS:
51
                Assert::email(
52
                    $value,
53
                    "The content %s of the NameID was not in the format specified by the Format attribute",
54
                );
55
                break;
56
            case C::NAMEID_ENTITY:
57
                /* 8.3.6: he NameQualifier, SPNameQualifier, and SPProvidedID attributes MUST be omitted. */
58
                Assert::null($NameQualifier, "Entity Identifier included a disallowed NameQualifier attribute.");
59
                Assert::null($SPNameQualifier, "Entity Identifier included a disallowed SPNameQualifier attribute.");
60
                Assert::null($SPProvidedID, "Entity Identifier included a disallowed SPProvidedID attribute.");
61
                break;
62
            case C::NAMEID_PERSISTENT:
63
                /* 8.3.7: Persistent name identifier values MUST NOT exceed a length of 256 characters. */
64
                Assert::maxLength(
65
                    $value,
66
                    256,
67
                    "Persistent name identifier values MUST NOT exceed a length of 256 characters.",
68
                );
69
                break;
70
            case C::NAMEID_TRANSIENT:
71
                /* 8.3.8: Transient name identifier values MUST NOT exceed a length of 256 characters. */
72
                Assert::maxLength(
73
                    $value,
74
                    256,
75
                    "Transient name identifier values MUST NOT exceed a length of 256 characters.",
76
                );
77
                break;
78
        }
79
80
        parent::__construct($value, $NameQualifier, $SPNameQualifier, $Format, $SPProvidedID);
81
    }
82
83
84
    public function getEncryptionBackend(): ?EncryptionBackend
85
    {
86
        // return the encryption backend you want to use,
87
        // or null if you are fine with the default
88
        return null;
89
    }
90
91
92
    /**
93
     * Create a class from an array
94
     *
95
     * @param array $data
96
     * @return static
97
     */
98
    public static function fromArray(array $data): static
99
    {
100
        $data = self::processArrayContents($data);
101
102
        return new static(
103
            $data['value'],
104
            $data['NameQualifier'] ?? null,
105
            $data['SPNameQualifier'] ?? null,
106
            $data['Format'] ?? null,
107
            $data['SPProvidedID'] ?? null,
108
        );
109
    }
110
111
112
    /**
113
     * Validates an array representation of this object and returns the same array with
114
     * rationalized keys (casing) and parsed sub-elements.
115
     *
116
     * @param array $data
117
     * @return array $data
118
     */
119
    private static function processArrayContents(array $data): array
120
    {
121
        $data = array_change_key_case($data, CASE_LOWER);
122
123
        // Make sure the array keys are known for this kind of object
124
        Assert::allOneOf(
125
            array_keys($data),
126
            [
127
                'value',
128
                'format',
129
                'namequalifier',
130
                'spnamequalifier',
131
                'spprovidedid',
132
            ],
133
            ArrayValidationException::class,
134
        );
135
136
        Assert::keyExists($data, 'value', ArrayValidationException::class);
137
        Assert::string($data['value'], ArrayValidationException::class);
138
        $retval = ['value' => $data['value']];
139
140
        if (array_key_exists('format', $data)) {
141
            Assert::string($data['format'], ArrayValidationException::class);
142
            $retval['Format'] = $data['format'];
143
        }
144
145
        if (array_key_exists('namequalifier', $data)) {
146
            Assert::string($data['namequalifier'], ArrayValidationException::class);
147
            $retval['NameQualifier'] = $data['namequalifier'];
148
        }
149
150
        if (array_key_exists('spnamequalifier', $data)) {
151
            Assert::string($data['spnamequalifier'], ArrayValidationException::class);
152
            $retval['SPNameQualifier'] = $data['spnamequalifier'];
153
        }
154
155
        if (array_key_exists('spprovidedid', $data)) {
156
            Assert::string($data['spprovidedid'], ArrayValidationException::class);
157
            $retval['SPProvidedID'] = $data['spprovidedid'];
158
        }
159
160
        return $retval;
161
    }
162
163
164
    /**
165
     * Create an array from this class
166
     *
167
     * @return array
168
     */
169
    public function toArray(): array
170
    {
171
        $data = [
172
            'value' => $this->getContent(),
173
            'Format' => $this->getFormat(),
174
            'NameQualifier' => $this->getNameQualifier(),
175
            'SPNameQualifier' => $this->getSPNameQualifier(),
176
            'SPProvidedID' => $this->getSPProvidedID(),
177
        ];
178
179
        return array_filter($data);
180
    }
181
}
182