Issues (1208)

Security Analysis    not enabled

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/LightSaml/Credential/KeyHelper.php (2 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
 * This file is part of the LightSAML-Core package.
5
 *
6
 * (c) Milos Tomic <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace LightSaml\Credential;
13
14
use LightSaml\Error\LightSamlSecurityException;
15
use RobRichards\XMLSecLibs\XMLSecurityKey;
16
17
class KeyHelper
18
{
19
    /**
20
     * @param string $key        Key content or key filename
21
     * @param string $passphrase Passphrase for the private key
22
     * @param bool   $isFile     true if $key is a filename of the key
23
     * @param string $type
24
     *
25
     * @return XMLSecurityKey
26
     */
27 41
    public static function createPrivateKey($key, $passphrase, $isFile = false, $type = XMLSecurityKey::RSA_SHA1)
28
    {
29 41
        $result = new XMLSecurityKey($type, array('type' => 'private'));
30 41
        $result->passphrase = $passphrase;
31 41
        $result->loadKey($key, $isFile, false);
32
33 41
        return $result;
34
    }
35
36
    /**
37
     * @param X509Certificate $certificate
38
     *
39
     * @return XMLSecurityKey
40
     */
41 30
    public static function createPublicKey(X509Certificate $certificate)
42
    {
43 30
        if (null == $certificate->getSignatureAlgorithm()) {
44
            throw new LightSamlSecurityException('Unrecognized certificate signature algorithm');
45
        }
46 30
        $key = new XMLSecurityKey($certificate->getSignatureAlgorithm(), array('type' => 'public'));
47 30
        $key->loadKey($certificate->toPem(), false, true);
48
49 30
        return $key;
50
    }
51
52
    /**
53
     * @param XMLSecurityKey $key
54
     * @param string         $algorithm
55
     *
56
     * @throws \LightSaml\Error\LightSamlSecurityException
57
     * @throws \InvalidArgumentException
58
     *
59
     * @return XMLSecurityKey
60
     */
61 1
    public static function castKey(XMLSecurityKey $key, $algorithm)
62
    {
63 1
        if (false == is_string($algorithm)) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
64
            throw new \InvalidArgumentException('Algorithm must be string');
65
        }
66
67
        // do nothing if algorithm is already the type of the key
68 1
        if ($key->type === $algorithm) {
69
            return $key;
70
        }
71
72 1
        $keyInfo = openssl_pkey_get_details($key->key);
73 1
        if (false === $keyInfo) {
74
            throw new LightSamlSecurityException('Unable to get key details from XMLSecurityKey.');
75
        }
76 1
        if (false == isset($keyInfo['key'])) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
77
            throw new LightSamlSecurityException('Missing key in public key details.');
78
        }
79
80 1
        $newKey = new XMLSecurityKey($algorithm, array('type' => 'public'));
81 1
        $newKey->loadKey($keyInfo['key']);
82
83 1
        return $newKey;
84
    }
85
}
86