Fixes cross-wallet txp view - #4227
Open
MichaelAJay wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an information disclosure in the Bitcore Wallet Service “tx proposal by hash” read path by scoping the storage lookup to the authenticated wallet, preventing a copayer from retrieving another wallet’s proposal when they know the txid.
Changes:
- Adds a wallet-scoped storage lookup (
fetchTxByHashForWallet) for tx proposals by txid. - Updates
WalletService.getTxByHashto use the authenticated wallet ID for the by-hash lookup. - Adds regression tests covering same-wallet success and cross-wallet/unknown-txid non-disclosure at storage, service, and HTTP-route levels.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/bitcore-wallet-service/src/lib/storage.ts | Adds wallet-scoped tx-by-hash storage lookup used by authenticated reads. |
| packages/bitcore-wallet-service/src/lib/server.ts | Switches getTxByHash to call the wallet-scoped storage method. |
| packages/bitcore-wallet-service/test/storage.test.ts | Adds storage coverage for duplicate txids across wallets and wallet-scoped disambiguation. |
| packages/bitcore-wallet-service/test/integration/server.test.ts | Adds service + HTTP-route regression tests ensuring foreign-wallet/unknown txids return indistinguishable not-found errors. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| // Wallet-scoped counterpart to fetchTxByHash, used by the authenticated | ||
| // by-hash API read. | ||
| fetchTxByHashForWallet(walletId: string, hash, cb: (err?: any, tx?: TxProposal) => void) { |
| @@ -3139,7 +3139,12 @@ export class WalletService implements IWalletService { | |||
| * @returns {Object} txProposal | |||
| */ | |||
| getTxByHash(opts, cb) { | |||
Comment on lines
+9180
to
+9183
| afterEach(function() { | ||
| verifyStub.restore(); | ||
| httpServer.close(); | ||
| }); |
| disableLogs: true, | ||
| basePath: config.basePath | ||
| }); | ||
| httpServer.listen(testPort); |
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.
Description
Fixes a cross-wallet transaction proposal disclosure in
GET /v1/txproposalsbyhash/:txid/.Previously, the endpoint looked up transaction proposals globally by txid. This allowed an authenticated copayer to retrieve another wallet’s proposal when its txid was known. The endpoint now scopes the database lookup to the authenticated wallet.
Foreign and unknown txids return the same existing HTTP 400
TX_NOT_FOUNDresponse, while owner access and transaction-note behavior remain unchanged.Changelog
fetchTxByHashForWalletstorage method.Testing Notes
Requires MongoDB on
localhost:27017.TX_NOT_FOUNDwith no owner data;Lockstests; neither failure intersects this diff.Checklist