lightningnetwork / lightning-onion

Onion Routed Micropayments for the Lightning Network
MIT License
397 stars 126 forks source link

fix: Racy shared secret storage. #1

Closed cdecker closed 7 years ago

cdecker commented 7 years ago

Fixed a minor bug in how we were storing shared secrets we already saw. We were checking for old secrets, then releasing all locks to check the MAC and then inserting the secret into the map. If we received a duplicate message while we were checking the MAC we could be tricked into processing the package twice. Adding an additional check after checking the MAC seems like a good tradeoff between speed and safety.