VYPR
Moderate severityNVD Advisory· Published Dec 22, 2023· Updated Aug 2, 2024

Potential URI resolution path traversal in the AWS SDK for PHP

CVE-2023-51651

Description

AWS SDK for PHP is the Amazon Web Services software development kit for PHP. Within the scope of requests to S3 object keys and/or prefixes containing a Unix double-dot, a URI path traversal is possible. The issue exists in the buildEndpoint method in the RestSerializer component of the AWS SDK for PHP v3 prior to 3.288.1. The buildEndpoint method relies on the Guzzle Psr7 UriResolver utility, which strips dot segments from the request path in accordance with RFC 3986. Under certain conditions, this could lead to an arbitrary object being accessed. This issue has been patched in version 3.288.1.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
aws/aws-sdk-phpPackagist
< 3.288.13.288.1

Affected products

1

Patches

1
aebc9f801438

bugfix: dot segment handling (#2835)

https://github.com/aws/aws-sdk-phpSean O'BrienNov 22, 2023via ghsa
3 files changed · +69 2
  • .changes/nextrelease/s3-dot-segment.json+7 0 added
    @@ -0,0 +1,7 @@
    +[
    +  {
    +    "type": "bugfix",
    +    "category": "s3",
    +    "description": "Disables transformation of request URI paths with dot segments"
    +  }
    +]
    
  • src/Api/Serializer/RestSerializer.php+9 2 modified
    @@ -242,14 +242,21 @@ function (array $matches) use ($varDefinitions) {
                     $path = rtrim($path, '/');
                 }
                 $relative = $path . $relative;
    +
    +            if (strpos($relative, '../') !== false) {
    +                if ($relative[0] !== '/') {
    +                    $relative = '/' . $relative;
    +                }
    +                return new Uri($this->endpoint . $relative);
    +            }
             }
             // If endpoint has path, remove leading '/' to preserve URI resolution.
             if ($path && $relative[0] === '/') {
                 $relative = substr($relative, 1);
             }
     
    -        //Append path to endpoint when leading '//...' present
    -        // as uri cannot be properly resolved
    +        //Append path to endpoint when leading '//...'
    +        // present as uri cannot be properly resolved
             if ($this->api->isModifiedModel()
                 && strpos($relative, '//') === 0
             ) {
    
  • tests/S3/S3ClientTest.php+53 0 modified
    @@ -2321,4 +2321,57 @@ public function testDoesNotComputeMD5($options, $operation)
             );
             $s3->execute($command);
         }
    +
    +    /**
    +     * @dataProvider dotSegmentProvider
    +     */
    +    public function testHandlesDotSegmentsInKey($key, $expectedUri)
    +    {
    +        $s3 = $this->getTestClient('s3');
    +        $this->addMockResults($s3, [[]]);
    +        $command = $s3->getCommand('getObject', ['Bucket' => 'foo', 'Key' => $key]);
    +        $command->getHandlerList()->appendSign(
    +            Middleware::tap(function ($cmd, $req) use ($expectedUri) {
    +                $this->assertSame($expectedUri, (string) $req->getUri());
    +            })
    +        );
    +        $s3->execute($command);
    +    }
    +
    +    public function dotSegmentProvider()
    +    {
    +        return [
    +            ['../foo' , 'https://foo.s3.amazonaws.com/../foo'],
    +            ['bar/../../foo', 'https://foo.s3.amazonaws.com/bar/../../foo'],
    +            ['/../foo', 'https://foo.s3.amazonaws.com//../foo'],
    +            ['foo/bar/../baz', 'https://foo.s3.amazonaws.com/foo/bar/../baz']
    +        ];
    +    }
    +
    +    /**
    +     * @dataProvider dotSegmentPathStyleProvider
    +     */
    +    public function testHandlesDotSegmentsInKeyWithPathStyle($key, $expectedUri)
    +    {
    +        $s3 = $this->getTestClient('s3', ['use_path_style_endpoint' => true]);
    +        $this->addMockResults($s3, [[]]);
    +        $command = $s3->getCommand('getObject', ['Bucket' => 'foo', 'Key' => $key]);
    +        $command->getHandlerList()->appendSign(
    +            Middleware::tap(function ($cmd, $req) use ($expectedUri) {
    +                $this->assertSame($expectedUri, (string) $req->getUri());
    +            })
    +        );
    +        $s3->execute($command);
    +    }
    +
    +    public function dotSegmentPathStyleProvider()
    +    {
    +        return [
    +            ['../foo' , 'https://s3.amazonaws.com/foo/foo/../foo'],
    +            ['bar/../../foo', 'https://s3.amazonaws.com/foo/foo/bar/../../foo'],
    +            ['/../foo', 'https://s3.amazonaws.com/foo/foo//../foo'],
    +            ['foo/bar/../baz', 'https://s3.amazonaws.com/foo/foo/foo/bar/../baz'],
    +        ];
    +    }
    +
     }
    

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

6

News mentions

0

No linked articles in our index yet.