VYPR
Low severityNVD Advisory· Published Nov 6, 2024· Updated Nov 3, 2025

Open redirect via browser-sanitized URLs in symfony/http-foundation

CVE-2024-50345

Description

symfony/http-foundation is a module for the Symphony PHP framework which defines an object-oriented layer for the HTTP specification. The Request class, does not parse URI with special characters the same way browsers do. As a result, an attacker can trick a validator relying on the Request class to redirect users to another domain. The Request::create methods now assert the URI does not contain invalid characters as defined by https://url.spec.whatwg.org/. This issue has been patched in versions 5.4.46, 6.4.14, and 7.1.7. Users are advised to upgrade. There are no known workarounds for this vulnerability.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
symfony/http-foundationPackagist
< 5.4.465.4.46
symfony/http-foundationPackagist
>= 6.0.0, < 6.4.146.4.14
symfony/http-foundationPackagist
>= 7.0.0, < 7.1.77.1.7

Affected products

1

Patches

1
5a9b08e5740a

[HttpFoundation] Reject URIs that contain invalid characters

https://github.com/symfony/symfonyNicolas GrekasOct 22, 2024via ghsa
2 files changed · +45 2
  • src/Symfony/Component/HttpFoundation/Request.php+17 0 modified
    @@ -11,6 +11,7 @@
     
     namespace Symfony\Component\HttpFoundation;
     
    +use Symfony\Component\HttpFoundation\Exception\BadRequestException;
     use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException;
     use Symfony\Component\HttpFoundation\Exception\JsonException;
     use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
    @@ -333,6 +334,8 @@ public static function createFromGlobals()
          * @param string|resource|null $content    The raw body data
          *
          * @return static
    +     *
    +     * @throws BadRequestException When the URI is invalid
          */
         public static function create(string $uri, string $method = 'GET', array $parameters = [], array $cookies = [], array $files = [], array $server = [], $content = null)
         {
    @@ -360,6 +363,20 @@ public static function create(string $uri, string $method = 'GET', array $parame
                 unset($components['fragment']);
             }
     
    +        if (false === $components) {
    +            throw new BadRequestException('Invalid URI.');
    +        }
    +
    +        if (false !== ($i = strpos($uri, '\\')) && $i < strcspn($uri, '?#')) {
    +            throw new BadRequestException('Invalid URI: A URI cannot contain a backslash.');
    +        }
    +        if (\strlen($uri) !== strcspn($uri, "\r\n\t")) {
    +            throw new BadRequestException('Invalid URI: A URI cannot contain CR/LF/TAB characters.');
    +        }
    +        if ('' !== $uri && (\ord($uri[0]) <= 32 || \ord($uri[-1]) <= 32)) {
    +            throw new BadRequestException('Invalid URI: A URI must not start nor end with ASCII control characters or spaces.');
    +        }
    +
             if (isset($components['host'])) {
                 $server['SERVER_NAME'] = $components['host'];
                 $server['HTTP_HOST'] = $components['host'];
    
  • src/Symfony/Component/HttpFoundation/Tests/RequestTest.php+28 2 modified
    @@ -13,6 +13,7 @@
     
     use PHPUnit\Framework\TestCase;
     use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
    +use Symfony\Component\HttpFoundation\Exception\BadRequestException;
     use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException;
     use Symfony\Component\HttpFoundation\Exception\JsonException;
     use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
    @@ -289,9 +290,34 @@ public function testCreateWithRequestUri()
             $this->assertTrue($request->isSecure());
     
             // Fragment should not be included in the URI
    -        $request = Request::create('http://test.com/foo#bar');
    -        $request->server->set('REQUEST_URI', 'http://test.com/foo#bar');
    +        $request = Request::create('http://test.com/foo#bar\\baz');
    +        $request->server->set('REQUEST_URI', 'http://test.com/foo#bar\\baz');
             $this->assertEquals('http://test.com/foo', $request->getUri());
    +
    +        $request = Request::create('http://test.com/foo?bar=f\\o');
    +        $this->assertEquals('http://test.com/foo?bar=f%5Co', $request->getUri());
    +        $this->assertEquals('/foo', $request->getPathInfo());
    +        $this->assertEquals('bar=f%5Co', $request->getQueryString());
    +    }
    +
    +    /**
    +     * @testWith ["http://foo.com\\bar"]
    +     *           ["\\\\foo.com/bar"]
    +     *           ["a\rb"]
    +     *           ["a\nb"]
    +     *           ["a\tb"]
    +     *           ["\u0000foo"]
    +     *           ["foo\u0000"]
    +     *           [" foo"]
    +     *           ["foo "]
    +     *           [":"]
    +     */
    +    public function testCreateWithBadRequestUri(string $uri)
    +    {
    +        $this->expectException(BadRequestException::class);
    +        $this->expectExceptionMessage('Invalid URI');
    +
    +        Request::create($uri);
         }
     
         /**
    

Vulnerability mechanics

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

References

9

News mentions

0

No linked articles in our index yet.