The analysis of the security advisory and the associated patch commit c76c5ad0dc9de1c966443bd946fafc6351f87587 clearly indicates that the RSASHA1Algorithm and RSASHA256Algorithm contracts were vulnerable to RSA signature forgery. The vulnerability stemmed from the improper verification of the PKCS#1 v1.5 padding in the verify functions of these contracts.
The original code recovered the signed message and only checked if the message ended with the expected hash (SHA1 or SHA256). It did not verify the padding bytes, which is a critical step in preventing signature forgery attacks like the one described by Bleichenbacher in 2006.
The patch addresses this by introducing a new library, RSAPKCS1Verify.sol, which includes a function recoverAndVerify. This new function explicitly checks for the correct PKCS#1 v1.5 padding structure (0x00 0x01 [0xFF padding] 0x00 [DigestInfo] [Hash]). The verify functions in both RSASHA1Algorithm.sol and RSASHA256Algorithm.sol were updated to use this new library, thus mitigating the vulnerability.
The addition of the test file TestRSAForgedSignature.test.ts further confirms the vulnerability and the effectiveness of the patch by simulating the attack and asserting that the forged signature is correctly rejected by the patched code.