Skip to content

Commit d49e93e

Browse files
committed
Convert hex hostname segments to decimals
1 parent 96c60d7 commit d49e93e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- The `utils/fix-field-layout-uids` command now checks for duplicate top-level field layout UUIDs. ([#18193](https://github.com/craftcms/cms/pull/18193))
66
- Fixed a bug where all plugin settings were being saved to the project config, rather than just posted settings. ([craftcms/commerce#4006](https://github.com/craftcms/commerce/issues/4006))
77
- Fixed a bug where custom selects could be positioned incorrectly after the window was resized. ([#18179](https://github.com/craftcms/cms/issues/18179))
8-
- Fixed an SSRF vulnerability. (GHSA-96pq-hxpw-rgh8)
8+
- Fixed SSRF vulnerabilities. (GHSA-96pq-hxpw-rgh8, GHSA-m5r2-8p9x-hp5m)
99
- Fixed a SQL injection vulnerability. (GHSA-2453-mppf-46cj)
1010

1111
## 4.16.17 - 2025-12-0421

src/gql/resolvers/mutations/Asset.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use GraphQL\Error\UserError;
2525
use GraphQL\Type\Definition\ResolveInfo;
2626
use GuzzleHttp\Client;
27+
use Illuminate\Support\Collection;
2728
use Throwable;
2829
use yii\base\Exception;
2930
use yii\base\InvalidArgumentException;
@@ -280,8 +281,20 @@ protected function handleUpload(AssetElement $asset, array $fileInformation): bo
280281

281282
private function validateHostname(string $url): bool
282283
{
283-
// make sure the hostname is alphanumeric and not an IP address
284284
$hostname = parse_url($url, PHP_URL_HOST);
285+
286+
// convert hex segments to decimal
287+
$hostname = Collection::make(explode('.', $hostname))
288+
->map(function(string $chunk) {
289+
if (str_starts_with($chunk, '0x')) {
290+
$octets = str_split(substr($chunk, 2), 2);
291+
return implode('.', array_map('hexdec', $octets));
292+
}
293+
return $chunk;
294+
})
295+
->join('.');
296+
297+
// make sure the hostname is alphanumeric and not an IP address
285298
if (
286299
!filter_var($hostname, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) ||
287300
filter_var($hostname, FILTER_VALIDATE_IP)

0 commit comments

Comments
 (0)