GitHub Security Advisory: GHSA-6m5f-j7w2-w953
Package: wwbn/avideo (COMPOSER)
Severity: HIGH (CVSS 7.4)
CWE: CWE-326: Inadequate Encryption Strength
Vulnerable versions: <= 26.0
Patched in: unpatched

Summary: AVideo has a PGP 2FA Bypass via Cryptographically Broken 512-bit RSA Key Generation in LoginControl Plugin

Details:
## Summary

The `createKeys()` function in the LoginControl plugin's PGP 2FA system generates 512-bit RSA keys, which have been publicly factorable since 1999. An attacker who obtains a target user's public key can factor the 512-bit RSA modulus on commodity hardware in hours, derive the complete private key, and decrypt any PGP 2FA challenge issued by the system — completely bypassing the second authentication factor. Additionally, the `generateKeys.json.php` and `encryptMessage.json.php` endpoints lack any authentication checks, exposing CPU-intensive key generation to anonymous users.

## Details

The vulnerability originates in `plugin/LoginControl/pgp/functions.php` at line 26:

```php
// plugin/LoginControl/pgp/functions.php:26
$privateKey = RSA::createKey(512);
```

This code was copied from the `singpolyma/openpgp-php` library's example/demo code, which was never intended for production use. The entire PGP 2FA flow relies on these weak keys:

1. **Key generation**: When a user enables PGP 2FA, the UI calls `createKeys()` which generates a 512-bit RSA keypair. The public key is saved to the database via `savePublicKey.json.php`.

2. **Challenge creation** (`LoginControl.php:520-531`): During login, a `uniqid()` token is generated, stored in the session, and encrypted with the user's stored public key:
```php
// LoginControl.php:525-530
$_SESSION['user']['challenge']['text'] = uniqid();
$encMessage = self::encryptPGPMessage(User::getId(), $_SESSION['user']['challenge']['text']);
```

3. **Challenge verification** (`LoginControl.php:533-539`): The user must decrypt the challenge and submit the plaintext. Verification is a simple equality check:
```php
// LoginControl.php:534
if ($response == $_SESSION['user']['challenge']['text']) {
```

Since 512-bit RSA was publicly factored in 1999 (RSA-155 challenge), an attacker who obtains the public key can factor the modulus using freely available tools (CADO-NFS, msieve, yafu) in a matter of hours on modern hardware, reconstruct the complete private key from the prime factors, and decrypt any challenge encrypted with that key.

**Unauthenticated endpoints** (compounding issue):

`generateKeys.json.php` does not include `configuration.php` and has no authentication check:
```php
// plugin/LoginControl/pgp/generateKeys.json.php:1-2
<?php
require_once  '../../../plugin/LoginControl/pgp/functions.php';
```

Similarly, `encryptMessage.json.php` has no authentication. Both are accessible to anonymous users, enabling abuse of CPU-intensive RSA key generation for denial-of-service.

## PoC

**Step 1: Obtain the target user's 512-bit public key**

The public key must be obtained through a side channel (e.g., the user sharing it per PGP conventions, another vulnerability leaking database contents, or admin access). The key is stored in the `users_externalOptions` table under the key `PGPKey`.

**Step 2: Extract the RSA modulus from the public key**

```bash
# Extract the modulus from the PGP public key
echo "