Skip to content

Commit 3715eea

Browse files
authored
Fix/xmlsecuritykey type hardening (#286)
* Harden XMLSecEnc against PHP 8 null fatals Guard encrypt/decrypt and EncryptedKey construction against null DOM nodes and failed crypto returns; tighten PHPDoc and changelog. * Harden XMLSecurityKey types and null/false handling. Tighten cryptParams/key typing, fail closed on unreadable key files and oversized convertRSA input, and validate RSA/symmetric crypto results so static analysis and failure paths stay consistent. * Normalize decrypt exceptions and harden empty RSA ASN.1 input. Catch phpseclib throws on symmetric/RSA decrypt so failures always surface as Failure decrypting Data, and reject empty convertRSA inputs; add coverage for both. * Make decrypt-failure-uniform.phpt resilient to CI OpenSSL noise. Silence display errors and allow optional STDERR between assertions so PHPUnit PHPT runs do not fail when OpenSSL writes padding diagnostics. * Migrate phpunit.xml to the PHPUnit 9.6 configuration schema.
1 parent b11d713 commit 3715eea

5 files changed

Lines changed: 352 additions & 87 deletions

File tree

CHANGELOG.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ Security Improvements:
2727
DEFAULT_KEY_ALGORITHMS / DEFAULT_DATA_ALGORITHMS presets)
2828
- Use a single generic "Failure decrypting Data" error for all decryption
2929
failures (bad padding, cipher error, failed RSA unwrap) so callers cannot
30-
build a CBC padding oracle from distinguishable errors
30+
build a CBC padding oracle from distinguishable errors. Catch and normalize
31+
phpseclib throws (LengthException, BadDecryptionException, RuntimeException,
32+
etc.) on symmetric and RSA decrypt paths so exception type/message cannot
33+
form a ciphertext-validity oracle either.
3134
- Add verifyDocument(): safe-by-default signature verification that requires a
3235
caller-pinned key (never trusts KeyInfo), enforces a SignatureMethod/DigestMethod
3336
algorithm allowlist, fails closed on unvalidated references, and returns the

phpunit.xml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.5/phpunit.xsd">
2-
<filter>
3-
<whitelist addUncoveredFilesFromWhitelist="false">
1+
<?xml version="1.0"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd">
3+
<coverage includeUncoveredFiles="false">
4+
<include>
45
<directory suffix=".php">src</directory>
5-
</whitelist>
6-
</filter>
6+
</include>
7+
</coverage>
78
</phpunit>

0 commit comments

Comments
 (0)