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

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\mdattr;
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\ProtocolViolationException;
11
use SimpleSAML\SAML2\XML\saml\Assertion;
12
use SimpleSAML\SAML2\XML\saml\Attribute;
13
use SimpleSAML\SAML2\XML\saml\AttributeStatement;
14
use SimpleSAML\SAML2\XML\saml\NameID;
15
use SimpleSAML\XML\SchemaValidatableElementInterface;
16
use SimpleSAML\XML\SchemaValidatableElementTrait;
17
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
18
19
use function array_filter;
20
use function array_merge;
21
use function sprintf;
22
23
/**
24
 * Class for handling the EntityAttributes metadata extension.
25
 *
26
 * @link: http://docs.oasis-open.org/security/saml/Post2.0/sstc-metadata-attr-cs-01.pdf
27
 *
28
 * @package simplesamlphp/saml2
29
 */
30
final class EntityAttributes extends AbstractMdattrElement implements SchemaValidatableElementInterface
0 ignored issues
show
The type SimpleSAML\SAML2\XML\mdattr\AbstractMdattrElement 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...
31
{
32
    use SchemaValidatableElementTrait;
33
34
35
    /**
36
     * Create a EntityAttributes element.
37
     *
38
     * @param (\SimpleSAML\SAML2\XML\saml\Assertion|\SimpleSAML\SAML2\XML\saml\Attribute)[] $children
39
     */
40
    public function __construct(
41
        protected array $children,
42
    ) {
43
        Assert::maxCount($children, C::UNBOUNDED_LIMIT);
44
        Assert::allIsInstanceOfAny($children, [Assertion::class, Attribute::class]);
45
46
        $assertions = array_filter($children, function ($child) {
47
            return $child instanceof Assertion;
48
        });
49
50
        foreach ($assertions as $assertion) {
51
            $statements = array_merge(
52
                $assertion->getAttributeStatements(),
53
                $assertion->getAuthnStatements(),
54
                $assertion->getStatements(),
55
            );
56
57
            Assert::allIsInstanceOf(
58
                $statements,
59
                AttributeStatement::class,
60
                '<saml:Asssertion> elements in an <mdattr:EntityAttributes> may only contain AttributeStatements',
61
                ProtocolViolationException::class,
62
            );
63
            Assert::count(
64
                $statements,
65
                1,
66
                'One (and only one) <saml:AttributeStatement> MUST be included '
67
                . 'in a <saml:Assertion> inside a <mdattr:EntityAttribute>',
68
                ProtocolViolationException::class,
69
            );
70
            Assert::notNull(
71
                Assertion::fromXML($assertion->toXML())->getSignature(),
72
                'Every <saml:Assertion> inside a <mdattr:EntityAttributes> must be individually signed',
73
                ProtocolViolationException::class,
74
            );
75
76
            $subject = $assertion->getSubject();
77
            Assert::notNull(
78
                $subject,
79
                'Every <saml:Assertion> inside a <mdattr:EntityAttributes> must contain a Subject',
80
                ProtocolViolationException::class,
81
            );
82
83
            Assert::isEmpty(
84
                $subject->getSubjectConfirmation(),
85
                'Every <saml:Assertion> inside a <mdattr:EntityAttributes> must NOT contain any SubjectConfirmation',
86
                ProtocolViolationException::class,
87
            );
88
89
            /** @var \SimpleSAML\SAML2\XML\saml\NameID|null $nameId */
90
            $nameId = $subject?->getIdentifier();
91
            Assert::isInstanceOf(
92
                $nameId,
93
                NameID::class,
94
                'Every <saml:Assertion> inside a <mdattr:EntityAttributes> must contain a NameID',
95
                ProtocolViolationException::class,
96
            );
97
            Assert::same(
98
                $nameId?->getFormat()->getValue(),
99
                C::NAMEID_ENTITY,
100
                sprintf('The NameID format must be %s', C::NAMEID_ENTITY),
101
                ProtocolViolationException::class,
102
            );
103
        }
104
    }
105
106
107
    /**
108
     * Collect the value of the children-property
109
     *
110
     * @return (\SimpleSAML\SAML2\XML\saml\Assertion|\SimpleSAML\SAML2\XML\saml\Attribute)[]
111
     */
112
    public function getChildren(): array
113
    {
114
        return $this->children;
115
    }
116
117
118
    /**
119
     * Add the value to the children-property
120
     *
121
     * @param \SimpleSAML\SAML2\XML\saml\Assertion|\SimpleSAML\SAML2\XML\saml\Attribute $child
122
     *
123
     * @throws \SimpleSAML\Assert\AssertionFailedException
124
     */
125
    public function addChild($child): void
126
    {
127
        $this->children = array_merge($this->children, [$child]);
128
    }
129
130
131
    /**
132
     * Convert XML into a EntityAttributes
133
     *
134
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
135
     *   if the qualified name of the supplied element is wrong
136
     */
137
    public static function fromXML(DOMElement $xml): static
138
    {
139
        Assert::same($xml->localName, 'EntityAttributes', InvalidDOMElementException::class);
140
        Assert::same($xml->namespaceURI, EntityAttributes::NS, InvalidDOMElementException::class);
141
142
        $children = [];
143
        foreach ($xml->childNodes as $node) {
144
            if ($node instanceof DOMElement && $node->namespaceURI === C::NS_SAML) {
145
                switch ($node->localName) {
146
                    case 'Assertion':
147
                        $children[] = Assertion::fromXML($node);
148
                        break;
149
                    case 'Attribute':
150
                        $children[] = Attribute::fromXML($node);
151
                        break;
152
                    default:
153
                        continue 2;
154
                }
155
            }
156
        }
157
158
        return new static($children);
159
    }
160
161
162
    /**
163
     * Convert this EntityAttributes to XML.
164
     */
165
    public function toXML(?DOMElement $parent = null): DOMElement
166
    {
167
        $e = $this->instantiateParentElement($parent);
168
169
        foreach ($this->getChildren() as $child) {
170
            $child->toXML($e);
171
        }
172
173
        return $e;
174
    }
175
}
176