Issues (16)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  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.
  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.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
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/BaseAuthorizationServer.php (2 issues)

Labels

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php declare(strict_types=1);
2
3
namespace Limoncello\OAuthServer;
4
5
/**
6
 * Copyright 2015-2019 [email protected]
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 * http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
21
use Limoncello\OAuthServer\Contracts\AuthorizationServerInterface;
22
use Limoncello\OAuthServer\Contracts\ClientInterface;
23
use Limoncello\OAuthServer\Contracts\Integration\ClientIntegrationInterface as CII;
24
use Limoncello\OAuthServer\Contracts\Integration\CodeIntegrationInterface as AII;
25
use Limoncello\OAuthServer\Contracts\Integration\ImplicitIntegrationInterface as III;
26
use Limoncello\OAuthServer\Contracts\Integration\PasswordIntegrationInterface as PII;
27
use Limoncello\OAuthServer\Contracts\Integration\RefreshIntegrationInterface as RII;
28
use Limoncello\OAuthServer\GrantTraits\ClientGrantTrait;
29
use Limoncello\OAuthServer\GrantTraits\CodeGrantTrait;
30
use Limoncello\OAuthServer\GrantTraits\ImplicitGrantTrait;
31
use Limoncello\OAuthServer\GrantTraits\PasswordGrantTrait;
32
use Limoncello\OAuthServer\GrantTraits\RefreshGrantTrait;
33
use Limoncello\OAuthServer\ServerTraits\OAuthServerTrait;
34
use Psr\Http\Message\ResponseInterface;
35
use Psr\Http\Message\ServerRequestInterface;
36
use function assert;
37
use function http_build_query;
38
39
/**
40
 * @package Limoncello\OAuthServer
41
 */
42
abstract class BaseAuthorizationServer implements AuthorizationServerInterface, AII, III, PII, CII, RII
43
{
44
    use OAuthServerTrait,
45
        CodeGrantTrait, ImplicitGrantTrait, PasswordGrantTrait, ClientGrantTrait, RefreshGrantTrait;
46
47
    /**
48
     * Implements Authorization Endpoint.
49
     *
50
     * @param array $parameters
51
     *
52
     * @return ResponseInterface
53
     *
54
     * @link https://tools.ietf.org/html/rfc6749#section-3.1
55
     * @link https://tools.ietf.org/html/rfc6749#section-4.2.1
56
     */
57
    abstract protected function createAuthorization(array $parameters): ResponseInterface;
58
59
    /**
60
     * @var null|int
61
     */
62
    private $maxStateLength = null;
63 44
64
    /**
65 44
     * Constructor.
66 44
     */
67 44
    public function __construct()
68 44
    {
69 44
        $this->codeSetIntegration($this);
70
        $this->implicitSetIntegration($this);
71
        $this->passSetIntegration($this);
72
        $this->clientSetIntegration($this);
73
        $this->refreshSetIntegration($this);
74
    }
75 13
76
    /**
77 13
     * @inheritdoc
78
     */
79
    public function getCreateAuthorization(ServerRequestInterface $request): ResponseInterface
80
    {
81
        return $this->createAuthorization($request->getQueryParams());
82
    }
83 2
84
    /**
85 2
     * @inheritdoc
86
     */
87
    public function postCreateAuthorization(ServerRequestInterface $request): ResponseInterface
88
    {
89
        return $this->createAuthorization($request->getParsedBody());
0 ignored issues
show
It seems like $request->getParsedBody() targeting Psr\Http\Message\ServerR...erface::getParsedBody() can also be of type null or object; however, Limoncello\OAuthServer\B...::createAuthorization() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
90
    }
91 4
92
    /**
93 4
     * @inheritdoc
94
     */
95
    public function codeValidateScope(ClientInterface $client, array $scopes = null): array
96
    {
97
        return $this->validateScope($client, $scopes);
98
    }
99 4
100
    /**
101 4
     * @inheritdoc
102
     */
103
    public function implicitValidateScope(ClientInterface $client, array $scopes = null): array
104
    {
105
        return $this->validateScope($client, $scopes);
106
    }
107 5
108
    /**
109 5
     * @inheritdoc
110
     */
111
    public function passValidateScope(ClientInterface $client = null, array $scopes = null): array
112
    {
113
        return $this->validateScope($client, $scopes);
0 ignored issues
show
It seems like $client defined by parameter $client on line 111 can be null; however, Limoncello\OAuthServer\S...rTrait::validateScope() does not accept null, maybe add an additional type check?

It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.

We recommend to add an additional type check (or disallow null for the parameter):

function notNullable(stdClass $x) { }

// Unsafe
function withoutCheck(stdClass $x = null) {
    notNullable($x);
}

// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
    if ($x instanceof stdClass) {
        notNullable($x);
    }
}

// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
    notNullable($x);
}
Loading history...
114
    }
115 3
116
    /**
117 3
     * @inheritdoc
118
     */
119
    public function clientValidateScope(ClientInterface $client, array $scopes = null): array
120
    {
121
        return $this->validateScope($client, $scopes);
122
    }
123 12
124
    /**
125 12
     * @return int|null
126
     */
127
    public function getMaxStateLength(): ?int
128
    {
129
        return $this->maxStateLength;
130
    }
131
132
    /**
133 2
     * @param int|null $maxStateLength
134
     *
135 2
     * @return self
136
     */
137 2
    public function setMaxStateLength(int $maxStateLength = null): self
138
    {
139 2
        assert($maxStateLength === null || $maxStateLength > 0);
140
141
        $this->maxStateLength = $maxStateLength;
142
143
        return $this;
144
    }
145
146
    /**
147 12
     * @param array $parameters
148
     *
149 12
     * @return string
150
     */
151
    protected function encodeAsXWwwFormUrlencoded(array $parameters): string
152
    {
153
        return http_build_query($parameters, '', '&', PHP_QUERY_RFC3986);
154
    }
155
}
156