-
Notifications
You must be signed in to change notification settings - Fork 288
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 user input from URI error message #280
Conversation
Nice find. Presumably we could also just sanitize the address before showing? |
Yes that's possible. I thought a generic error message is good enough in this case for user and there is no need to know the wrong address or anything else which was entered. For sanitization I will have to do more research if it's already done for something else in GUI or find best way to do it in C++. |
I think it would be better to always sanitize the address before showing it. @Bosch-0 what do you think about this from a UX perspective. should the incorrect address be shown back to the user? |
The blank error that prayank presented in the OP would be my suggestion. The only information I would include (if you can) alongside the incorrect address is why the address is invalid. Say for example is opening a testnet address when running mainnet it could notify the user of this. @GBKS thoughts? |
Thanks everyone for the review.
@jarolrod
@Bosch-0
@GBKS Thanks for sharing the mockup. However, less is better in this case IMO. @hebasto Few examples of different reasons mentioned in the error messages:
After this PR:
Before this PR: After this PR:
Before this PR: After this PR: There is one more case which was already mentioned and can be tested with Line 238 in 585cbe2
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK 9885de1, tested on Debian Sid with Qt 5.15.2
To reproduce, I've created wrapper open.sh
file with this content:
#!/usr/bin/bash
/home/vincas/code/bitcoin/280-bitcoin-core-gui.git/_build_pr/src/qt/bitcoin-qt -regtest $@
Then, in about:config
Firefox page I've set network.protocol-handler.expose.bitcoin
to boolean false
value.
Finally, entered specially-crafted link into Firefox address bar to open it, selected open.sh
I've prepared earlier.
Master: got cracker message, this PR: got vague (but safe) error message as expected.
I personally don't care much about "usefulness" of the error message, better just fix it ASAP and improve in later PR.
I agree. I think this PR is good enough to be merged. I have opened another PR bitcoin/bitcoin#21755 to improve error messages for invalid addresses. |
tACK a79ca55 on windows 10 - looks good to me! Before / After: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
concept ack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach ACK a79ca55.
tested ACK commit a79ca55 Great find! A valid address still contains a label, but an invalid address will now only contain the error message (without extra info). |
+ Detailed error messages for invalid address + Used `IsValidDestination` instead of `IsValidDestinationString` + Referred to bitcoin/bitcoin#20832 for solution
@Rspigler I tried the examples mentioned in BIP 21 with a testnet address in bitcoin-qt(testnet). They are all working.
Not sure what did I test last time when I got error and opened this PR: bitcoin/bitcoin#21819. Maybe I used mainnet address in testnet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK. Nice find. Added for backport. |
3bad0b3 Remove user input from URI error message (unknown) Pull request description: Removes the user input from error message to avoid it being used in attacks. Its not really a vulnerability in Bitcoin Core because involves social engineering, dependency on user environment etc. But this PR improves security and by avoiding abuse of URI error in future. Example of an attack: 1. User opens a link in firefox: ``` bitcoin:tb1qag2e6yhl52hr53vdxzaxvnjtueupvuftan4yfu%0A%0AWARNING%3A%20DO%20NOT%20CLOSE%20THIS%20WINDOW%20OR%20TURN%20OFF%20YOUR%20PC!%20IF%20YOU%20ABORT%20THIS%20PROCESS%2C%20YOU%20COULD%20DESTROY%20ALL%20OF%20YOU%20DATA!%20PLEASE%20ENSURE%20THAT%20YOUR%20POWER%20CABLE%20IS%20PLUGGED%20IN!%0A%0AYou%20became%20victim%20of%20the%20XYZ%20RANSOMWARE!%0A%0AThe%20hard%20disks%20of%20your%20computer%20have%20been%20encrypted%20with%20a%20military%20grade%20encryption%20algorithm.%20There%20is%20no%20way%20to%20restore%20your%20data%20without%20a%20special%20key.%20You%20can%20purchase%20this%20key%20on%20the%20darknet%20page%20shown%20in%20step%202.%0ATo%20purchase%20your%20key%20and%20restore%20your%20data%2C%20please%20follow%20these%20three%20easy%20steps%3A%0A%0A1.%20Download%20the%20Tor%20browser%20at%20%E2%80%9Chttps%3A%2F%2Fwww.torproject.org%2F%E2%80%9C.%0A2.%20Visit%20one%20of%20the%20following%20pages%20with%20the%20Tor%20Browser%3A%0Ahttp%3A%2F%2Frandomchars.onion%2Fabc123%0A3.%20Send%20BTC%20by%20following%20the%20instructions%20on%20the%20page ``` 2. User selects Bitcoin Core to open the link:  3. User is asked to send BTC with some message convincing enough which can be different depending on the victim:  **After this PR** (_No user input mentioned in the error_):  ACKs for top commit: hebasto: ACK 3bad0b3, tested on Linux Mint 20.1 (Qt 5.12.8). jarolrod: tACK 3bad0b3 Tree-SHA512: aac2fdfcaa7a9cd6582750c1960682554795640f5aacb78bdae121724e1151da3cbb62b8f8b1e0bc37347afe78b3e9a446277cab8e009d2a1050c0e971f001b3
+ Detailed error messages for invalid address + Used `IsValidDestination` instead of `IsValidDestinationString` + Referred to bitcoin#20832 for solution Github-Pull: bitcoin-core/gui#280 Rebased-From: 3bad0b3
Backported in bitcoin/bitcoin#22022 |
+ Detailed error messages for invalid address + Used `IsValidDestination` instead of `IsValidDestinationString` + Referred to bitcoin#20832 for solution Github-Pull: bitcoin-core/gui#280 Rebased-From: 3bad0b3
09620b8 Update Windows code signing certificate (Andrew Chow) 46320ba Remove user input from URI error message (unknown) f2a8898 p2p, bugfix: use NetPermissions::HasFlag() in CConnman::Bind() (Jon Atack) Pull request description: ACKs for top commit: achow101: ACK 09620b8 Diffs match. hebasto: ACK 09620b8, tested bitcoin-core/gui#280 behavior. fanquake: ACK 09620b8 Tree-SHA512: 1c4aaec42ea047261b5d30851bca605540eccf572708403335b38016127d3230b5380b3f5ef03921ed62192239b0d3da9787d51f557ed7911bf6bb2a7c172753
09620b89f5f78434080196162c75e3e65cc8d47f Update Windows code signing certificate (Andrew Chow) 46320ba72f80dd865b05bbfe2654cde124859881 Remove user input from URI error message (unknown) f2a88986a18f197f6a4690f5dcca248f6b6170e2 p2p, bugfix: use NetPermissions::HasFlag() in CConnman::Bind() (Jon Atack) Pull request description: ACKs for top commit: achow101: ACK 09620b89f5f78434080196162c75e3e65cc8d47f Diffs match. hebasto: ACK 09620b89f5f78434080196162c75e3e65cc8d47f, tested bitcoin-core/gui#280 behavior. fanquake: ACK 09620b89f5f78434080196162c75e3e65cc8d47f Tree-SHA512: 1c4aaec42ea047261b5d30851bca605540eccf572708403335b38016127d3230b5380b3f5ef03921ed62192239b0d3da9787d51f557ed7911bf6bb2a7c172753
Removes the user input from error message to avoid it being used in attacks.
Its not really a vulnerability in Bitcoin Core because involves social engineering, dependency on user environment etc. But this PR improves security and by avoiding abuse of URI error in future.
Example of an attack:
After this PR (No user input mentioned in the error):