Issues (99)

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

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;
10
use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooLowException;
11
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
12
use SimpleSAML\SAML2\Type\SAMLDateTimeValue;
13
use SimpleSAML\SAML2\Type\SAMLStringValue;
14
use SimpleSAML\SAML2\Utils\XPath;
15
use SimpleSAML\SAML2\XML\saml\Issuer;
16
use SimpleSAML\XML\SchemaValidatableElementInterface;
17
use SimpleSAML\XML\SchemaValidatableElementTrait;
18
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
19
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
20
use SimpleSAML\XMLSchema\Type\IDValue;
21
use SimpleSAML\XMLSchema\Type\NCNameValue;
22
use SimpleSAML\XMLSecurity\XML\ds\Signature;
23
24
use function array_pop;
25
use function version_compare;
26
27
/**
28
 * The \SimpleSAML\SAML2\XML\samlp\ArtifactResponse,
29
 *  is the response to the \SimpleSAML\SAML2\XML\samlp\ArtifactResolve.
30
 *
31
 * @package simplesamlphp/saml2
32
 */
33
class ArtifactResponse extends AbstractStatusResponse implements SchemaValidatableElementInterface
34
{
35
    use SchemaValidatableElementTrait;
0 ignored issues
show
The trait SimpleSAML\XML\SchemaValidatableElementTrait requires the property $line which is not provided by SimpleSAML\SAML2\XML\samlp\ArtifactResponse.
Loading history...
36
37
38
    /**
39
     * Constructor for SAML 2 ArtifactResponse.
40
     *
41
     * @param \SimpleSAML\XMLSchema\Type\IDValue $id
42
     * @param \SimpleSAML\SAML2\XML\samlp\Status $status
43
     * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue $issueInstant
44
     * @param \SimpleSAML\SAML2\XML\saml\Issuer|null $issuer
45
     * @param \SimpleSAML\XMLSchema\Type\NCNameValue|null $inResponseTo
46
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $destination
47
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $consent
48
     * @param \SimpleSAML\SAML2\XML\samlp\Extensions|null $extensions
49
     * @param \SimpleSAML\SAML2\XML\samlp\AbstractMessage|null $message
50
     */
51
    final public function __construct(
52
        IDValue $id,
53
        Status $status,
54
        SAMLDateTimeValue $issueInstant,
55
        ?Issuer $issuer = null,
56
        ?NCNameValue $inResponseTo = null,
57
        ?SAMLAnyURIValue $destination = null,
58
        ?SAMLAnyURIValue $consent = null,
59
        ?Extensions $extensions = null,
60
        protected ?AbstractMessage $message = null,
61
    ) {
62
        parent::__construct(
63
            $id,
64
            $status,
65
            $issueInstant,
66
            $issuer,
67
            $inResponseTo,
68
            $destination,
69
            $consent,
70
            $extensions,
71
        );
72
    }
73
74
75
    /**
76
     * Collect the value of the any-property
77
     *
78
     * @return \SimpleSAML\SAML2\XML\samlp\AbstractMessage|null
79
     */
80
    public function getMessage(): ?AbstractMessage
81
    {
82
        return $this->message;
83
    }
84
85
86
    /**
87
     * Convert XML into an ArtifactResponse
88
     *
89
     * @param \DOMElement $xml
90
     * @return static
91
     *
92
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
93
     *   if the qualified name of the supplied element is wrong
94
     * @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException
95
     *   if the supplied element is missing one of the mandatory attributes
96
     */
97
    public static function fromXML(DOMElement $xml): static
98
    {
99
        Assert::same($xml->localName, 'ArtifactResponse', InvalidDOMElementException::class);
100
        Assert::same($xml->namespaceURI, ArtifactResponse::NS, InvalidDOMElementException::class);
101
102
        $version = self::getAttribute($xml, 'Version', SAMLStringValue::class);
103
        Assert::true(version_compare('2.0', $version->getValue(), '<='), RequestVersionTooLowException::class);
104
        Assert::true(version_compare('2.0', $version->getValue(), '>='), RequestVersionTooHighException::class);
105
106
        $issuer = Issuer::getChildrenOfClass($xml);
107
        Assert::countBetween($issuer, 0, 1);
108
109
        // find message; it should come last, after the Status-element
110
        $status = XPath::xpQuery($xml, './saml_protocol:Status', XPath::getXPath($xml));
111
        $status = $status[0];
112
        $message = null;
113
114
        /** @psalm-suppress RedundantCondition */
115
        for ($child = $status->nextSibling; $child !== null; $child = $child->nextSibling) {
116
            if ($child instanceof DOMElement) {
117
                $message = MessageFactory::fromXML($child);
118
                break;
119
            }
120
            /* Ignore comments and text nodes. */
121
        }
122
123
        $status = Status::getChildrenOfClass($xml);
124
        Assert::count($status, 1);
125
126
        $extensions = Extensions::getChildrenOfClass($xml);
127
        Assert::maxCount(
128
            $extensions,
129
            1,
130
            'Only one saml:Extensions element is allowed.',
131
            TooManyElementsException::class,
132
        );
133
134
        $signature = Signature::getChildrenOfClass($xml);
135
        Assert::maxCount(
136
            $signature,
137
            1,
138
            'Only one ds:Signature element is allowed.',
139
            TooManyElementsException::class,
140
        );
141
142
        $response = new static(
143
            self::getAttribute($xml, 'ID', IDValue::class),
144
            array_pop($status),
145
            self::getAttribute($xml, 'IssueInstant', SAMLDateTimeValue::class),
146
            empty($issuer) ? null : array_pop($issuer),
147
            self::getOptionalAttribute($xml, 'InResponseTo', NCNameValue::class, null),
148
            self::getOptionalAttribute($xml, 'Destination', SAMLAnyURIValue::class, null),
149
            self::getOptionalAttribute($xml, 'Consent', SAMLAnyURIValue::class, null),
150
            empty($extensions) ? null : array_pop($extensions),
151
            $message,
152
        );
153
154
        if (!empty($signature)) {
155
            $response->setSignature($signature[0]);
156
            $response->setXML($xml);
157
        }
158
159
        return $response;
160
    }
161
162
163
    /**
164
     * Convert this message to an unsigned XML document.
165
     * This method does not sign the resulting XML document.
166
     *
167
     * @return \DOMElement The root element of the DOM tree
168
     */
169
    protected function toUnsignedXML(?DOMElement $parent = null): DOMElement
170
    {
171
        $e = parent::toUnsignedXML($parent);
172
173
        $this->getMessage()?->toXML($e);
174
175
        return $e;
176
    }
177
}
178