Exploit databaseDownload repository ZIP
GH-8c7f0e4b0e998904a1d6f7dcd99e3e7d
d-xuan/cve-2024-52510
Sources for CVE-2024-52510
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files3
d-xuan/cve-2024-52510Revision 6c0d89756ae0
- ↑..Parent directory
- CertificateChainValidator.php
- CertificateToolbox.php
- PhpCertificateChainValidator.php
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
3rdparty/web-auth/metadata-service/src/CertificateChain/CertificateToolbox.php
PHP · 1,998 bytes<?php
declare(strict_types=1);
namespace Webauthn\MetadataService\CertificateChain;
use ParagonIE\ConstantTime\Base64;
use function preg_replace;
use const PHP_EOL;
class CertificateToolbox
{
private const PEM_HEADER = '-----BEGIN ';
private const PEM_FOOTER = '-----END ';
/**
* @param string[] $data
*
* @return string[]
*/
public static function fixPEMStructures(array $data, string $type = 'CERTIFICATE'): array
{
return array_map(static fn ($d): string => self::fixPEMStructure($d, $type), $data);
}
public static function fixPEMStructure(string $data, string $type = 'CERTIFICATE'): string
{
if (str_contains($data, self::PEM_HEADER)) {
return trim($data);
}
$pem = self::PEM_HEADER . $type . '-----' . PHP_EOL;
$pem .= chunk_split($data, 64, PHP_EOL);
return $pem . (self::PEM_FOOTER . $type . '-----' . PHP_EOL);
}
/**
* @deprecated since 4.7.0 and will be removed in 5.0.0. No replacement as not used internally.
* @infection-ignore-all
*/
public static function convertPEMToDER(string $data): string
{
if (! str_contains($data, self::PEM_HEADER)) {
return $data;
}
$data = preg_replace('/\-{5}.*\-{5}[\r\n]*/', '', $data);
$data = preg_replace("/[\r\n]*/", '', (string) $data);
return Base64::decode(trim((string) $data), true);
}
public static function convertDERToPEM(string $data, string $type = 'CERTIFICATE'): string
{
if (str_contains($data, self::PEM_HEADER)) {
return $data;
}
return self::fixPEMStructure(base64_encode($data), $type);
}
/**
* @param string[] $data
*
* @return string[]
*/
public static function convertAllDERToPEM(iterable $data, string $type = 'CERTIFICATE'): array
{
return array_map(static fn ($d): string => self::convertDERToPEM($d, $type), $data);
}
}