rpc: do not return panic stack traces to callers - #67
Open
DHEBP wants to merge 1 commit into
Open
Conversation
On panic recovery the daemon RPC handlers and the two tx-verification recover sites formatted debug.Stack() into the returned error, which becomes the JSON-RPC error body. Any unauthenticated caller could retrieve the node's absolute build path and OS username. Log the stack at V(1) and return a generic error instead. Also fix a nil-pointer dereference in NameToAddress: the address constructor's error was discarded and a stale error checked in its place, so a name whose stored value is not a 33-byte key produced a nil address that was then dereferenced. Guard on the nil address. Values of 33 bytes still resolve as before.
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.
What
On panic recovery, the derod RPC handlers and the two tx-verification recover sites formatted
debug.Stack()into the returned error. That error becomes the JSON-RPC error body, so any unauthenticated caller can retrieve the node's absolute build path and OS username.The same disclosure is reachable through
DERO.NameToAddresswith no crafted transaction: a name whose stored value is not a 33-byte key hits a nil-pointer dereference (the address constructor's error was discarded and a stale error checked in its place), which the recover then turns into a stack-trace response.Change
cmd/derod/rpchandlers + 2blockchain/transaction_verify.gorecover sites: log the stack atV(1), return a generic error.NameToAddress: guard on the nil address so malformed stored values return cleanly instead of panicking. Values of 33 bytes (including existing zero-owned names) still resolve exactly as before.Notes