Skip to content
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

remove Debug from SessionRecord #472

Closed
wants to merge 1 commit into from

Conversation

cosmicexplorer
Copy link
Contributor

@cosmicexplorer cosmicexplorer commented Jun 27, 2022

  1. SessionRecord impls Debug, but it's not used anywhere. This removes that.
  2. PrivateKey is given a Debug impl which avoids leaking any useful data or making elliptic curve computations.

cosmicexplorer added a commit to cosmicexplorer/libsignal that referenced this pull request Jul 18, 2022
- that allows clients of this library to avoid having to reimplement Debug for the complex in-memory
  stores if they produce their own wrappers around those stores and want to Debug those
cosmicexplorer added a commit to cosmicexplorer/libsignal that referenced this pull request Jul 19, 2022
- that allows clients of this library to avoid having to reimplement Debug for the complex in-memory
  stores if they produce their own wrappers around those stores and want to Debug those
cosmicexplorer added a commit to cosmicexplorer/libsignal that referenced this pull request Jul 19, 2022
- that allows clients of this library to avoid having to reimplement Debug for the complex in-memory
  stores if they produce their own wrappers around those stores and want to Debug those
Copy link
Contributor

@jrose-signal jrose-signal left a comment

Choose a reason for hiding this comment

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

Hm. I feel weird about making these Debug because I feel like logging them can leak more information than you might intend. But I guess if that were really true then SessionRecord shouldn't be Debug in the first place, and it is, so okay.

rust/protocol/src/curve.rs Outdated Show resolved Hide resolved
cosmicexplorer added a commit to cosmicexplorer/libsignal that referenced this pull request Sep 9, 2022
- that allows clients of this library to avoid having to reimplement Debug for the complex in-memory
  stores if they produce their own wrappers around those stores and want to Debug those
cosmicexplorer added a commit to cosmicexplorer/libsignal that referenced this pull request Sep 9, 2022
- that allows clients of this library to avoid having to reimplement Debug for the complex in-memory
  stores if they produce their own wrappers around those stores and want to Debug those
cosmicexplorer added a commit to cosmicexplorer/libsignal that referenced this pull request Sep 9, 2022
- also add a cheap Debug impl for PrivateKey which leaks no info
cosmicexplorer added a commit to cosmicexplorer/libsignal that referenced this pull request Sep 9, 2022
- also add a cheap Debug impl for PrivateKey which leaks no info
@cosmicexplorer
Copy link
Contributor Author

I feel like logging them can leak more information than you might intend

I think this is a very reasonable concern. The best argument in favor I can think of is that if we define a canonical Debug here (and we take precautions like not printing private key contents), then it's perhaps less likely anyone will later feel the need to define an ad-hoc debug printing method later which might not take those precautions?

But to take a step back, this change in particular was motivated by me wanting to be able to more easily debug tests for my own code, a CLI tool which depends on libsignal-protocol and e.g. serializes those in-memory stores to files on disk. That use case is definitely not what Signal is concerned with, so if your gut is feeling weird about adding this, I would recommend we close this, since it's not very difficult for me to add a debug formatting method for my own purposes.

But I guess if that were really true then SessionRecord shouldn't be Debug in the first place, and it is, so okay.

It actually looks like removing Debug from SessionRecord causes no compile issues, so after convincing myself with the above argument I've actually modified this change to simply remove Debug from it! I've kept the PrivateKey debug impl though, with a comment that calculating the public key equivalent isn't free.

@cosmicexplorer cosmicexplorer changed the title make crypto entities and the in-memory stores impl Debug remove Debug from SessionRecord Sep 9, 2022
@jrose-signal
Copy link
Contributor

Hm, if we're trending that way then I'd say PrivateKey doesn't need it either, since you can always ask for the key_type. (I'm thinking about a user looking at generated API docs and seeing that PrivateKey implements Debug, but then trying it and realizing it doesn't tell them anything useful.) What do you think?

- also add a cheap Debug impl for PrivateKey which leaks no info
@cosmicexplorer
Copy link
Contributor Author

(I'm thinking about a user looking at generated API docs and seeing that PrivateKey implements Debug, but then trying it and realizing it doesn't tell them anything useful.)

This is a very useful framing to evaluate these docs changes in, and I agree that it would be more confusing than helpful. I have removed the Debug impl for PrivateKey.

Copy link
Contributor

@jrose-signal jrose-signal left a comment

Choose a reason for hiding this comment

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

Handling the cherry-pick now, but note that it's showing up as "unverified" in GitHub because I can't re-sign the commit with your key. I could remove you as a commit author, or you could turn off "vigilant mode", or we could leave it "unverified".

@cosmicexplorer
Copy link
Contributor Author

Hm, that's a strange little quirk. I have turned off "vigilant mode" now, as it is rarely needed. Please let me know if that lets you cherry-pick it without any smudges.

@cosmicexplorer
Copy link
Contributor Author

Ping! I think this should be good to merge? Please feel free to edit the commit (including removing my authorship) if that is needed to safely merge.

@jrose-signal
Copy link
Contributor

Sorry, it's in the private branch and will be in the next release! But we haven't had anything to drive a release just yet. I'll close this when the release happens and I can put the cherry-picked commit hash here.

@cosmicexplorer
Copy link
Contributor Author

Great, thanks!

@jrose-signal jrose-signal added the awaiting release Will be in the next release of libsignal label Nov 29, 2022
moiseev-signal pushed a commit that referenced this pull request Feb 4, 2023
- also add a cheap Debug impl for PrivateKey which leaks no info
@jrose-signal
Copy link
Contributor

Released in v0.22.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting release Will be in the next release of libsignal
Development

Successfully merging this pull request may close these issues.

2 participants