nextcloud/tests/lib/Security
Anna Larch c0b57cd298 fix(security): don't propagate ValueError from Crypto::decrypt() fallback
When decrypting a v3 ciphertext with a mismatched secret, the first
attempt throws an Exception (HMAC mismatch). The fallback then calls
decryptWithoutSecret() with an empty string, which causes hash_hkdf()
to throw a ValueError. Since ValueError extends \Error rather than
\Exception, it bypassed the catch block and propagated as an unhandled
error, crashing the whole request.

Wrap the fallback in its own try/catch(\Throwable) and rethrow the
original Exception so callers get a meaningful HMAC mismatch error.

Signed-off-by: Anna Larch <anna@nextcloud.com>
AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 13:15:27 +00:00
..
Bruteforce chore: add missing Override attribute to test files 2026-04-28 21:29:28 +02:00
CSP chore: add missing Override attribute to test files 2026-04-28 21:29:28 +02:00
CSRF chore: add missing Override attribute to test files 2026-04-28 21:29:28 +02:00
Events refactor: Add void return type to PHPUnit test methods 2024-09-15 22:32:31 +02:00
FeaturePolicy chore: add missing Override attribute to test files 2026-04-28 21:29:28 +02:00
IdentityProof chore: add missing Override attribute to test files 2026-04-28 21:29:28 +02:00
Ip chore: add missing Override attribute to test files 2026-04-28 21:29:28 +02:00
Normalizer chore: run rector 2025-07-01 22:45:52 +02:00
RateLimiting chore: add missing Override attribute to test files 2026-04-28 21:29:28 +02:00
VerificationToken chore: add missing Override attribute to test files 2026-04-28 21:29:28 +02:00
CertificateManagerTest.php chore: add missing Override attribute to test files 2026-04-28 21:29:28 +02:00
CertificateTest.php chore: add missing Override attribute to test files 2026-04-28 21:29:28 +02:00
CredentialsManagerTest.php refactor: apply rector rules for PHPUnit 10 2025-10-27 21:56:04 +01:00
CryptoTest.php fix(security): don't propagate ValueError from Crypto::decrypt() fallback 2026-06-09 13:15:27 +00:00
HasherTest.php chore: add missing Override attribute to test files 2026-04-28 21:29:28 +02:00
RemoteHostValidatorIntegrationTest.php chore: add missing Override attribute to test files 2026-04-28 21:29:28 +02:00
RemoteHostValidatorTest.php chore: add missing Override attribute to test files 2026-04-28 21:29:28 +02:00
SecureRandomTest.php chore: add missing Override attribute to test files 2026-04-28 21:29:28 +02:00
TrustedDomainHelperTest.php chore: add missing Override attribute to test files 2026-04-28 21:29:28 +02:00