Issues (1)

Security Analysis    not enabled

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

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\Module\yubikey\Controller;
6
7
use InvalidArgumentException;
8
use SimpleSAML\Auth;
9
use SimpleSAML\Configuration;
10
use SimpleSAML\Error;
11
use SimpleSAML\HTTP\RunnableResponse;
12
use SimpleSAML\Module\yubikey\Auth\Process\OTP;
13
use SimpleSAML\Session;
14
use SimpleSAML\XHTML\Template;
15
use Symfony\Component\HttpFoundation\Request;
16
17
/**
18
 * Controller class for the yubikey module.
19
 *
20
 * This class serves the different views available in the module.
21
 *
22
 * @package simplesamlphp/simplesamlphp-module-yubikey
23
 */
24
class Yubikey
25
{
26
    /**
27
     * @var \SimpleSAML\Auth\State|string
28
     * @psalm-var \SimpleSAML\Auth\State|class-string
29
     */
30
    protected $authState = Auth\State::class;
31
32
    /**
33
     * @var \SimpleSAML\Module\yubikey\Auth\Process\OTP|string
34
     * @psalm-var \SimpleSAML\Module\yubikey\Auth\Process\OTP|class-string
35
     */
36
    protected $otp = OTP::class;
37
38
39
    /**
40
     * Controller constructor.
41
     *
42
     * It initializes the global configuration and session for the controllers implemented here.
43
     *
44
     * @param \SimpleSAML\Configuration $config The configuration to use by the controllers.
45
     * @param \SimpleSAML\Session $session The session to use by the controllers.
46
     *
47
     * @throws \Exception
48
     */
49
    public function __construct(
50
        protected Configuration $config,
51
        protected Session $session,
52
    ) {
53
    }
54
55
56
    /**
57
     * Inject the \SimpleSAML\Auth\State dependency.
58
     *
59
     * @param \SimpleSAML\Auth\State $authState
60
     */
61
    public function setAuthState(Auth\State $authState): void
62
    {
63
        $this->authState = $authState;
64
    }
65
66
67
    /**
68
     * Inject the \SimpleSAML\Module\yubikey\Auth\Process\OTP dependency.
69
     *
70
     * @param \SimpleSAML\Module\yubikey\Auth\Process\OTP $otp
71
     */
72
    public function setOtp(OTP $otp): void
73
    {
74
        $this->otp = $otp;
75
    }
76
77
78
    /**
79
     * This page asks the user to authenticate using a Yubikey.
80
     *
81
     * @param \Symfony\Component\HttpFoundation\Request $request The current request.
82
     * @return \SimpleSAML\XHTML\Template|\SimpleSAML\HTTP\RunnableResponse
83
     */
84
    public function main(Request $request)
85
    {
86
        $stateId = $request->query->get('AuthState');
87
        if ($stateId === null) {
88
            throw new Error\BadRequest('Missing AuthState parameter.');
89
        }
90
91
        $state = $this->authState::loadState($stateId, 'yubikey:otp:init');
92
93
        $error = false;
94
95
        $otp = $request->request->get('otp');
96
        if ($otp !== null) {
97
            // we were given an OTP
98
            try {
99
                if ($this->otp::authenticate($state, $otp)) {
0 ignored issues
show
It seems like $state can also be of type null; however, parameter $state of SimpleSAML\Module\yubike...ess\OTP::authenticate() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

99
                if ($this->otp::authenticate(/** @scrutinizer ignore-type */ $state, $otp)) {
Loading history...
100
                    $this->authState::saveState($state, 'yubikey:otp:init');
101
                    return new RunnableResponse([Auth\ProcessingChain::class, 'resumeProcessing'], [$state]);
102
                } else {
103
                    $error = 'The YubiKey used is invalid. Make sure to use the YubiKey associated with your account.';
104
                }
105
            } catch (InvalidArgumentException $e) {
106
                $error = $e->getMessage();
107
            }
108
        }
109
110
        $t = new Template($this->config, 'yubikey:otp.twig');
111
        $t->data['AuthState'] = $stateId;
112
        $t->data['error'] = $error ?: false;
113
        $t->data['autofocus'] = 'otp';
114
115
        return $t;
116
    }
117
}
118