Issues (2)

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 (2 issues)

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|class-string
0 ignored issues
show
Documentation Bug introduced by
The doc comment \SimpleSAML\Auth\State|class-string at position 2 could not be parsed: Unknown type name 'class-string' at position 2 in \SimpleSAML\Auth\State|class-string.
Loading history...
28
     */
29
    protected $authState = Auth\State::class;
30
31
    /**
32
     * @var \SimpleSAML\Module\yubikey\Auth\Process\OTP|class-string
0 ignored issues
show
Documentation Bug introduced by
The doc comment \SimpleSAML\Module\yubik...rocess\OTP|class-string at position 2 could not be parsed: Unknown type name 'class-string' at position 2 in \SimpleSAML\Module\yubikey\Auth\Process\OTP|class-string.
Loading history...
33
     */
34
    protected $otp = OTP::class;
35
36
37
    /**
38
     * Controller constructor.
39
     *
40
     * It initializes the global configuration and session for the controllers implemented here.
41
     *
42
     * @param \SimpleSAML\Configuration $config The configuration to use by the controllers.
43
     * @param \SimpleSAML\Session $session The session to use by the controllers.
44
     *
45
     * @throws \Exception
46
     */
47
    public function __construct(
48
        protected Configuration $config,
49
        protected Session $session,
50
    ) {
51
    }
52
53
54
    /**
55
     * Inject the \SimpleSAML\Auth\State dependency.
56
     *
57
     * @param \SimpleSAML\Auth\State $authState
58
     */
59
    public function setAuthState(Auth\State $authState): void
60
    {
61
        $this->authState = $authState;
62
    }
63
64
65
    /**
66
     * Inject the \SimpleSAML\Module\yubikey\Auth\Process\OTP dependency.
67
     *
68
     * @param \SimpleSAML\Module\yubikey\Auth\Process\OTP $otp
69
     */
70
    public function setOtp(OTP $otp): void
71
    {
72
        $this->otp = $otp;
73
    }
74
75
76
    /**
77
     * This page asks the user to authenticate using a Yubikey.
78
     *
79
     * @param \Symfony\Component\HttpFoundation\Request $request The current request.
80
     * @return \SimpleSAML\XHTML\Template|\SimpleSAML\HTTP\RunnableResponse
81
     */
82
    public function main(Request $request)
83
    {
84
        $stateId = $request->query->get('AuthState');
85
        if ($stateId === null) {
86
            throw new Error\BadRequest('Missing AuthState parameter.');
87
        }
88
89
        $state = $this->authState::loadState($stateId, 'yubikey:otp:init');
90
91
        $error = false;
92
93
        $otp = $request->request->get('otp');
94
        if ($otp !== null) {
95
            // we were given an OTP
96
            try {
97
                if ($this->otp::authenticate($state, $otp)) {
98
                    $this->authState::saveState($state, 'yubikey:otp:init');
99
                    return new RunnableResponse([Auth\ProcessingChain::class, 'resumeProcessing'], [$state]);
100
                } else {
101
                    $error = 'The YubiKey used is invalid. Make sure to use the YubiKey associated with your account.';
102
                }
103
            } catch (InvalidArgumentException $e) {
104
                $error = $e->getMessage();
105
            }
106
        }
107
108
        $t = new Template($this->config, 'yubikey:otp.twig');
109
        $t->data['AuthState'] = $stateId;
110
        $t->data['error'] = $error ?: false;
111
        $t->data['autofocus'] = 'otp';
112
113
        return $t;
114
    }
115
}
116