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
|
|
@ -53,11 +53,11 @@ class WebPushTest extends TestCase
|
|||
[$uaPrivate, $uaPublic, $auth] = $this->browserKeys();
|
||||
$user = User::factory()->create();
|
||||
$subscription = PushSubscription::query()->create([
|
||||
'user_id' => $user->id, 'endpoint' => 'https://push.example.org/send/abc', 'endpoint_hash' => hash('sha256', 'x'),
|
||||
'user_id' => $user->id, 'endpoint' => 'https://fcm.googleapis.com/fcm/send/abc', 'endpoint_hash' => hash('sha256', 'x'),
|
||||
'public_key' => $uaPublic, 'auth_token' => $auth,
|
||||
]);
|
||||
|
||||
Http::fake(['push.example.org/*' => Http::response('', 201)]);
|
||||
Http::fake(['fcm.googleapis.com/*' => Http::response('', 201)]);
|
||||
$push = app(WebPush::class);
|
||||
$this->assertTrue($push->send($subscription, ['title' => 'Freigabe', 'body' => 'Ümläute & mehr']));
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ class WebPushTest extends TestCase
|
|||
preg_match('/^vapid t=([^,]+), k=(.+)$/', $request->header('Authorization')[0], $m);
|
||||
$this->assertSame($push->publicKey(), $m[2]);
|
||||
[$header, $claims, $signature] = explode('.', $m[1]);
|
||||
$this->assertSame('https://push.example.org', json_decode(WebPush::base64UrlDecode($claims), true)['aud']);
|
||||
$this->assertSame('https://fcm.googleapis.com', json_decode(WebPush::base64UrlDecode($claims), true)['aud']);
|
||||
$raw = WebPush::base64UrlDecode($signature);
|
||||
$int = fn (string $v) => "\x02".chr(strlen($v = ltrim($v, "\0")) + (ord($v[0]) > 0x7F ? 1 : 0)).(ord($v[0]) > 0x7F ? "\0" : '').$v;
|
||||
$der = $int(substr($raw, 0, 32)).$int(substr($raw, 32));
|
||||
|
|
@ -89,13 +89,17 @@ class WebPushTest extends TestCase
|
|||
|
||||
$this->actingAs($user)->get('/')->assertInertia(fn ($page) => $page->where('push.key', app(WebPush::class)->publicKey()));
|
||||
$this->postJson('/push/abo', ['endpoint' => 'http://unsicher.example.org/x', 'keys' => ['p256dh' => $uaPublic, 'auth' => $auth]])->assertUnprocessable();
|
||||
$this->postJson('/push/abo', ['endpoint' => 'https://push.example.org/send/1', 'keys' => ['p256dh' => $uaPublic, 'auth' => $auth]])->assertOk();
|
||||
// Nur bekannte Push-Dienste – keine internen Adressen (SSRF)
|
||||
foreach (['https://10.0.0.5:8443/admin', 'https://127.0.0.1/x', 'https://fcm.googleapis.com.evil.test/x', 'https://evil.test/fcm.googleapis.com'] as $endpoint) {
|
||||
$this->postJson('/push/abo', ['endpoint' => $endpoint, 'keys' => ['p256dh' => $uaPublic, 'auth' => $auth]])->assertStatus(422);
|
||||
}
|
||||
$this->postJson('/push/abo', ['endpoint' => 'https://fcm.googleapis.com/fcm/send/1', 'keys' => ['p256dh' => $uaPublic, 'auth' => $auth]])->assertOk();
|
||||
$this->assertSame(1, PushSubscription::query()->where('user_id', $user->id)->count());
|
||||
|
||||
$user->notify(new PortalNotification('Beitrag freigegeben', '„Sommerfest“ ist online.', '/neuigkeiten/sommerfest'));
|
||||
Queue::assertPushed(SendWebPush::class, fn (SendWebPush $job) => $job->userId === $user->id && $job->payload['url'] === '/neuigkeiten/sommerfest');
|
||||
|
||||
$this->deleteJson('/push/abo', ['endpoint' => 'https://push.example.org/send/1'])->assertOk();
|
||||
$this->deleteJson('/push/abo', ['endpoint' => 'https://fcm.googleapis.com/fcm/send/1'])->assertOk();
|
||||
$this->assertSame(0, PushSubscription::query()->count());
|
||||
|
||||
// Ohne Abonnement: nur die Glocke
|
||||
|
|
@ -115,4 +119,13 @@ class WebPushTest extends TestCase
|
|||
|
||||
$this->assertSame(0, PushSubscription::query()->count());
|
||||
}
|
||||
|
||||
public function test_foreign_subscriptions_cannot_be_taken_over(): void
|
||||
{
|
||||
[, $uaPublic, $auth] = $this->browserKeys();
|
||||
$endpoint = 'https://fcm.googleapis.com/fcm/send/geraet-1';
|
||||
$this->actingAs(User::factory()->create())->postJson('/push/abo', ['endpoint' => $endpoint, 'keys' => ['p256dh' => $uaPublic, 'auth' => $auth]])->assertOk();
|
||||
|
||||
$this->actingAs(User::factory()->create())->postJson('/push/abo', ['endpoint' => $endpoint, 'keys' => ['p256dh' => $uaPublic, 'auth' => $auth]])->assertStatus(409);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue