Skip to content

Simplify LSPS5/validator: drop time checks & custom signature storage #3961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

martinsaposnic
Copy link
Contributor

Remove timestamp validation, TimeProvider, SignatureStore trait and its InMemory implementation in favor of a fixed size signature cache. HTTPS already secures delivery, so a small cache is sufficient for basic replay protection.

pub const MAX_RECENT_SIGNATURES: usize = 5; -> I came up with the 5 number limit, not sure if we need more/less. Please comment your opinion on this

This is a planned follow up for the recently merged PR #3662, here is link with the discussion and motivation for this change #3662 (comment)

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jul 25, 2025

👋 Thanks for assigning @TheBlueMatt as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@martinsaposnic martinsaposnic mentioned this pull request Jul 24, 2025
14 tasks
@martinsaposnic
Copy link
Contributor Author

pub const MAX_RECENT_SIGNATURES: usize = 5; -> I came up with the 5 number limit, not sure if we need more/less. Please comment your opinion on this

thoughts? @tnull @TheBlueMatt

Copy link

codecov bot commented Jul 25, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.94%. Comparing base (55d8666) to head (dc97b9c).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
lightning-liquidity/src/lsps5/msgs.rs 0.00% 1 Missing ⚠️
lightning-liquidity/src/lsps5/validator.rs 94.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3961   +/-   ##
=======================================
  Coverage   88.93%   88.94%           
=======================================
  Files         174      174           
  Lines      123880   123835   -45     
  Branches   123880   123835   -45     
=======================================
- Hits       110176   110147   -29     
+ Misses      11251    11240   -11     
+ Partials     2453     2448    -5     
Flag Coverage Δ
fuzzing 22.61% <0.00%> (-0.01%) ⬇️
tests 88.77% <88.88%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@martinsaposnic martinsaposnic force-pushed the lsps5-validator-follow-up branch 3 times, most recently from a882fed to 2122b24 Compare July 25, 2025 17:33
TheBlueMatt
TheBlueMatt previously approved these changes Jul 25, 2025
@TheBlueMatt
Copy link
Collaborator

I'm a fan of this, and the code seems Obviously Correct (tm), but I'll let @tnull chime in in case he thinks there is some attack the more full-featured replay protection fixes.

@TheBlueMatt TheBlueMatt requested review from tnull and removed request for valentinewallace July 25, 2025 19:50
@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed elsewhere, concept ACK from my side. I'll actually also see to update the bLIP-55 PR to drop the mention of the timestamp header there.

That said, I'm a bit confused why we have a signature cache at all now? If we think TLS sufficiently protects against replaying packets, what additional protection does the cache give us? Especially, since the cache is of course easily gamed, as any adversary able to intercept and replay messages could now simply intercept 6 different messages and replay them in batches, ensuring that the cache lookup always misses?

@martinsaposnic
Copy link
Contributor Author

That said, I'm a bit confused why we have a signature cache at all now? If we think TLS sufficiently protects against replaying packets, what additional protection does the cache give us? Especially, since the cache is of course easily gamed, as any adversary able to intercept and replay messages could now simply intercept 6 different messages and replay them in batches, ensuring that the cache lookup always misses?

from what I remember from our convo a few weeks ago, the cache is mainly there to handle "accidental" replays from the LSP, e.g. the connection drops and the LSP doesn’t get the ACK, so it retries even though the notification actually landed. but yeah, I agree we could just drop those extra lines and keep things simpler. @TheBlueMatt what are your thoughts?

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independently from the discussion on whether we need to store signatures at all, this needs a rebase.

Remove timestamp validation, TimeProvider, SignatureStore trait
and its InMemory implementation in favor of a fixed size signature
cache. HTTPS already secures delivery, so a small cache is sufficient
for basic replay protection.
@martinsaposnic
Copy link
Contributor Author

this needs a rebase

done ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants