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

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\saml;
6
7
use DOMElement;
8
use SimpleSAML\Assert\AssertionFailedException;
9
use SimpleSAML\SAML2\Assert\Assert;
10
use SimpleSAML\SAML2\Constants as C;
11
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
12
use SimpleSAML\SAML2\Type\EntityIDValue;
13
use SimpleSAML\SAML2\Type\SAMLDateTimeValue;
14
use SimpleSAML\SAML2\Type\SAMLStringValue;
15
use SimpleSAML\SAML2\Utils;
16
use SimpleSAML\XMLSchema\Type\NCNameValue;
17
use SimpleSAML\XMLSchema\XML\AbstractAnyType;
18
use SimpleSAML\XMLSchema\XML\Constants\NS;
19
20
use function strval;
21
22
/**
23
 * Abstract class representing SAML 2 SubjectConfirmationData element.
24
 *
25
 * @package simplesamlphp/saml2
26
 */
27
abstract class AbstractSubjectConfirmationData extends AbstractAnyType
28
{
29
    public const string NS = C::NS_SAML;
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 29 at column 24
Loading history...
30
31
    public const string NS_PREFIX = 'saml';
32
33
    public const string SCHEMA = 'resources/schemas/saml-schema-assertion-2.0.xsd';
34
35
    /** The namespace-attribute for the xs:any element */
36
    public const string XS_ANY_ELT_NAMESPACE = NS::ANY;
37
38
    /** The namespace-attribute for the xs:anyAttribute element */
39
    public const string XS_ANY_ATTR_NAMESPACE = NS::OTHER;
40
41
    /**
42
     * The exclusions for the xs:anyAttribute element
43
     *
44
     * @var array<int, array<int, string>>
45
     */
46
    public const array XS_ANY_ATTR_EXCLUSIONS = [
47
        ['urn:oasis:names:tc:SAML:2.0:assertion', '*'],
48
        ['urn:oasis:names:tc:SAML:2.0:metadata', '*'],
49
        ['urn:oasis:names:tc:SAML:2.0:protocol', '*'],
50
    ];
51
52
53
    /**
54
     * Initialize (and parse) a SubjectConfirmationData element.
55
     *
56
     * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $notBefore
57
     * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $notOnOrAfter
58
     * @param \SimpleSAML\SAML2\Type\EntityIDValue|null $recipient
59
     * @param \SimpleSAML\XMLSchema\Type\NCNameValue|null $inResponseTo
60
     * @param \SimpleSAML\SAML2\Type\SAMLStringValue|null $address
61
     * @param \SimpleSAML\XML\SerializableElementInterface[] $children
62
     * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
63
     */
64
    public function __construct(
65
        protected ?SAMLDateTimeValue $notBefore = null,
66
        protected ?SAMLDateTimeValue $notOnOrAfter = null,
67
        protected ?EntityIDValue $recipient = null,
68
        protected ?NCNameValue $inResponseTo = null,
69
        protected ?SAMLStringValue $address = null,
70
        array $children = [],
71
        array $namespacedAttributes = [],
72
    ) {
73
        /** SAML 2.0 Core specifications paragraph 2.4.1.2 */
74
        if ($notBefore !== null && $notOnOrAfter !== null) {
75
            Assert::true(
76
                $notBefore->toDateTime() < $notOnOrAfter->toDateTime(),
77
                "The value for NotBefore MUST be less than (earlier than) the value for NotOnOrAfter.",
78
                ProtocolViolationException::class,
79
            );
80
        }
81
82
        if ($address !== null) {
83
            try {
84
                /**
85
                 * IPv4 addresses SHOULD be represented in the usual dotted-decimal format (e.g., "1.2.3.4").
86
                 * IPv6 addresses SHOULD be represented as defined by Section 2.2 of IETF RFC 3513 [RFC 3513]
87
                 * (e.g., "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210").
88
                 */
89
                Assert::ip($address->getValue());
90
            } catch (AssertionFailedException) {
91
                Utils::getContainer()->getLogger()->warning(
92
                    sprintf('Provided address (%s) is not a valid IPv4 or IPv6  address.', $address->getValue()),
93
                );
94
            }
95
        }
96
97
        $this->setElements($children);
98
        $this->setAttributesNS($namespacedAttributes);
99
    }
100
101
102
    /**
103
     * Collect the value of the NotBefore-property
104
     *
105
     * @return \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null
106
     */
107
    public function getNotBefore(): ?SAMLDateTimeValue
108
    {
109
        return $this->notBefore;
110
    }
111
112
113
    /**
114
     * Collect the value of the NotOnOrAfter-property
115
     *
116
     * @return \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null
117
     */
118
    public function getNotOnOrAfter(): ?SAMLDateTimeValue
119
    {
120
        return $this->notOnOrAfter;
121
    }
122
123
124
    /**
125
     * Collect the value of the Recipient-property
126
     *
127
     * @return \SimpleSAML\SAML2\Type\EntityIDValue|null
128
     */
129
    public function getRecipient(): ?EntityIDValue
130
    {
131
        return $this->recipient;
132
    }
133
134
135
    /**
136
     * Collect the value of the InResponseTo-property
137
     *
138
     * @return \SimpleSAML\XMLSchema\Type\NCNameValue|null
139
     */
140
    public function getInResponseTo(): ?NCNameValue
141
    {
142
        return $this->inResponseTo;
143
    }
144
145
146
    /**
147
     * Collect the value of the Address-property
148
     *
149
     * @return \SimpleSAML\SAML2\Type\SAMLStringValue|null
150
     */
151
    public function getAddress(): ?SAMLStringValue
152
    {
153
        return $this->address;
154
    }
155
156
157
    /**
158
     * Test if an object, at the state it's in, would produce an empty XML-element
159
     */
160
    public function isEmptyElement(): bool
161
    {
162
        return empty($this->getNotBefore())
163
            && empty($this->getNotOnOrAfter())
164
            && empty($this->getRecipient())
165
            && empty($this->getInResponseTo())
166
            && empty($this->getAddress())
167
            && empty($this->getElements())
168
            && empty($this->getAttributesNS());
169
    }
170
171
172
    /**
173
     * Convert this element to XML.
174
     */
175
    public function toXML(?DOMElement $parent = null): DOMElement
176
    {
177
        $e = $this->instantiateParentElement($parent);
178
179
        if ($this->getNotBefore() !== null) {
180
            $e->setAttribute('NotBefore', strval($this->getNotBefore()));
181
        }
182
        if ($this->getNotOnOrAfter() !== null) {
183
            $e->setAttribute('NotOnOrAfter', strval($this->getNotOnOrAfter()));
184
        }
185
        if ($this->getRecipient() !== null) {
186
            $e->setAttribute('Recipient', strval($this->getRecipient()));
187
        }
188
        if ($this->getInResponseTo() !== null) {
189
            $e->setAttribute('InResponseTo', strval($this->getInResponseTo()));
190
        }
191
        if ($this->getAddress() !== null) {
192
            $e->setAttribute('Address', strval($this->getAddress()));
193
        }
194
195
        foreach ($this->getAttributesNS() as $attr) {
196
            $attr->toXML($e);
197
        }
198
199
        foreach ($this->getElements() as $n) {
200
            $n->toXML($e);
201
        }
202
203
        return $e;
204
    }
205
}
206