Issues (12)

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.

web/idp/_config.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
require_once __DIR__.'/../../vendor/autoload.php';
4
5
class IdpConfig
6
{
7
    const OWN_ENTITY_ID = 'https://localhost/lightSAML/lightSAML-IDP';
8
9
    /** @var  \SpConfig */
10
    private static $instance;
11
12
    public $debug = true;
13
14
    /**
15
     * @return \IdpConfig
16
     */
17
    public static function current()
18
    {
19
        if (null == self::$instance) {
20
            self::$instance = new static();
0 ignored issues
show
Documentation Bug introduced by
It seems like new static() of type this<IdpConfig> is incompatible with the declared type object<SpConfig> of property $instance.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
21
        }
22
23
        return self::$instance;
0 ignored issues
show
Bug Compatibility introduced by
The expression self::$instance; of type IdpConfig|SpConfig adds the type SpConfig to the return on line 23 which is incompatible with the return type documented by IdpConfig::current of type IdpConfig.
Loading history...
24
    }
25
26
    /**
27
     * @return \LightSaml\Build\Container\BuildContainerInterface
28
     */
29
    public function getBuildContainer()
30
    {
31
        $pimple = new \Pimple\Container();
32
        $result = new \LightSaml\Bridge\Pimple\Container\BuildContainer($pimple);
33
        $this->buildOwnContext($result);
34
        $this->buildSystemContext($result);
35
        $this->buildPartyContext($result);
36
        $this->buildStoreContext($result);
37
        $this->buildProviderContext($result);
38
        $this->buildCredentialContext($result);
39
        $this->buildServiceContext($result);
40
41
        return $result;
42
    }
43
44
    /**
45
     * @param \LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer
46
     */
47
    private function buildOwnContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer)
48
    {
49
        $ownCredential = $this->buildOwnCredential();
50
        $ownEntityDescriptorProvider = $this->buildOwnEntityDescriptorProvider($ownCredential->getCertificate());
51
52
        $buildContainer->getPimple()->register(
53
            new \LightSaml\Bridge\Pimple\Container\Factory\OwnContainerProvider(
54
                $ownEntityDescriptorProvider,
55
                [$ownCredential]
56
            )
57
        );
58
    }
59
60
    /**
61
     * @param \LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer
62
     */
63
    private function buildSystemContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer)
64
    {
65
        $buildContainer->getPimple()->register(new \LightSaml\Bridge\Pimple\Container\Factory\SystemContainerProvider());
66
67
        $pimple = $buildContainer->getPimple();
68
        $pimple[\LightSaml\Bridge\Pimple\Container\SystemContainer::LOGGER] = function () {
69
            return $this->buildLogger();
70
71
        };
72
        $pimple[\LightSaml\Bridge\Pimple\Container\SystemContainer::SESSION] = function () {
73
            return $this->buildSession();
74
75
        };
76
    }
77
78
    /**
79
     * @param \LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer
80
     */
81
    private function buildPartyContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer)
82
    {
83
        $buildContainer->getPimple()->register(new \LightSaml\Bridge\Pimple\Container\Factory\PartyContainerProvider());
84
85
        $pimple = $buildContainer->getPimple();
86
        $pimple[\LightSaml\Bridge\Pimple\Container\PartyContainer::SP_ENTITY_DESCRIPTOR] = function () {
87
            return $this->buildSpEntityStore();
88
        };
89
        $pimple[\LightSaml\Bridge\Pimple\Container\PartyContainer::TRUST_OPTIONS_STORE] = function () {
90
            $trustOptions = new \LightSaml\Meta\TrustOptions\TrustOptions();
91
92
            return new \LightSaml\Store\TrustOptions\FixedTrustOptionsStore($trustOptions);
93
        };
94
    }
95
96
    /**
97
     * @param \LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer
98
     */
99
    private function buildStoreContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer)
100
    {
101
        $buildContainer->getPimple()->register(
102
            new \LightSaml\Bridge\Pimple\Container\Factory\StoreContainerProvider(
103
                $buildContainer->getSystemContainer()
104
            )
105
        );
106
    }
107
108
    /**
109
     * @param \LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer
110
     */
111
    private function buildProviderContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer)
112
    {
113
        $buildContainer->getPimple()->register(
114
            new \LightSaml\Bridge\Pimple\Container\Factory\ProviderContainerProvider()
115
        );
116
117
        $pimple = $buildContainer->getPimple();
118
        $pimple[\LightSaml\Bridge\Pimple\Container\ProviderContainer::ATTRIBUTE_VALUE_PROVIDER] = function () {
119
            return (new \LightSaml\Provider\Attribute\FixedAttributeValueProvider())
120
                ->add(new \LightSaml\Model\Assertion\Attribute(
121
                    \LightSaml\ClaimTypes::COMMON_NAME,
122
                    'common-name'
123
                ))
124
                ->add(new \LightSaml\Model\Assertion\Attribute(
125
                    \LightSaml\ClaimTypes::GIVEN_NAME,
126
                    'first'
127
                ))
128
                ->add(new \LightSaml\Model\Assertion\Attribute(
129
                    \LightSaml\ClaimTypes::SURNAME,
130
                    'last'
131
                ))
132
                ->add(new \LightSaml\Model\Assertion\Attribute(
133
                    \LightSaml\ClaimTypes::EMAIL_ADDRESS,
134
                    '[email protected]'
135
                ));
136
137
        };
138
139
        $pimple[\LightSaml\Bridge\Pimple\Container\ProviderContainer::SESSION_INFO_PROVIDER] = function () {
140
            return new \LightSaml\Provider\Session\FixedSessionInfoProvider(
141
                time() - 600,
142
                'session-index',
143
                \LightSaml\SamlConstants::AUTHN_CONTEXT_PASSWORD_PROTECTED_TRANSPORT
144
            );
145
        };
146
147
        $pimple[\LightSaml\Bridge\Pimple\Container\ProviderContainer::NAME_ID_PROVIDER] = function () use ($buildContainer) {
148
            $nameId = new \LightSaml\Model\Assertion\NameID('[email protected]');
149
            $nameId
150
                ->setFormat(\LightSaml\SamlConstants::NAME_ID_FORMAT_EMAIL)
151
                ->setNameQualifier($buildContainer->getOwnContainer()->getOwnEntityDescriptorProvider()->get()->getEntityID())
152
            ;
153
154
            return new \LightSaml\Provider\NameID\FixedNameIdProvider($nameId);
155
        };
156
    }
157
158
    /**
159
     * @param \LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer
160
     */
161
    private function buildCredentialContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer)
162
    {
163
        $buildContainer->getPimple()->register(
164
            new \LightSaml\Bridge\Pimple\Container\Factory\CredentialContainerProvider(
165
                $buildContainer->getPartyContainer(),
166
                $buildContainer->getOwnContainer()
167
            )
168
        );
169
    }
170
171
    /**
172
     * @param \LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer
173
     */
174
    private function buildServiceContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer)
175
    {
176
        $buildContainer->getPimple()->register(
177
            new \LightSaml\Bridge\Pimple\Container\Factory\ServiceContainerProvider(
178
                $buildContainer->getCredentialContainer(),
179
                $buildContainer->getStoreContainer(),
180
                $buildContainer->getSystemContainer()
181
            )
182
        );
183
    }
184
185
    /**
186
     * @return \Symfony\Component\HttpFoundation\Session\Session
187
     */
188
    private function buildSession()
189
    {
190
        $session = new \Symfony\Component\HttpFoundation\Session\Session();
191
        $session->setName('PHPSIDIDP');
192
        $session->start();
193
194
        return $session;
195
    }
196
197
    /**
198
     * @return \LightSaml\Credential\X509Credential
199
     */
200
    private function buildOwnCredential()
201
    {
202
        $ownCredential = new \LightSaml\Credential\X509Credential(
203
            (new \LightSaml\Credential\X509Certificate())
204
                ->loadPem(file_get_contents(__DIR__.'/saml.crt')),
205
            \LightSaml\Credential\KeyHelper::createPrivateKey(__DIR__.'/saml.key', null, true)
206
        );
207
        $ownCredential
208
            ->setEntityId(self::OWN_ENTITY_ID)
209
        ;
210
211
        return $ownCredential;
212
    }
213
214
    /**
215
     * @param \LightSaml\Credential\X509Certificate $certificate
216
     *
217
     * @return \LightSaml\Provider\EntityDescriptor\EntityDescriptorProviderInterface
218
     */
219
    private function buildOwnEntityDescriptorProvider(\LightSaml\Credential\X509Certificate $certificate)
220
    {
221
        return new \LightSaml\Builder\EntityDescriptor\SimpleEntityDescriptorBuilder(
222
            self::OWN_ENTITY_ID,
223
            null,
224
            'https://localhost/lightsaml/lightSAML-IDP/web/idp/login.php',
225
            $certificate
226
        );
227
    }
228
229
    /**
230
     * @return \LightSaml\Store\EntityDescriptor\FixedEntityDescriptorStore
231
     */
232
    private function buildSpEntityStore()
233
    {
234
        $idpProvider = new \LightSaml\Store\EntityDescriptor\FixedEntityDescriptorStore();
235
        $idpProvider->add(
236
            \LightSaml\Model\Metadata\EntityDescriptor::load(__DIR__.'/localhost-lightsaml-demosp.xml')
237
        );
238
        $idpProvider->add(
239
            \LightSaml\Model\Metadata\EntityDescriptor::load(__DIR__.'/localhost-lightsaml-lightsaml.xml')
240
        );
241
242
        return $idpProvider;
243
    }
244
245
    /**
246
     * @return \Monolog\Logger
247
     */
248
    private function buildLogger()
249
    {
250
        $logger = new \Monolog\Logger('lightsaml', array(new \Monolog\Handler\StreamHandler(__DIR__.'/idp.log')));
251
252
        return $logger;
253
    }
254
}
255