VYPR
Moderate severityNVD Advisory· Published Dec 12, 2023· Updated May 22, 2025

php-svg-lib possible DoS caused by infinite recursion when parsing SVG document

CVE-2023-50251

Description

php-svg-lib is an SVG file parsing / rendering library. Prior to version 0.5.1, when parsing the attributes passed to a use tag inside an svg document, an attacker can cause the system to go to an infinite recursion. Depending on the system configuration and attack pattern this could exhaust the memory available to the executing process and/or to the server itself. An attacker sending multiple request to a system to render the above payload can potentially cause resource exhaustion to the point that the system is unable to handle incoming request. Version 0.5.1 contains a patch for this issue.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
phenx/php-svg-libPackagist
< 0.5.10.5.1

Affected products

1

Patches

1
88163cbe562d

Prevent circular reference in use elements

https://github.com/dompdf/php-svg-libBrian SweeneyNov 20, 2023via ghsa
1 file changed · +20 0
  • src/Svg/Tag/UseTag.php+20 0 modified
    @@ -14,12 +14,19 @@ class UseTag extends AbstractTag
         protected $y = 0;
         protected $width;
         protected $height;
    +    protected $instances = 0;
     
         /** @var AbstractTag */
         protected $reference;
     
         protected function before($attributes)
         {
    +        $this->instances++;
    +        if ($this->instances > 1) {
    +            //TODO: log circular reference error state
    +            return;
    +        }
    +
             if (isset($attributes['x'])) {
                 $this->x = $attributes['x'];
             }
    @@ -52,6 +59,9 @@ protected function before($attributes)
         }
     
         protected function after() {
    +        if ($this->instances > 0) {
    +            return;
    +        }
             parent::after();
     
             if ($this->reference) {
    @@ -63,6 +73,11 @@ protected function after() {
     
         public function handle($attributes)
         {
    +        if ($this->instances > 1) {
    +            //TODO: log circular reference error state
    +            return;
    +        }
    +
             parent::handle($attributes);
     
             if (!$this->reference) {
    @@ -87,6 +102,11 @@ public function handle($attributes)
     
         public function handleEnd()
         {
    +        $this->instances--;
    +        if ($this->instances > 0) {
    +            return;
    +        }
    +
             parent::handleEnd();
     
             if (!$this->reference) {
    

Vulnerability mechanics

Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

4

News mentions

0

No linked articles in our index yet.