Skip to content

Conversation

@aureleoules
Copy link
Contributor

@aureleoules aureleoules commented Sep 27, 2022

The following RPCs did not sanitize the optional label name:

  • importprivkey
  • importaddress
  • importpubkey
  • importmulti
  • importdescriptors
  • listsinceblock

Thus is was possible to import an address with a label * which should not be possible.
The wildcard label is used for backwards compatibility in the listtransactions rpc.
I added test coverage for these RPCs.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 27, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK furszy, stickies-v, ajtowns, theStack, achow101
Concept ACK MarcoFalke, 1440000bytes

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #26840 (refactor: importpubkey, importprivkey, importaddress, importmulti, and importdescriptors rpc by KolbyML)
  • #26174 (rpc, wallet: add ability to retrieve all address book entries by w0xlt)
  • #24897 ([Draft / POC] Silent Payments by w0xlt)
  • #22838 (descriptors: Be able to specify change and receiving in a single descriptor string by achow101)
  • #20892 (tests: Run both descriptor and legacy tests within a single test invocation by achow101)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Contributor

@stickies-v stickies-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approach ACK 3012200bc0602fc35a53b6a25a7d23eaaed54f9c

@aureleoules aureleoules force-pushed the 2022-09-test-label-invalid branch from 3012200 to cef09dd Compare September 27, 2022 14:54
@aureleoules
Copy link
Contributor Author

Thanks for the review @stickies-v, I've addressed all your comments.

@aureleoules aureleoules force-pushed the 2022-09-test-label-invalid branch from cef09dd to b2d0d4b Compare September 27, 2022 14:58
@aureleoules aureleoules force-pushed the 2022-09-test-label-invalid branch from b2d0d4b to d293585 Compare September 27, 2022 15:15
@aureleoules
Copy link
Contributor Author

Pushed, thanks @stickies-v.

Copy link
Contributor

@stickies-v stickies-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK d29358558 - nice improvement, straightforward code changes and test.

Left a few nits, nothing blocking.

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK. Left a follow-up idea

@aureleoules aureleoules force-pushed the 2022-09-test-label-invalid branch 3 times, most recently from 62535d8 to 8867b03 Compare September 28, 2022 14:33
@maflcko maflcko added this to the 24.0 milestone Sep 28, 2022
@aureleoules aureleoules force-pushed the 2022-09-test-label-invalid branch from 8867b03 to 5b98f5a Compare September 28, 2022 21:26
@aureleoules aureleoules force-pushed the 2022-09-test-label-invalid branch from 5b98f5a to 8b71661 Compare October 3, 2022 12:33
Copy link
Contributor

@stickies-v stickies-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 8b716611b

@aureleoules
Copy link
Contributor Author

Please restore it.

Done @luke-jr.

@aureleoules aureleoules force-pushed the 2022-09-test-label-invalid branch 2 times, most recently from cce2e87 to b119bb8 Compare December 16, 2022 13:52
@ghost
Copy link

ghost commented Dec 18, 2022

Concept ACK

@aureleoules aureleoules force-pushed the 2022-09-test-label-invalid branch from b119bb8 to 408e375 Compare December 19, 2022 10:07
Copy link
Contributor

@stickies-v stickies-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK 408e375d1

Reduced string copying compared to my previous ACK. One non-blocking nit.

Copy link
Member

@furszy furszy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 893c2888

Copy link
Contributor

@ajtowns ajtowns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK.

@aureleoules aureleoules force-pushed the 2022-09-test-label-invalid branch from 408e375 to 6d70265 Compare January 4, 2023 11:29
- importprivkey
- importaddress
- importpubkey
- listtransactions
- listsinceblock
- importmulti
- importdescriptors
@aureleoules aureleoules force-pushed the 2022-09-test-label-invalid branch from 6d70265 to 632202c Compare January 4, 2023 11:31
@aureleoules aureleoules force-pushed the 2022-09-test-label-invalid branch from 632202c to 65e78bd Compare January 4, 2023 12:45
Copy link
Member

@furszy furszy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diff ACK 65e78bd

Copy link
Contributor

@stickies-v stickies-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK 65e78bd

Comment on lines +135 to +136
static const std::string empty_string;
if (value.isNull()) return empty_string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not needed anymore now that we're returning a string copy

Suggested change
static const std::string empty_string;
if (value.isNull()) return empty_string;
if (value.isNull()) return "";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or return {};

@ajtowns
Copy link
Contributor

ajtowns commented Jan 6, 2023

ACK 65e78bd

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK 65e78bd

[node.getnewaddress],
[node.setlabel, address],
[node.getaddressesbylabel],
[node.importpubkey, pubkey],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 65e78bd "test: Invalid label name coverage"

importpubkey is a legacy wallet only RPC. The reason this test still passes with --descriptors is because the test framework has this (and some of the other import RPCs) aliased to importdescriptors.

Copy link
Contributor Author

@aureleoules aureleoules Jan 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know. But considering this PR has 4 ACKs, is it worth the change? The test is executed with both --legacy-wallet and --descriptors anyway.

@achow101
Copy link
Member

ACK 65e78bd

@achow101 achow101 merged commit 68f88bc into bitcoin:master Jan 10, 2023
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jan 11, 2023
65e78bd test: Invalid label name coverage (Aurèle Oulès)
552b51e refactor: Add sanity checks in LabelFromValue (Aurèle Oulès)
67e7ba8 rpc: Sanitize label name in various RPCs (Aurèle Oulès)

Pull request description:

  The following RPCs did not sanitize the optional label name:
  - importprivkey
  - importaddress
  - importpubkey
  - importmulti
  - importdescriptors
  - listsinceblock

  Thus is was possible to import an address with a label `*` which should not be possible.
  The wildcard label is used for backwards compatibility in the `listtransactions` rpc.
  I added test coverage for these RPCs.

ACKs for top commit:
  ajtowns:
    ACK 65e78bd
  achow101:
    ACK 65e78bd
  furszy:
    diff ACK 65e78bd
  stickies-v:
    re-ACK 65e78bd
  theStack:
    re-ACK 65e78bd

Tree-SHA512: ad99f2824d4cfae352166b76da4ca0069b7c2eccf81aaa0654be25bbb3c6e5d6b005d93960f3f4154155f80e12be2d0cebd5529922ae3d2a36ee4eed82440b31
@aureleoules aureleoules deleted the 2022-09-test-label-invalid branch January 12, 2023 11:51
@bitcoin bitcoin locked and limited conversation to collaborators Jan 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.