SFT-7491: keep authorization credentials out of the log - #58
Open
georgesFoundation wants to merge 1 commit into
Open
georgesFoundation wants to merge 1 commit into
georgesFoundation wants to merge 1 commit into
Conversation
send() wrote the whole serialized transmit buffer to the log at debug level, so mining.authorize put the pool user and password into ordinary diagnostic output (CWE-532). mining.submit repeats the user in every share, and pools echo it back at us: Public-Pool answers a failed authorization with [20, "...", ", <user>"]. Every frame the client logs now goes through Sensitivity::loggable, and it is that return value, never a buffer, that reaches a logging macro. The decision is made before the macro is invoked, so it holds for both backends fmt maps onto and at every level. send() takes the classification as a required argument rather than inferring it, so a new secret-bearing request cannot be added without someone choosing one. Classified secret: mining.authorize and mining.submit, plus any response matched to a pending one of those. Everything else is logged in full and documented in the crate docs as carrying no authorization parameter. Raw receive-buffer dumps are gone. A buffer, and a freshly read chunk, span an arbitrary number of frames, so at that point there is no way to tell whether one of them echoes a credential; the per-frame log covers the useful case and can be classified. The commented-out transmit-buffer dump is removed too rather than left as an invitation. Error::Pool is the one credential-adjacent value handed back rather than logged, since its message and detail are pool-chosen text that can echo the user. Documented on the variant. The regression test drives a full handshake with canary credentials and a capturing logger at trace level, and asserts neither canary nor any fragment appears. It caught the read-path chunk dump that reading the send path alone would have missed. defmt cannot be captured in a host test, so it is covered by construction plus unit tests pinning loggable. Adds a flake check so the log-gated test actually runs; the all-features checks have to exclude this crate.
|
The code changes are sane (although more complicated than warranted IMO), the tests are mostly unnecessary. Compare to the similar patch in keyos, and the upcoming policy that allows these data in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
send() wrote the whole serialized transmit buffer to the log at debug level, so mining.authorize put the pool user and password into ordinary diagnostic output (CWE-532). mining.submit repeats the user in every share, and pools echo it back at us: Public-Pool answers a failed authorization with [20, "...", ", "].
Every frame the client logs now goes through Sensitivity::loggable, and it is that return value, never a buffer, that reaches a logging macro. The decision is made before the macro is invoked, so it holds for both backends fmt maps onto and at every level. send() takes the classification as a required argument rather than inferring it, so a new secret-bearing request cannot be added without someone choosing one.
Classified secret: mining.authorize and mining.submit, plus any response matched to a pending one of those. Everything else is logged in full and documented in the crate docs as carrying no authorization parameter.
Raw receive-buffer dumps are gone. A buffer, and a freshly read chunk, span an arbitrary number of frames, so at that point there is no way to tell whether one of them echoes a credential; the per-frame log covers the useful case and can be classified. The commented-out transmit-buffer dump is removed too rather than left as an invitation.
Error::Pool is the one credential-adjacent value handed back rather than logged, since its message and detail are pool-chosen text that can echo the user. Documented on the variant.
The regression test drives a full handshake with canary credentials and a capturing logger at trace level, and asserts neither canary nor any fragment appears. It caught the read-path chunk dump that reading the send path alone would have missed. defmt cannot be captured in a host test, so it is covered by construction plus unit tests pinning loggable. Adds a flake check so the log-gated test actually runs; the all-features checks have to exclude this crate.