Issues (378)

Security Analysis    23 potential vulnerabilities

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 (2)
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection (1)
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 (5)
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 (14)
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 (1)
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.

core/src/Auth/Process/AttributeValueMap.php (1 issue)

Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\Module\core\Auth\Process;
6
7
use SimpleSAML\{Auth, Error, Logger};
8
use SimpleSAML\Assert\Assert;
9
10
use function array_intersect;
11
use function array_key_exists;
12
use function array_merge;
13
use function array_unique;
14
use function count;
15
use function is_array;
16
use function is_int;
17
18
/**
19
 * Filter to create target attribute based on value(s) in source attribute
20
 *
21
 * @package SimpleSAMLphp
22
 */
23
class AttributeValueMap extends Auth\ProcessingFilter
24
{
25
    /**
26
     * The name of the attribute we should assign values to (ie: the target attribute).
27
     * @var string
28
     */
29
    private string $targetattribute = '';
30
31
    /**
32
     * The name of the attribute we should create values from.
33
     * @var string
34
     */
35
    private string $sourceattribute = '';
36
37
    /**
38
     * The required $sourceattribute values and target affiliations.
39
     * @var array
40
     */
41
    private array $values = [];
42
43
    /**
44
     * Whether $sourceattribute should be kept or not.
45
     * @var bool
46
     */
47
    private bool $keep = false;
48
49
    /**
50
     * Whether $target attribute values should be replaced by new values or not.
51
     * @var bool
52
     */
53
    private bool $replace = false;
54
55
56
    /**
57
     * Initialize the filter.
58
     *
59
     * @param array &$config Configuration information about this filter.
60
     * @param mixed $reserved For future use.
61
     * @throws \SimpleSAML\Error\Exception If the configuration is not valid.
62
     */
63
    public function __construct(array &$config, $reserved)
64
    {
65
        parent::__construct($config, $reserved);
66
67
        // parse configuration
68
        foreach ($config as $name => $value) {
69
            if (is_int($name)) {
70
                // check if this is an option
71
                if ($value === '%replace') {
72
                    $this->replace = true;
73
                } elseif ($value === '%keep') {
74
                    $this->keep = true;
75
                } else {
76
                    // unknown configuration option, log it and ignore the error
77
                    Logger::warning(
78
                        "AttributeValueMap: unknown configuration flag '" . var_export($value, true) . "'"
79
                    );
80
                }
81
                continue;
82
            }
83
84
            // set the target attribute
85
            if ($name === 'targetattribute') {
86
                $this->targetattribute = $value;
87
            }
88
89
            // set the source attribute
90
            if ($name === 'sourceattribute') {
91
                $this->sourceattribute = $value;
92
            }
93
94
            // set the values
95
            if ($name === 'values') {
96
                $this->values = $value;
97
            }
98
        }
99
100
        // now validate it
101
        if (empty($this->sourceattribute)) {
102
            throw new Error\Exception("AttributeValueMap: 'sourceattribute' configuration option not set.");
103
        }
104
        if (empty($this->targetattribute)) {
105
            throw new Error\Exception("AttributeValueMap: 'targetattribute' configuration option not set.");
106
        }
107
        if (!is_array($this->values)) {
0 ignored issues
show
The condition is_array($this->values) is always true.
Loading history...
108
            throw new Error\Exception("AttributeValueMap: 'values' configuration option is not an array.");
109
        }
110
    }
111
112
113
    /**
114
     * Apply filter.
115
     *
116
     * @param array &$state The current request
117
     */
118
    public function process(array &$state): void
119
    {
120
        Logger::debug('Processing the AttributeValueMap filter.');
121
122
        Assert::keyExists($state, 'Attributes');
123
        $attributes = &$state['Attributes'];
124
125
        if (!array_key_exists($this->sourceattribute, $attributes)) {
126
            // the source attribute does not exist, nothing to do here
127
            return;
128
        }
129
130
        $sourceattribute = $attributes[$this->sourceattribute];
131
        $targetvalues = [];
132
133
        if (is_array($sourceattribute)) {
134
            foreach ($this->values as $value => $values) {
135
                if (!is_array($values)) {
136
                    $values = [$values];
137
                }
138
                if (count(array_intersect($values, $sourceattribute)) > 0) {
139
                    Logger::debug("AttributeValueMap: intersect match for '$value'");
140
                    $targetvalues[] = $value;
141
                }
142
            }
143
        }
144
145
        if (count($targetvalues) > 0) {
146
            if ($this->replace || !array_key_exists($this->targetattribute, $attributes)) {
147
                $attributes[$this->targetattribute] = $targetvalues;
148
            } else {
149
                $attributes[$this->targetattribute] = array_unique(array_merge(
150
                    $attributes[$this->targetattribute],
151
                    $targetvalues
152
                ));
153
            }
154
        }
155
156
        if (!$this->keep) {
157
            // no need to keep the source attribute
158
            unset($attributes[$this->sourceattribute]);
159
        }
160
    }
161
}
162