URL Validation Flaw in PHP Packages: CVE-2021-21705

php5 Updated 02 Oct 2025

Summary

02/07/2021
N/A
Yes i
Medium
5.3

UBUNTU-CVE-2021-21705: In PHP versions 7.3.x below 7.3.29, 7.4.x below 7.4.21 and 8.0.x below 8.0.8, when using URL validation functionality via filter_var() function with FILTER_VALIDATE_URL parameter, an URL with invalid password field can b... Affects php5 versions < 5.5.9+dfsg-1ubuntu4.29+esm14. Fixed in 5.5.9+dfsg-1ubuntu4.29+esm14. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

PHP is a widely-used open-source scripting language designed for web development but also used as a general-purpose programming language. It is known for its ease of use, flexibility, and extensive community support. The affected packages include various PHP versions (5, 7.0, 7.2, 7.4) that are integral to running web applications. This vulnerability allows for improper URL validation, which can lead to security risks.

Vulnerability Detail

In PHP versions 7.3.x below 7.3.29, 7.4.x below 7.4.21, and 8.0.x below 8.0.8, the filter_var() function with the FILTER_VALIDATE_URL parameter can incorrectly accept URLs with invalid password fields as valid. This flaw can lead to incorrect URL parsing, potentially causing the application to contact the wrong server or make erroneous access decisions, thereby exposing sensitive data or allowing unauthorized access.

How To Fix

Minimum fixed version

5.5.9+dfsg-1ubuntu4.29+esm14

This is the first release that contains the fix.

sudo apt-get install --only-upgrade php5

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, avoid using the filter_var() function for URL validation until the package is updated. Instead, implement custom validation logic that checks for valid URL formats without relying on the flawed function.

Conclusion

CVE-2021-21705 presents a significant risk to PHP applications due to improper URL validation. It is crucial to update affected PHP packages to their patched versions to mitigate this vulnerability. Additionally, temporary workarounds should be implemented until updates are applied.

See every vulnerability recorded for php5 →

Share this vulnerability

FAQ

CVE-2021-21705 is a vulnerability in PHP that allows invalid URLs to be accepted by the filter_var() function, leading to potential security risks.

The affected versions include PHP 7.3.x below 7.3.29, 7.4.x below 7.4.21, and 8.0.x below 8.0.8.

The vulnerability can lead to incorrect URL parsing, which may result in contacting the wrong server or making unauthorized access decisions.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without requiring any signup.

The CVSS score for CVE-2021-21705 is 5.3, indicating a medium severity level.

Related vulnerabilities

Recent vulnerabilities recorded for php5.

How To Fix

Minimum fixed version

5.5.9+dfsg-1ubuntu4.29+esm14

This is the first release that contains the fix.

sudo apt-get install --only-upgrade php5

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback