Repository navigation
Sanitize sensitive data from log messages to prevent privacy leaks - #950
Conversation
Pull Request Test Coverage Report for Build 17649056846Details
💛 - Coveralls |
nothingmuch
left a comment
There was a problem hiding this comment.
In some places I think too much information has been redacted.
IMO it's fine for trace logs to contain sensitive data, just debug and higher levels should be safe to share without redaction. Also limiting trace events means otherwise important information might no longer be available at all requiring code modifications to inspect.
In particular with regards to query parameters and psbt, that information is potentially important to analyze sender behavior, because the software might be interacting with a different or even unknown implementation, which may send surprising things.
| (&Method::GET, "/bip21") => { | ||
| let query_string = req.uri().query().unwrap_or(""); | ||
| log::debug!("{:?}, {query_string:?}", req.method()); | ||
| log::trace!("Processing GET /bip21 with query length: {}", query_string.len()); |
There was a problem hiding this comment.
here just changing to the trace level seems enough to me
| log::trace!("Processing GET /bip21 with query length: {}", query_string.len()); | |
| log::trace!("{:?}, {query_string:?}", req.method()); |
| log::warn!( | ||
| "Request contains a duplicate input. Preventing possible probing attack." | ||
| ); |
There was a problem hiding this comment.
| log::warn!( | |
| "Request contains a duplicate input. Preventing possible probing attack." | |
| ); | |
| log::warn!( | |
| "Request contains a duplicate input. Preventing possible probing attack." | |
| ); | |
| log::trace!("Input outpoint: {}", input.txin.previous_outpoint); |
8235890 to
ac09fc2
Compare
|
sorry i forgot to re-review this PR... the trace lines that used to print the config and psbt should still print that as long as it's only at trace value, that information is useful for debugging and it's much smoother to set RUST_LOG=foo=trace instead of modifying the code to add new log or print statements if you want to dump the data |
|
It would be great if we could get this in before 1.0, since that would make it possible to request debug logs from users with no privacy concerns. |
|
I'm cool getting this in pre-1.0 so that we can debug more effectively. Just needs a rebase. |
|
ping @0xZaddyy |
|
fwiw i still have some outstanding feedback but it's fine to address it after the release |
e95440a to
de13362
Compare
nothingmuch
left a comment
There was a problem hiding this comment.
sorry i didn't mean to suggest you revert everything, just the the redaction of the psbt
| req: Request<Incoming>, | ||
| ) -> Result<Response<BoxBody<Bytes, hyper::Error>>> { | ||
| tracing::debug!("Received request: {req:?}"); | ||
| log::trace!("Received {} request to {}", req.method(), req.uri().path()); |
There was a problem hiding this comment.
| log::trace!("Received {} request to {}", req.method(), req.uri().path()); | |
| tracing::trace!("Received {} request to {}", req.method(), req.uri().path()); |
| (&Method::GET, "/bip21") => { | ||
| let query_string = req.uri().query().unwrap_or(""); | ||
| tracing::debug!("{:?}, {query_string:?}", req.method()); | ||
| log::trace!("{:?}, {query_string:?}", req.method()); |
There was a problem hiding this comment.
| log::trace!("{:?}, {query_string:?}", req.method()); | |
| tracing::trace!("{:?}, {query_string:?}", req.method()); |
| hyper = { version = "1.6.0", features = ["http1", "server"], optional = true } | ||
| hyper-rustls = { version = "0.27.7", default-features=false, features = ["ring"], optional = true } | ||
| hyper-util = { version = "0.1.16", optional = true } | ||
| log = "0.4.27" |
There was a problem hiding this comment.
| log = "0.4.27" |
| method = "PUT"; | ||
| } | ||
| tracing::debug!("Payjoin PSBT target: {}", target_resource.as_str()); | ||
| log::trace!("Payjoin PSBT target: {}", target_resource.as_str()); |
There was a problem hiding this comment.
| log::trace!("Payjoin PSBT target: {}", target_resource.as_str()); | |
| tracing::trace!("Payjoin PSBT target: {}", target_resource.as_str()); |
|
|
||
| let psbt = unchecked_psbt.validate().map_err(InternalPayloadError::InconsistentPsbt)?; | ||
| tracing::debug!("Received original psbt: {psbt:?}"); | ||
| log::trace!("Received original psbt: {psbt:?}"); |
There was a problem hiding this comment.
| log::trace!("Received original psbt: {psbt:?}"); | |
| tracing::trace!("Received original psbt: {psbt:?}"); |
| let params = Params::from_query_pairs(pairs, supported_versions) | ||
| .map_err(InternalPayloadError::SenderParams)?; | ||
| tracing::debug!("Received request with params: {params:?}"); | ||
| log::trace!("Received request with params: {params:?}"); |
There was a problem hiding this comment.
| log::trace!("Received request with params: {params:?}"); | |
| tracing::trace!("Received request with params: {params:?}"); |
| ); | ||
|
|
||
| tracing::debug!("parsed optional parameters: {params:?}"); | ||
| log::trace!("parsed optional parameters: {params:?}"); |
There was a problem hiding this comment.
| log::trace!("parsed optional parameters: {params:?}"); | |
| tracing::trace!("parsed optional parameters: {params:?}"); |
| hpke = { package = "bitcoin-hpke", version = "0.13.0", optional = true } | ||
| http = { version = "1.3.1", optional = true } | ||
| bhttp = { version = "0.6.1", optional = true } | ||
| log = "0.4.27" |
There was a problem hiding this comment.
| log = "0.4.27" |
| } | ||
|
|
||
| log::trace!("App config loaded successfully"); | ||
| tracing::debug!("App config: {config:?}"); |
There was a problem hiding this comment.
| tracing::debug!("App config: {config:?}"); | |
| tracing::trace!("App config: {config:?}"); |
| psbt.inputs.len(), | ||
| psbt.unsigned_tx.output.len() | ||
| ); | ||
| tracing::debug!("Proposed psbt: {psbt:#?}"); |
There was a problem hiding this comment.
| tracing::debug!("Proposed psbt: {psbt:#?}"); | |
| tracing::trace!("Proposed psbt: {psbt:#?}"); |
nothingmuch
left a comment
There was a problem hiding this comment.
Looks good, please squash these changes as there is some back and forth, I think everything could take the message of the first commit.
- Remove transaction outpoints, PSBTs, configuration data, and HTTP request details from log output to prevent privacy leaks. - Move sensitive logs to trace level or replace with sanitized equivalents that preserve debugging restore previous state back to trace refactor: replace log with existing tracing chore: update Cargo lock files
a06e50d to
4fa75db
Compare
done, thank you @nothingmuch |
This PR introduces a privacy safe logging system.
Closes #821, closes #911
Summary