Skip to content

Commit 5a150e1

Browse files
gluk256gballet
authored andcommitted
whisper: serious security issue fixed (#16219)
The diagnostic tool was saving the unencrypted version of the messages, which is an obvious security flaw. As of this commit: * encrypted messages saved instead of plain text. * all messages are stored, even that created by the user of wnode.
1 parent 9b4e182 commit 5a150e1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

cmd/wnode/main.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -594,19 +594,22 @@ func writeMessageToFile(dir string, msg *whisper.ReceivedMessage) {
594594
address = crypto.PubkeyToAddress(*msg.Src)
595595
}
596596

597-
if whisper.IsPubKeyEqual(msg.Src, &asymKey.PublicKey) {
598-
// message from myself: don't save, only report
599-
fmt.Printf("\n%s <%x>: message received: '%s'\n", timestamp, address, name)
600-
} else if len(dir) > 0 {
597+
// this is a sample code; uncomment if you don't want to save your own messages.
598+
//if whisper.IsPubKeyEqual(msg.Src, &asymKey.PublicKey) {
599+
// fmt.Printf("\n%s <%x>: message from myself received, not saved: '%s'\n", timestamp, address, name)
600+
// return
601+
//}
602+
603+
if len(dir) > 0 {
601604
fullpath := filepath.Join(dir, name)
602-
err := ioutil.WriteFile(fullpath, msg.Payload, 0644)
605+
err := ioutil.WriteFile(fullpath, msg.Raw, 0644)
603606
if err != nil {
604607
fmt.Printf("\n%s {%x}: message received but not saved: %s\n", timestamp, address, err)
605608
} else {
606-
fmt.Printf("\n%s {%x}: message received and saved as '%s' (%d bytes)\n", timestamp, address, name, len(msg.Payload))
609+
fmt.Printf("\n%s {%x}: message received and saved as '%s' (%d bytes)\n", timestamp, address, name, len(msg.Raw))
607610
}
608611
} else {
609-
fmt.Printf("\n%s {%x}: big message received (%d bytes), but not saved: %s\n", timestamp, address, len(msg.Payload), name)
612+
fmt.Printf("\n%s {%x}: message received (%d bytes), but not saved: %s\n", timestamp, address, len(msg.Raw), name)
610613
}
611614
}
612615

0 commit comments

Comments
 (0)