Issues (14)

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/Account/Link.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * This file is part of the Mediapart LaPresseLibre Library.
5
 *
6
 * CC BY-NC-SA <https://github.com/mediapart/lapresselibre>
7
 *
8
 * For the full license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Mediapart\LaPresseLibre\Account;
13
14
use Mediapart\LaPresseLibre\Security\Encryption;
15
use Mediapart\LaPresseLibre\Account\Account;
16
use Mediapart\LaPresseLibre\Account\Repository;
17
18
/**
19
 * @see https://github.com/NextINpact/LaPresseLibreSDK/wiki/Liaison-de-compte-utilisateur-par-redirection
20
 */
21
class Link
22
{
23
    const RETURN_URL = 'https://beta.lapresselibre.fr/manage/link-result?lpl=%1$s&part=%2$s';
24
    const STATUS_SUCCESS = 1;
25
    const STATUS_FAILURE = 2;
26
    const STATUS_CONFLICT = 3;
27
28
    /**
29
     * @var Encryption
30
     */
31
    private $encryption;
32
33
    /**
34
     * @var Repository 
35
     */
36
    private $repository;
37
38
    /**
39
     * @var int
40
     */
41
    private $public_key;
42
43
    /**
44
     * @param Encryption $encryption
45
     * @param Repository $repository
46
     * @param int $public_key
47
     */
48
    public function __construct(Encryption $encryption, Repository $repository, $public_key)
49
    {
50
        $this->encryption = $encryption;
51
        $this->repository = $repository;
52
        $this->public_key = $public_key;
53
    }
54
55
    /**
56
     * Liaison de compte utilisateur par redirection
57
     *
58
     * @param string $lplUser
59
     * @param Account $logguedAccount
60
     * @return string
61
     */
62
    public function generate($lplUser, Account $logguedAccount)
63
    {
64
        /* Le paramètre "lpluser" représente l'ID LPL de l'utilisateur qui 
65
           souhaite lier son compte. Il est chiffré en AES256 puis codé en 
66
           base64 en reprenant la méthode de chiffrement utilisée pour les 
67
           web services. */
68
        $code = $this->encryption->decrypt($lplUser);
69
70
        if ($existingAccount = $this->repository->find($code)) {
71
72
            /* En cas de conflit la valeur du statut que le partenaire doit
73
               retourner sera "3". Sauf évidement s'il s'agit du bon compte
74
               utilisateur. */
75
            $status = ($existingAccount != $logguedAccount) 
76
                ? self::STATUS_CONFLICT 
77
                : self::STATUS_SUCCESS
78
            ;
79
80
        } else {
81
            try {
82
83
                /* Si l'ID LPL reçu n'est pas déjà présent, le partenaire 
84
                   doit rechercher le compte utilisateur pour y rattacher 
85
                   L'ID LPL. Puis on retourne un statut "1" pour indiquer 
86
                   que la liaison s'est effectuée avec succès. */
87
                $account = new Account($logguedAccount->getEmail(), $code);
88
                $this->repository->save($account);
89
                $status = self::STATUS_SUCCESS;
90
91
            } catch (\Exception $e) {
92
93
                /* Le statut retourné par le partenaire LPL est "2" en cas 
94
                   d'erreur. */
95
                $status = self::STATUS_FAILURE;
96
            }
97
        }
98
99
        /* Le partenaire doit rediriger l'utilisateur vers l'url fournie par 
100
           LPL avec les paramètres : */
101
        return sprintf(
102
            self::RETURN_URL,
103
104
            /* "lpl" : composé de l'ID LPL et du statut. Ce paramètre sera 
105
               ensuite chiffré en AES puis codé en base64. 
106
               Exemple : { Guid: xxxx, statut: 1 } */
107
            rawurlencode(
108
                $this->encryption->encrypt(
109
                    [
0 ignored issues
show
array('Guid' => $code, 'statut' => $status) of type array<string,integer|string> is incompatible with the type string expected by parameter $message of Mediapart\LaPresseLibre\...y\Encryption::encrypt(). ( Ignorable by Annotation )

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

109
                    /** @scrutinizer ignore-type */ [
Loading history...
110
                        'Guid' => $code,
111
                        'statut' => $status,
112
                    ],
113
                    OPENSSL_RAW_DATA & OPENSSL_NO_PADDING
114
                )
115
            ),
116
117
            /* "part" : qui représente le code du partenaire. */
118
            $this->public_key
119
        );
120
    }
121
}
122