GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (22)

Security Analysis    1 potential vulnerability

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 (1)
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/Http/TwoFactorModule.php (4 issues)

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
2
3
/**
4
 * eduVPN - End-user friendly VPN.
5
 *
6
 * Copyright: 2016-2017, The Commons Conservancy eduVPN Programme
7
 * SPDX-License-Identifier: AGPL-3.0+
8
 */
9
10
namespace SURFnet\VPN\Common\Http;
11
12
use fkooman\SeCookie\SessionInterface;
13
use SURFnet\VPN\Common\Http\Exception\HttpException;
14
use SURFnet\VPN\Common\HttpClient\Exception\ApiException;
15
use SURFnet\VPN\Common\HttpClient\ServerClient;
16
use SURFnet\VPN\Common\TplInterface;
17
18
class TwoFactorModule implements ServiceModuleInterface
19
{
20
    /** @var \SURFnet\VPN\Common\HttpClient\ServerClient */
21
    private $serverClient;
22
23
    /** @var \fkooman\SeCookie\SessionInterface; */
24
    private $session;
25
26
    /** @var \SURFnet\VPN\Common\TplInterface */
27
    private $tpl;
28
29
    public function __construct(ServerClient $serverClient, SessionInterface $session, TplInterface $tpl)
30
    {
31
        $this->serverClient = $serverClient;
32
        $this->session = $session;
33
        $this->tpl = $tpl;
34
    }
35
36
    public function init(Service $service)
37
    {
38
        $service->post(
39
            '/_two_factor/auth/verify/totp',
40 View Code Duplication
            function (Request $request, array $hookData) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
                if (!array_key_exists('auth', $hookData)) {
42
                    throw new HttpException('authentication hook did not run before', 500);
43
                }
44
                $userId = $hookData['auth'];
45
46
                $this->session->delete('_two_factor_verified');
47
48
                $totpKey = InputValidation::totpKey($request->getPostParameter('_two_factor_auth_totp_key'));
49
                $redirectTo = $request->getPostParameter('_two_factor_auth_redirect_to');
50
                self::validateRedirectTo($request, $redirectTo);
51
52
                try {
53
                    $this->serverClient->post('verify_totp_key', ['user_id' => $userId, 'totp_key' => $totpKey]);
54
                    $this->session->regenerate(true);
55
                    $this->session->set('_two_factor_verified', $userId);
56
57
                    return new RedirectResponse($redirectTo, 302);
58
                } catch (ApiException $e) {
59
                    // unable to validate the OTP
60
                    $response = new Response(200, 'text/html');
61
                    $response->setBody(
62
                        $this->tpl->render(
63
                            'twoFactorTotp',
64
                            [
65
                                '_two_factor_auth_invalid' => true,
66
                                '_two_factor_auth_error_msg' => $e->getMessage(),
67
                                '_two_factor_auth_redirect_to' => $redirectTo,
68
                            ]
69
                        )
70
                    );
71
72
                    return $response;
73
                }
74
            }
75
        );
76
77
        $service->post(
78
            '/_two_factor/auth/verify/yubi',
79 View Code Duplication
            function (Request $request, array $hookData) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
80
                if (!array_key_exists('auth', $hookData)) {
81
                    throw new HttpException('authentication hook did not run before', 500);
82
                }
83
                $userId = $hookData['auth'];
84
85
                $this->session->delete('_two_factor_verified');
86
87
                $yubiKeyOtp = InputValidation::yubiKeyOtp($request->getPostParameter('_two_factor_auth_yubi_key_otp'));
88
                $redirectTo = $request->getPostParameter('_two_factor_auth_redirect_to');
89
                self::validateRedirectTo($request, $redirectTo);
90
91
                try {
92
                    $this->serverClient->post('verify_yubi_key_otp', ['user_id' => $userId, 'yubi_key_otp' => $yubiKeyOtp]);
93
                    $this->session->regenerate(true);
94
                    $this->session->set('_two_factor_verified', $userId);
95
96
                    return new RedirectResponse($redirectTo, 302);
97
                } catch (ApiException $e) {
98
                    // unable to validate the OTP
99
                    $response = new Response(200, 'text/html');
100
                    $response->setBody(
101
                        $this->tpl->render(
102
                            'twoFactorYubiKeyOtp',
103
                            [
104
                                '_two_factor_auth_invalid' => true,
105
                                '_two_factor_auth_error_msg' => $e->getMessage(),
106
                                '_two_factor_auth_redirect_to' => $redirectTo,
107
                            ]
108
                        )
109
                    );
110
111
                    return $response;
112
                }
113
            }
114
        );
115
    }
116
117
    private static function validateRedirectTo(Request $request, $redirectTo)
118
    {
119
        // validate the URL
120 View Code Duplication
        if (false === filter_var($redirectTo, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED | FILTER_FLAG_PATH_REQUIRED)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
121
            throw new HttpException('invalid redirect_to URL', 400);
122
        }
123
124
        // extract the "host" part of the URL
125 View Code Duplication
        if (false === $redirectToHost = parse_url($redirectTo, PHP_URL_HOST)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
126
            throw new HttpException('invalid redirect_to URL, unable to extract host', 400);
127
        }
128
        if ($request->getServerName() !== $redirectToHost) {
129
            throw new HttpException('redirect_to does not match expected host', 400);
130
        }
131
    }
132
}
133