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/samlp/AuthnQuery.php (5 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\samlp;
6
7
use DOMElement;
8
use SimpleSAML\SAML2\Assert\Assert;
9
use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooHighException;
0 ignored issues
show
The type SimpleSAML\SAML2\Excepti...VersionTooHighException 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...
10
use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooLowException;
0 ignored issues
show
The type SimpleSAML\SAML2\Excepti...tVersionTooLowException 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...
11
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
12
use SimpleSAML\SAML2\Type\SAMLDateTimeValue;
0 ignored issues
show
The type SimpleSAML\SAML2\Type\SAMLDateTimeValue 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...
13
use SimpleSAML\SAML2\Type\SAMLStringValue;
14
use SimpleSAML\SAML2\XML\saml\Issuer;
15
use SimpleSAML\SAML2\XML\saml\Subject;
16
use SimpleSAML\SAML2\XML\samlp\RequestedAuthnContext;
17
use SimpleSAML\XML\SchemaValidatableElementInterface;
18
use SimpleSAML\XML\SchemaValidatableElementTrait;
19
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
20
use SimpleSAML\XMLSchema\Exception\MissingElementException;
21
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
22
use SimpleSAML\XMLSchema\Type\IDValue;
0 ignored issues
show
The type SimpleSAML\XMLSchema\Type\IDValue 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...
23
use SimpleSAML\XMLSecurity\XML\ds\Signature;
24
25
use function array_pop;
26
use function version_compare;
27
28
/**
29
 * Class for SAML 2 AuthnQuery query messages.
30
 *
31
 * @package simplesamlphp/saml2
32
 */
33
final class AuthnQuery extends AbstractSubjectQuery implements SchemaValidatableElementInterface
34
{
35
    use SchemaValidatableElementTrait;
36
37
38
    /**
39
     * Constructor for SAML 2 AuthnQuery.
40
     *
41
     * @param \SimpleSAML\XMLSchema\Type\IDValue $id
42
     * @param \SimpleSAML\SAML2\XML\saml\Subject $subject
43
     * @param \SimpleSAML\SAML2\XML\samlp\RequestedAuthnContext|null $requestedAuthnContext
44
     * @param \SimpleSAML\SAML2\Type\SAMLStringValue|null $sessionIndex
45
     * @param \SimpleSAML\SAML2\XML\saml\Issuer $issuer
46
     * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue $issueInstant
47
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $destination
48
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $consent
49
     * @param \SimpleSAML\SAML2\XML\samlp\Extensions $extensions
50
     */
51
    public function __construct(
52
        IDValue $id,
53
        Subject $subject,
54
        SAMLDateTimeValue $issueInstant,
55
        protected ?RequestedAuthnContext $requestedAuthnContext = null,
56
        protected ?SAMLStringValue $sessionIndex = null,
57
        ?Issuer $issuer = null,
58
        ?SAMLAnyURIValue $destination = null,
59
        ?SAMLAnyURIValue $consent = null,
60
        ?Extensions $extensions = null,
0 ignored issues
show
The type SimpleSAML\SAML2\XML\samlp\Extensions 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...
61
    ) {
62
        parent::__construct($id, $subject, $issuer, $issueInstant, $destination, $consent, $extensions);
63
    }
64
65
66
    /**
67
     * Retrieve RequestedAuthnContext.
68
     *
69
     * @return \SimpleSAML\SAML2\XML\samlp\RequestedAuthnContext|null
70
     */
71
    public function getRequestedAuthnContext(): ?RequestedAuthnContext
72
    {
73
        return $this->requestedAuthnContext;
74
    }
75
76
77
    /**
78
     * Retrieve session index.
79
     *
80
     * @return \SimpleSAML\SAML2\Type\SAMLStringValue|null
81
     */
82
    public function getSessionIndex(): ?SAMLStringValue
83
    {
84
        return $this->sessionIndex;
85
    }
86
87
88
    /**
89
     * Create a class from XML
90
     *
91
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
92
     *   if the qualified name of the supplied element is wrong
93
     * @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException
94
     *   if the supplied element is missing one of the mandatory attributes
95
     * @throws \SimpleSAML\XMLSchema\Exception\MissingElementException
96
     *   if one of the mandatory child-elements is missing
97
     * @throws \SimpleSAML\XMLSchema\Exception\TooManyElementsException
98
     *   if too many child-elements of a type are specified
99
     */
100
    public static function fromXML(DOMElement $xml): static
101
    {
102
        Assert::same($xml->localName, 'AuthnQuery', InvalidDOMElementException::class);
103
        Assert::same($xml->namespaceURI, AuthnQuery::NS, InvalidDOMElementException::class);
104
105
        $version = self::getAttribute($xml, 'Version');
106
        Assert::true(version_compare('2.0', $version->getValue(), '<='), RequestVersionTooLowException::class);
107
        Assert::true(version_compare('2.0', $version->getValue(), '>='), RequestVersionTooHighException::class);
108
109
        $requestedAuthnContext = RequestedAuthnContext::getChildrenOfClass($xml);
110
111
        $issuer = Issuer::getChildrenOfClass($xml);
112
        Assert::countBetween($issuer, 0, 1);
113
114
        $extensions = Extensions::getChildrenOfClass($xml);
115
        Assert::maxCount(
116
            $extensions,
117
            1,
118
            'Only one saml:Extensions element is allowed.',
119
            TooManyElementsException::class,
120
        );
121
122
        $subject = Subject::getChildrenOfClass($xml);
123
        Assert::notEmpty($subject, 'Missing subject in subject query.', MissingElementException::class);
124
        Assert::maxCount(
125
            $subject,
126
            1,
127
            'More than one <saml:Subject> in AttributeQuery',
128
            TooManyElementsException::class,
129
        );
130
131
        $signature = Signature::getChildrenOfClass($xml);
132
        Assert::maxCount($signature, 1, 'Only one ds:Signature element is allowed.', TooManyElementsException::class);
133
134
        $request = new static(
135
            self::getAttribute($xml, 'ID', IDValue::class),
136
            array_pop($subject),
137
            self::getAttribute($xml, 'IssueInstant', SAMLDateTimeValue::class),
138
            array_pop($requestedAuthnContext),
139
            self::getOptionalAttribute($xml, 'SessionIndex', SAMLStringValue::class, null),
140
            array_pop($issuer),
141
            self::getOptionalAttribute($xml, 'Destination', SAMLAnyURIValue::class, null),
142
            self::getOptionalAttribute($xml, 'Consent', SAMLAnyURIValue::class, null),
143
            array_pop($extensions),
144
        );
145
146
        if (!empty($signature)) {
147
            $request->setSignature($signature[0]);
148
            $request->setXML($xml);
149
        }
150
151
        return $request;
152
    }
153
154
155
    /**
156
     * Convert this message to an unsigned XML document.
157
     * This method does not sign the resulting XML document.
158
     */
159
    protected function toUnsignedXML(?DOMElement $parent = null): DOMElement
160
    {
161
        $e = parent::toUnsignedXML($parent);
162
163
        $sessionIndex = $this->getSessionIndex();
164
        if ($sessionIndex !== null) {
165
            $e->setAttribute('SessionIndex', $sessionIndex->getValue());
166
        }
167
168
        $this->getRequestedAuthnContext()?->toXML($e);
169
170
        return $e;
171
    }
172
}
173