Issues (476)

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

1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use SimpleSAML\SAML2\Binding\HTTPArtifact;
10
use SimpleSAML\SAML2\Binding\HTTPPost;
11
use SimpleSAML\SAML2\Binding\HTTPRedirect;
12
use SimpleSAML\SAML2\Binding\SOAP;
13
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...
14
use SimpleSAML\SAML2\Exception\Protocol\UnsupportedBindingException;
0 ignored issues
show
The type SimpleSAML\SAML2\Excepti...pportedBindingException 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\XML\samlp\AbstractMessage;
16
17
use function array_key_exists;
18
use function array_keys;
19
use function array_map;
20
use function explode;
21
use function implode;
22
use function var_export;
23
24
/**
25
 * Base class for SAML 2 bindings.
26
 *
27
 * @package simplesamlphp/saml2
28
 */
29
abstract class Binding
30
{
31
    /**
32
     * The destination of messages.
33
     *
34
     * This can be null, in which case the destination in the message is used.
35
     * @var string|null
36
     */
37
    protected ?string $destination = null;
38
39
40
    /**
41
     * Retrieve a binding with the given URN.
42
     *
43
     * Will throw an exception if it is unable to locate the binding.
44
     *
45
     * @param string $urn The URN of the binding.
46
     * @throws \SimpleSAML\SAML2\Exception\Protocol\UnsupportedBindingException
47
     * @return \SimpleSAML\SAML2\Binding The binding.
48
     */
49
    public static function getBinding(string $urn): Binding
50
    {
51
        switch ($urn) {
52
            case C::BINDING_HTTP_POST:
53
            case C::BINDING_HOK_SSO:
54
                return new HTTPPost();
55
            case C::BINDING_HTTP_REDIRECT:
56
                return new HTTPRedirect();
57
            case C::BINDING_HTTP_ARTIFACT:
58
                return new HTTPArtifact();
59
            // ECP ACS is defined with the PAOS binding, but as the IdP, we
60
            // talk to the ECP using SOAP -- if support for ECP as an SP is
61
            // implemented, this logic may need to change
62
            case C::BINDING_PAOS:
63
                return new SOAP();
64
            default:
65
                throw new UnsupportedBindingException('Unsupported binding: ' . var_export($urn, true));
66
        }
67
    }
68
69
70
    /**
71
     * Guess the current binding.
72
     *
73
     * This function guesses the current binding and creates an instance
74
     * of \SimpleSAML\SAML2\Binding matching that binding.
75
     *
76
     * An exception will be thrown if it is unable to guess the binding.
77
     *
78
     * @param \Psr\Http\Message\ServerRequestInterface $request
79
     * @throws \SimpleSAML\SAML2\Exception\Protocol\UnsupportedBindingException
80
     * @return \SimpleSAML\SAML2\Binding The binding.
81
     */
82
    public static function getCurrentBinding(ServerRequestInterface $request): Binding
83
    {
84
        $method = $request->getMethod();
85
86
        switch ($method) {
87
            case 'GET':
88
                $query = $request->getQueryParams();
89
                if (array_key_exists('SAMLRequest', $query) || array_key_exists('SAMLResponse', $query)) {
90
                    return new Binding\HTTPRedirect();
91
                } elseif (array_key_exists('SAMLart', $query)) {
92
                    return new Binding\HTTPArtifact();
93
                }
94
                break;
95
96
            case 'POST':
97
                $contentType = null;
98
                if ($request->hasHeader('Content-Type')) {
99
                    $contentType = $request->getHeader('Content-Type')[0];
100
                    $contentType = explode(';', $contentType);
101
                    $contentType = $contentType[0]; /* Remove charset. */
102
                }
103
104
                $query = $request->getParsedBody();
105
                if (array_key_exists('SAMLRequest', $query) || array_key_exists('SAMLResponse', $query)) {
106
                    return new Binding\HTTPPost();
107
                } elseif (array_key_exists('SAMLart', $query)) {
108
                    return new Binding\HTTPArtifact();
109
                } else {
110
                    /**
111
                     * The registration information for text/xml is in all respects the same
112
                     * as that given for application/xml (RFC 7303 - Section 9.1)
113
                     */
114
                    if (
115
                        ($contentType === 'text/xml' || $contentType === 'application/xml')
116
                        // See paragraph 3.2.3 of Binding for SAML2 (OASIS)
117
                        || ($request->hasHeader('SOAPAction')
118
                            && $request->getHeader('SOAPAction')[0] === 'http://www.oasis-open.org/committees/security')
119
                    ) {
120
                        return new Binding\SOAP();
121
                    }
122
                }
123
                break;
124
        }
125
126
        $logger = Utils::getContainer()->getLogger();
127
        $logger->warning('Unable to find the SAML 2 binding used for this request.');
128
        $logger->warning('Request method: ' . var_export($method, true));
129
130
        if (!empty($query)) {
131
            $logger->warning(
132
                $method . " parameters: '" . implode("', '", array_map('addslashes', array_keys($query))) . "'",
133
            );
134
        }
135
136
        if ($request->hasHeader('Content-Type')) {
137
            $logger->warning('Content-Type: ' . var_export($request->getHeader('Content-Type')[0], true));
138
        }
139
140
        throw new UnsupportedBindingException('Unable to find the SAML 2 binding used for this request.');
141
    }
142
143
144
    /**
145
     * Retrieve the destination of a message.
146
     *
147
     * @return string|null $destination The destination the message will be delivered to.
148
     */
149
    public function getDestination(): ?string
150
    {
151
        return $this->destination;
152
    }
153
154
155
    /**
156
     * Override the destination of a message.
157
     *
158
     * Set to null to use the destination set in the message.
159
     *
160
     * @param string|null $destination The destination the message should be delivered to.
161
     */
162
    public function setDestination(?string $destination = null): void
163
    {
164
        $this->destination = $destination;
165
    }
166
167
168
    /**
169
     * Send a SAML 2 message.
170
     *
171
     * This function will send a message using the specified binding.
172
     * The message will be delivered to the destination set in the message.
173
     *
174
     * @param \SimpleSAML\SAML2\XML\samlp\AbstractMessage $message The message which should be sent.
175
     * @return \Psr\Http\Message\ResponseInterface
176
     */
177
    abstract public function send(AbstractMessage $message): ResponseInterface;
178
179
180
    /**
181
     * Receive a SAML 2 message.
182
     *
183
     * This function will extract the message from the current request.
184
     * An exception will be thrown if we are unable to process the message.
185
     *
186
     * @param \Psr\Http\Message\ServerRequestInterface $request
187
     * @return \SimpleSAML\SAML2\XML\samlp\AbstractMessage The received message.
188
     */
189
    abstract public function receive(ServerRequestInterface $request): AbstractMessage;
190
}
191