Issues (581)

Security Analysis    no request data  

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/XML/wsp/PolicyReference.php (1 issue)

Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\WSSecurity\XML\wsp;
6
7
use DOMElement;
8
use SimpleSAML\WSSecurity\Assert\Assert;
9
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10
use SimpleSAML\XML\Exception\SchemaViolationException;
11
use SimpleSAML\XML\ExtendableAttributesTrait;
12
use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait};
13
use SimpleSAML\XML\XsNamespace as NS;
14
15
use function str_replace;
16
17
/**
18
 * Class defining the PolicyReference element
19
 *
20
 * @package simplesamlphp/ws-security
21
 */
22
final class PolicyReference extends AbstractWspElement implements SchemaValidatableElementInterface
23
{
24
    use ExtendableAttributesTrait;
25
    use SchemaValidatableElementTrait;
0 ignored issues
show
The trait SimpleSAML\XML\SchemaValidatableElementTrait requires some properties which are not provided by SimpleSAML\WSSecurity\XML\wsp\PolicyReference: $message, $line
Loading history...
26
27
    /** The namespace-attribute for the xs:anyAttribute element */
28
    public const XS_ANY_ATTR_NAMESPACE = NS::ANY;
29
30
31
    /**
32
     * Initialize a wsp:PolicyReference
33
     *
34
     * @param string $URI
35
     * @param string|null $Digest
36
     * @param string $DigestAlgorithm
37
     * @param \SimpleSAML\XML\Attribute[] $namespacedAttributes
38
     */
39
    public function __construct(
40
        protected string $URI,
41
        protected ?string $Digest = null,
42
        protected ?string $DigestAlgorithm = 'http://schemas.xmlsoap.org/ws/2004/09/policy/Sha1Exc',
43
        array $namespacedAttributes = [],
44
    ) {
45
        Assert::validURI($URI, SchemaViolationException::class);
46
        Assert::nullOrValidBase64($Digest, SchemaViolationException::class);
47
        Assert::nullOrValidURI($DigestAlgorithm, SchemaViolationException::class);
48
49
        $this->setAttributesNS($namespacedAttributes);
50
    }
51
52
53
    /**
54
     * @return string
55
     */
56
    public function getURI(): string
57
    {
58
        return $this->URI;
59
    }
60
61
62
    /**
63
     * @return string|null
64
     */
65
    public function getDigest(): ?string
66
    {
67
        return $this->Digest ? str_replace(["\f", "\r", "\n", "\t", "\v", ' '], '', $this->Digest) : null;
68
    }
69
70
71
    /**
72
     * @return string|null
73
     */
74
    public function getDigestAlgorithm(): ?string
75
    {
76
        return $this->DigestAlgorithm;
77
    }
78
79
80
    /*
81
     * Convert XML into an wsp:PolicyReference element
82
     *
83
     * @param \DOMElement $xml The XML element we should load
84
     * @return static
85
     *
86
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
87
     *   If the qualified name of the supplied element is wrong
88
     */
89
    public static function fromXML(DOMElement $xml): static
90
    {
91
        Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
92
        Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
93
94
        $namespacedAttributes = self::getAttributesNSFromXML($xml);
95
        foreach ($namespacedAttributes as $i => $attr) {
96
            if ($attr->getNamespaceURI() === null) {
97
                if ($attr->getAttrName() === 'URI') {
98
                    unset($namespacedAttributes[$i]);
99
                    continue;
100
                } elseif ($attr->getAttrName() === 'Digest') {
101
                    unset($namespacedAttributes[$i]);
102
                    continue;
103
                } elseif ($attr->getAttrName() === 'DigestAlgorithm') {
104
                    unset($namespacedAttributes[$i]);
105
                    continue;
106
                }
107
            }
108
        }
109
110
        return new static(
111
            self::getAttribute($xml, 'URI'),
112
            self::getOptionalAttribute($xml, 'Digest', null),
113
            self::getOptionalAttribute($xml, 'DigestAlgorithm', null),
114
            $namespacedAttributes,
115
        );
116
    }
117
118
119
    /**
120
     * Convert this wsp:PolicyReference to XML.
121
     *
122
     * @param \DOMElement|null $parent The element we should add this wsp:Policy to
123
     * @return \DOMElement This wsp:PolicyReference element.
124
     */
125
    public function toXML(?DOMElement $parent = null): DOMElement
126
    {
127
        $e = $this->instantiateParentElement($parent);
128
        $e->setAttribute('URI', $this->getURI());
129
130
        if ($this->getDigest() !== null) {
131
            $e->setAttribute('Digest', $this->getDigest());
132
        }
133
134
        if ($this->getDigestAlgorithm() !== null) {
135
            $e->setAttribute('DigestAlgorithm', $this->getDigestAlgorithm());
136
        }
137
138
        foreach ($this->getAttributesNS() as $attr) {
139
            $attr->toXML($e);
140
        }
141
142
        return $e;
143
    }
144
}
145