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/AttributeQuery.php (6 issues)

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\Constants as C;
0 ignored issues
show
The type SimpleSAML\SAML2\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...
10
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...
11
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...
12
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
13
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
14
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...
15
use SimpleSAML\SAML2\Type\SAMLStringValue;
16
use SimpleSAML\SAML2\XML\saml\Attribute;
17
use SimpleSAML\SAML2\XML\saml\Issuer;
18
use SimpleSAML\SAML2\XML\saml\Subject;
19
use SimpleSAML\XML\SchemaValidatableElementInterface;
20
use SimpleSAML\XML\SchemaValidatableElementTrait;
21
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
22
use SimpleSAML\XMLSchema\Exception\MissingElementException;
23
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
24
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...
25
use SimpleSAML\XMLSecurity\XML\ds\Signature;
26
27
use function array_pop;
28
use function in_array;
29
30
/**
31
 * Class for SAML 2 attribute query messages.
32
 *
33
 * An attribute query asks for a set of attributes. The following
34
 * rules apply:
35
 *
36
 * - If no attributes are present in the query, all attributes should be
37
 *   returned.
38
 * - If any attributes are present, only those attributes which are present
39
 *   in the query should be returned.
40
 * - If an attribute contains any attribute values, only the attribute values
41
 *   which match those in the query should be returned.
42
 *
43
 * @package simplesamlphp/saml2
44
 */
45
class AttributeQuery extends AbstractSubjectQuery implements SchemaValidatableElementInterface
46
{
47
    use SchemaValidatableElementTrait;
48
49
50
    /**
51
     * Constructor for SAML 2 AttributeQuery.
52
     *
53
     * @param \SimpleSAML\XMLSchema\Type\IDValue $id
54
     * @param \SimpleSAML\SAML2\XML\saml\Subject $subject
55
     * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue $issueInstant
56
     * @param \SimpleSAML\SAML2\XML\saml\Attribute[] $attributes
57
     * @param \SimpleSAML\SAML2\XML\saml\Issuer $issuer
58
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $destination
59
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $consent
60
     * @param \SimpleSAML\SAML2\XML\samlp\Extensions $extensions
61
     */
62
    final public function __construct(
63
        IDValue $id,
64
        Subject $subject,
65
        SAMLDateTimeValue $issueInstant,
66
        protected array $attributes = [],
67
        ?Issuer $issuer = null,
68
        ?SAMLAnyURIValue $destination = null,
69
        ?SAMLAnyURIValue $consent = null,
70
        ?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...
71
    ) {
72
        Assert::maxCount($attributes, C::UNBOUNDED_LIMIT);
73
        Assert::allIsInstanceOf($attributes, Attribute::class);
74
75
        $cache = [];
76
        foreach ($attributes as $attribute) {
77
            $name = $attribute->getName();
78
            $nameFormat = $attribute->getNameFormat()?->getValue() ?? C::NAMEFORMAT_UNSPECIFIED;
79
80
            if (isset($cache[$nameFormat])) {
81
                Assert::true(
82
                    !in_array($name, $cache[$nameFormat], true),
83
                    'A single query MUST NOT contain two <saml:Attribute> elements with the same Name and NameFormat.',
84
                    ProtocolViolationException::class,
85
                );
86
            }
87
            $cache[$nameFormat][] = $name;
88
        }
89
        unset($cache);
90
91
        parent::__construct($id, $subject, $issuer, $issueInstant, $destination, $consent, $extensions);
92
    }
93
94
95
    /**
96
     * Retrieve all requested attributes.
97
     *
98
     * @return \SimpleSAML\SAML2\XML\saml\Attribute[] All requested attributes, as an associative array.
99
     */
100
    public function getAttributes(): array
101
    {
102
        return $this->attributes;
103
    }
104
105
106
    /**
107
     * Create a class from XML
108
     *
109
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
110
     *   if the qualified name of the supplied element is wrong
111
     * @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException
112
     *   if the supplied element is missing one of the mandatory attributes
113
     * @throws \SimpleSAML\XMLSchema\Exception\MissingElementException
114
     *   if one of the mandatory child-elements is missing
115
     * @throws \SimpleSAML\XMLSchema\Exception\TooManyElementsException
116
     *   if too many child-elements of a type are specified
117
     */
118
    public static function fromXML(DOMElement $xml): static
119
    {
120
        Assert::same($xml->localName, 'AttributeQuery', InvalidDOMElementException::class);
121
        Assert::same($xml->namespaceURI, AttributeQuery::NS, InvalidDOMElementException::class);
122
123
        $version = self::getAttribute($xml, 'Version', SAMLStringValue::class);
124
        Assert::true(version_compare('2.0', strval($version), '<='), RequestVersionTooLowException::class);
125
        Assert::true(version_compare('2.0', strval($version), '>='), RequestVersionTooHighException::class);
126
127
        $issuer = Issuer::getChildrenOfClass($xml);
128
        Assert::countBetween($issuer, 0, 1);
129
130
        $extensions = Extensions::getChildrenOfClass($xml);
131
        Assert::maxCount(
132
            $extensions,
133
            1,
134
            'Only one saml:Extensions element is allowed.',
135
            TooManyElementsException::class,
136
        );
137
138
        $subject = Subject::getChildrenOfClass($xml);
139
        Assert::notEmpty($subject, 'Missing subject in subject query.', MissingElementException::class);
140
        Assert::maxCount(
141
            $subject,
142
            1,
143
            'More than one <saml:Subject> in AttributeQuery',
144
            TooManyElementsException::class,
145
        );
146
147
        $signature = Signature::getChildrenOfClass($xml);
148
        Assert::maxCount($signature, 1, 'Only one ds:Signature element is allowed.', TooManyElementsException::class);
149
150
        $request = new static(
151
            self::getAttribute($xml, 'ID', IDValue::class),
152
            array_pop($subject),
153
            self::getAttribute($xml, 'IssueInstant', SAMLDateTimeValue::class),
154
            Attribute::getChildrenOfClass($xml),
155
            array_pop($issuer),
156
            self::getOptionalAttribute($xml, 'Destination', SAMLAnyURIValue::class, null),
157
            self::getOptionalAttribute($xml, 'Consent', SAMLAnyURIValue::class, null),
158
            array_pop($extensions),
159
        );
160
161
        if (!empty($signature)) {
162
            $request->setSignature($signature[0]);
163
            $request->setXML($xml);
164
        }
165
166
        return $request;
167
    }
168
169
170
    /**
171
     * Convert this message to an unsigned XML document.
172
     * This method does not sign the resulting XML document.
173
     */
174
    protected function toUnsignedXML(?DOMElement $parent = null): DOMElement
175
    {
176
        $e = parent::toUnsignedXML($parent);
177
178
        foreach ($this->getAttributes() as $attribute) {
179
            $attribute->toXML($e);
180
        }
181
182
        return $e;
183
    }
184
}
185