Sicherheitsupdate nach Audit (0.29.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m50s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m34s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m45s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m30s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m7s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m9s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m8s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 6m5s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 48s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m5s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m50s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m34s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m45s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m30s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m7s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m9s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m8s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 6m5s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 48s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m5s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a37895a16a
commit
f1202bea08
226 changed files with 1952 additions and 450 deletions
|
|
@ -20,6 +20,36 @@ class WebPush
|
|||
{
|
||||
public const KEYS = 'push.vapid';
|
||||
|
||||
/**
|
||||
* Push-Dienste der Browser. Nur dorthin wird gesendet – sonst ließe sich der Server
|
||||
* über ein präpariertes Abonnement zu Anfragen an interne Adressen bewegen.
|
||||
*/
|
||||
public const SERVICE_HOSTS = [
|
||||
'fcm.googleapis.com', 'android.googleapis.com', // Chrome, Edge (Android), Opera, Samsung
|
||||
'*.push.services.mozilla.com', // Firefox
|
||||
'*.notify.windows.com', // Edge (Windows)
|
||||
'web.push.apple.com', '*.push.apple.com', // Safari, iOS
|
||||
];
|
||||
|
||||
public static function isAllowedEndpoint(string $endpoint): bool
|
||||
{
|
||||
$parts = parse_url($endpoint);
|
||||
|
||||
if (($parts['scheme'] ?? null) !== 'https' || ! isset($parts['host']) || isset($parts['user']) || isset($parts['port'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$host = strtolower($parts['host']);
|
||||
|
||||
foreach (self::SERVICE_HOSTS as $allowed) {
|
||||
if ($host === $allowed || (str_starts_with($allowed, '*.') && str_ends_with($host, substr($allowed, 1)))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Präfix einer DER-kodierten P-256-Public-Key-Struktur (SubjectPublicKeyInfo) vor dem 65-Byte-Punkt */
|
||||
private const P256_SPKI_PREFIX = '3059301306072a8648ce3d020106082a8648ce3d030107034200';
|
||||
|
||||
|
|
@ -43,10 +73,14 @@ class WebPush
|
|||
*/
|
||||
public function send(PushSubscription $subscription, array $payload): bool
|
||||
{
|
||||
if (! self::isAllowedEndpoint($subscription->endpoint)) {
|
||||
return false; // unbekannter Dienst – Abonnement wird entfernt
|
||||
}
|
||||
|
||||
$body = $this->encrypt((string) json_encode($payload, JSON_UNESCAPED_UNICODE), $subscription->public_key, $subscription->auth_token);
|
||||
$keys = $this->keys();
|
||||
|
||||
$response = Http::timeout(10)->withHeaders([
|
||||
$response = Http::timeout(10)->withoutRedirecting()->withHeaders([
|
||||
'Authorization' => 'vapid t='.$this->jwt($subscription->endpoint, $keys['private']).', k='.$keys['public'],
|
||||
'Content-Encoding' => 'aes128gcm',
|
||||
'Content-Type' => 'application/octet-stream',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue