fix: propagate hashed password to threadpool

fixes: #11913
This commit is contained in:
Patryk Osmaczko 2023-09-19 15:24:21 +02:00 committed by osmaczko
parent d51b78468d
commit 2d4e20585b
14 changed files with 49 additions and 54 deletions

View File

@ -598,7 +598,7 @@ QtObject:
proc verifyAccountPassword*(self: Service, account: string, password: string): bool =
try:
let response = status_account.verifyAccountPassword(account, password, self.keyStoreDir)
let response = status_account.verifyAccountPassword(account, utils.hashPassword(password), self.keyStoreDir)
if(response.result.contains("error")):
let errMsg = response.result["error"].getStr
if(errMsg.len == 0):
@ -686,7 +686,7 @@ QtObject:
proc onWaitForReencryptionTimeout(self: Service, response: string) {.slot.} =
# Reencryption (can freeze and take up to 30 minutes)
let oldHashedPassword = hashedPasswordToUpperCase(self.tmpHashedPassword)
discard status_privacy.changeDatabaseHashedPassword(self.tmpAccount.keyUid, oldHashedPassword, self.tmpHashedPassword)
discard status_privacy.changeDatabasePassword(self.tmpAccount.keyUid, oldHashedPassword, self.tmpHashedPassword)
# Normal login after reencryption
self.doLogin(self.tmpAccount, self.tmpHashedPassword, self.tmpThumbnailImage, self.tmpLargeImage)

View File

@ -16,6 +16,7 @@ import ../../../app/core/tasks/[qt, threadpool]
import ../../../backend/communities as status_go
import ../../../app_service/common/types
import ../../../app_service/common/utils
include ./async_tasks
@ -1484,7 +1485,7 @@ QtObject:
slot: "onAsyncRequestToJoinCommunityDone",
communityId: communityId,
ensName: ensName,
password: password,
password: if password != "": utils.hashPassword(password) else: "",
addressesToShare: addressesToShare,
airdropAddress: airdropAddress,
)
@ -1518,7 +1519,7 @@ QtObject:
vptr: cast[ByteAddress](self.vptr),
slot: "onAsyncEditSharedAddressesDone",
communityId: communityId,
password: password,
password: if password != "": utils.hashPassword(password) else: "",
addressesToShare: addressesToShare,
airdropAddress: airdropAddress,
)

View File

@ -398,7 +398,7 @@ QtObject:
if txData.source == parseAddress(ZERO_ADDRESS):
return
let response = tokens_backend.deployOwnerToken(chainId, %ownerDeploymentParams, %masterDeploymentParams, %txData, password)
let response = tokens_backend.deployOwnerToken(chainId, %ownerDeploymentParams, %masterDeploymentParams, %txData, common_utils.hashPassword(password))
let ownerContractAddress = response.result["contractAddress"].getStr()
let transactionHash = response.result["transactionHash"].getStr()
debug "Deployed owner contract address ", ownerContractAddress=ownerContractAddress
@ -446,9 +446,9 @@ QtObject:
var response: RpcResponse[JsonNode]
case tokenMetadata.tokenType
of TokenType.ERC721:
response = tokens_backend.deployCollectibles(chainId, %deploymentParams, %txData, password)
response = tokens_backend.deployCollectibles(chainId, %deploymentParams, %txData, common_utils.hashPassword(password))
of TokenType.ERC20:
response = tokens_backend.deployAssets(chainId, %deploymentParams, %txData, password)
response = tokens_backend.deployAssets(chainId, %deploymentParams, %txData, common_utils.hashPassword(password))
else:
error "Contract deployment error - unknown token type", tokenType=tokenMetadata.tokenType
return
@ -608,7 +608,7 @@ QtObject:
if txData.source == parseAddress(ZERO_ADDRESS):
return
debug "Airdrop tokens ", chainId=collectibleAndAmount.communityToken.chainId, address=collectibleAndAmount.communityToken.address, amount=collectibleAndAmount.amount
let response = tokens_backend.mintTokens(collectibleAndAmount.communityToken.chainId, collectibleAndAmount.communityToken.address, %txData, password, walletAddresses, collectibleAndAmount.amount)
let response = tokens_backend.mintTokens(collectibleAndAmount.communityToken.chainId, collectibleAndAmount.communityToken.address, %txData, common_utils.hashPassword(password), walletAddresses, collectibleAndAmount.amount)
let transactionHash = response.result.getStr()
debug "Airdrop transaction hash ", transactionHash=transactionHash
@ -728,7 +728,7 @@ QtObject:
return
let txData = self.buildTransactionDataDto(addressFrom, contract.chainId, contract.address)
debug "Remote destruct collectibles ", chainId=contract.chainId, address=contract.address, tokens=tokenIds
let response = tokens_backend.remoteBurn(contract.chainId, contract.address, %txData, password, tokenIds)
let response = tokens_backend.remoteBurn(contract.chainId, contract.address, %txData, common_utils.hashPassword(password), tokenIds)
let transactionHash = response.result.getStr()
debug "Remote destruct transaction hash ", transactionHash=transactionHash
@ -793,7 +793,7 @@ QtObject:
var contract = self.findContractByUniqueId(contractUniqueKey)
let txData = self.buildTransactionDataDto(addressFrom, contract.chainId, contract.address)
debug "Burn tokens ", chainId=contract.chainId, address=contract.address, amount=amount
let response = tokens_backend.burn(contract.chainId, contract.address, %txData, password, amount)
let response = tokens_backend.burn(contract.chainId, contract.address, %txData, common_utils.hashPassword(password), amount)
let transactionHash = response.result.getStr()
debug "Burn transaction hash ", transactionHash=transactionHash

View File

@ -11,6 +11,7 @@ import ../../../backend/ens as status_ens
import ../../../backend/backend as status_go_backend
import ../../common/conversion as common_conversion
import ../../common/utils as common_utils
import utils as ens_utils
import ../settings/service as settings_service
import ../wallet_account/service as wallet_account_service
@ -293,7 +294,7 @@ QtObject:
try:
let txData = ens_utils.buildTransaction(parseAddress(address), 0.u256, gas, gasPrice,
eip1559Enabled, maxPriorityFeePerGas, maxFeePerGas)
let resp = status_ens.setPubKey(chainId, %txData, password, ensUsername.addDomain(),
let resp = status_ens.setPubKey(chainId, %txData, common_utils.hashPassword(password), ensUsername.addDomain(),
singletonInstance.userProfile.getPubKey())
let hash = resp.result.getStr
@ -347,7 +348,7 @@ QtObject:
if ensUsername.endsWith(ens_utils.STATUS_DOMAIN):
userNameNoDomain = ensUsername.replace(ens_utils.STATUS_DOMAIN, "")
let resp = status_ens.release(chainId, %txData, password, userNameNoDomain)
let resp = status_ens.release(chainId, %txData, common_utils.hashPassword(password), userNameNoDomain)
let hash = resp.result.getStr
let ensUsernamesAddress = self.getEnsRegisteredAddress()
@ -392,7 +393,7 @@ QtObject:
try:
let txData = ens_utils.buildTransaction(parseAddress(address), 0.u256, gas, gasPrice,
eip1559Enabled, maxPriorityFeePerGas, maxFeePerGas)
let resp = status_ens.register(chainId, %txData, password, username,
let resp = status_ens.register(chainId, %txData, common_utils.hashPassword(password), username,
singletonInstance.userProfile.getPubKey())
let hash = resp.result.getStr
let sntContract = self.getStatusToken()

View File

@ -9,6 +9,8 @@ import ../../../app/core/eventemitter
import ../../../backend/eth as status_eth
import ../../../backend/privacy as status_privacy
import ../../common/utils as common_utils
logScope:
topics = "privacy-service"
@ -89,7 +91,7 @@ QtObject:
return
let loggedInAccount = self.accountsService.getLoggedInAccount()
let response = status_privacy.changeDatabasePassword(loggedInAccount.keyUid, password, newPassword)
let response = status_privacy.changeDatabasePassword(loggedInAccount.keyUid, common_utils.hashPassword(password), common_utils.hashPassword(newPassword))
if(response.result.contains("error")):
let errMsg = response.result["error"].getStr

View File

@ -23,6 +23,7 @@ import ../transaction/service as transaction_service
import ../network/service as network_service
import ../chat/service as chat_service
import ../../common/types
import ../../common/utils as common_utils
import ../eth/utils as status_utils
export StickerDto
@ -213,7 +214,7 @@ QtObject:
chainId = self.networkService.getNetworkForStickers().chainId
txData = buildTransaction(parseAddress(address), gas, gasPrice, eip1559Enabled, maxPriorityFeePerGas, maxFeePerGas)
try:
let transactionResponse = status_stickers.buy(chainId, %txData, packId, password)
let transactionResponse = status_stickers.buy(chainId, %txData, packId, common_utils.hashPassword(password))
let transactionHash = transactionResponse.result.getStr()
let sntContract = self.getStatusToken()
self.transactionService.watchTransaction(

View File

@ -7,6 +7,7 @@ import ../../../backend/eth
import ../ens/utils as ens_utils
import ../../common/conversion as common_conversion
import ../../common/utils as common_utils
import ../../../app/core/[main]
import ../../../app/core/signals/types
@ -290,7 +291,7 @@ QtObject:
multiTxType: transactions.MultiTransactionType.MultiTransactionSend,
),
paths,
password,
common_utils.hashPassword(password),
)
if response.result{"hashes"} != nil:
@ -367,7 +368,7 @@ QtObject:
multiTxType: transactions.MultiTransactionType.MultiTransactionSend,
),
paths,
password,
common_utils.hashPassword(password),
)
if response.result{"hashes"} != nil:

View File

@ -417,10 +417,9 @@ proc loginWithKeycard*(chatKey, password: string, account, confNode: JsonNode):
error "error doing rpc request", methodName = "loginWithKeycard", exception=e.msg
raise newException(RpcException, e.msg)
proc verifyAccountPassword*(address: string, password: string, keystoreDir: string):
proc verifyAccountPassword*(address: string, hashedPassword: string, keystoreDir: string):
RpcResponse[JsonNode] {.raises: [Exception].} =
try:
let hashedPassword = hashPassword(password)
let response = status_go.verifyAccountPassword(keystoreDir, address, hashedPassword)
result.result = Json.decode(response, JsonNode)

View File

@ -38,11 +38,10 @@ proc requestToJoinCommunity*(
addressesToShare: seq[string],
airdropAddress: string,
): RpcResponse[JsonNode] {.raises: [Exception].} =
var passwordToSend = password
result = callPrivateRPC("requestToJoinCommunity".prefix, %*[{
"communityId": communityId,
"ensName": ensName,
"password": if passwordToSend != "": utils.hashPassword(password) else: "",
"password": password,
"addressesToReveal": addressesToShare,
"airdropAddress": airdropAddress,
}])
@ -53,10 +52,9 @@ proc editSharedAddresses*(
addressesToShare: seq[string],
airdropAddress: string,
): RpcResponse[JsonNode] {.raises: [Exception].} =
var passwordToSend = password
result = callPrivateRPC("editSharedAddressesForCommunity".prefix, %*[{
"communityId": communityId,
"password": if passwordToSend != "": utils.hashPassword(password) else: "",
"password": password,
"addressesToReveal": addressesToShare,
"airdropAddress": airdropAddress,
}])

View File

@ -7,12 +7,12 @@ import ./core, ./response_type
import ../app_service/service/community_tokens/dto/community_token
import interpret/cropped_image
proc deployCollectibles*(chainId: int, deploymentParams: JsonNode, txData: JsonNode, password: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, deploymentParams, txData, utils.hashPassword(password)]
proc deployCollectibles*(chainId: int, deploymentParams: JsonNode, txData: JsonNode, hashedPassword: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, deploymentParams, txData, hashedPassword]
return core.callPrivateRPC("communitytokens_deployCollectibles", payload)
proc deployAssets*(chainId: int, deploymentParams: JsonNode, txData: JsonNode, password: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, deploymentParams, txData, utils.hashPassword(password)]
proc deployAssets*(chainId: int, deploymentParams: JsonNode, txData: JsonNode, hashedPassword: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, deploymentParams, txData, hashedPassword]
return core.callPrivateRPC("communitytokens_deployAssets", payload)
proc removeCommunityToken*(chainId: int, address: string): RpcResponse[JsonNode] {.raises: [Exception].} =
@ -48,24 +48,24 @@ proc updateCommunityTokenSupply*(chainId: int, contractAddress: string, supply:
let payload = %* [chainId, contractAddress, supply.toString(10)]
return core.callPrivateRPC("wakuext_updateCommunityTokenSupply", payload)
proc mintTokens*(chainId: int, contractAddress: string, txData: JsonNode, password: string, walletAddresses: seq[string], amount: Uint256): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, contractAddress, txData, utils.hashPassword(password), walletAddresses, amount.toString(10)]
proc mintTokens*(chainId: int, contractAddress: string, txData: JsonNode, hashedPasword: string, walletAddresses: seq[string], amount: Uint256): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, contractAddress, txData, hashedPasword, walletAddresses, amount.toString(10)]
return core.callPrivateRPC("communitytokens_mintTokens", payload)
proc estimateMintTokens*(chainId: int, contractAddress: string, fromAddress: string, walletAddresses: seq[string], amount: Uint256): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, contractAddress, fromAddress, walletAddresses, amount.toString(10)]
return core.callPrivateRPC("communitytokens_estimateMintTokens", payload)
proc remoteBurn*(chainId: int, contractAddress: string, txData: JsonNode, password: string, tokenIds: seq[UInt256]): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, contractAddress, txData, utils.hashPassword(password), tokenIds.map(x => x.toString(10))]
proc remoteBurn*(chainId: int, contractAddress: string, txData: JsonNode, hashedPassword: string, tokenIds: seq[UInt256]): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, contractAddress, txData, hashedPassword, tokenIds.map(x => x.toString(10))]
return core.callPrivateRPC("communitytokens_remoteBurn", payload)
proc estimateRemoteBurn*(chainId: int, contractAddress: string, fromAddress: string, tokenIds: seq[UInt256]): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, contractAddress, fromAddress, tokenIds.map(x => x.toString(10))]
return core.callPrivateRPC("communitytokens_estimateRemoteBurn", payload)
proc burn*(chainId: int, contractAddress: string, txData: JsonNode, password: string, amount: Uint256): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, contractAddress, txData, utils.hashPassword(password), amount.toString(10)]
proc burn*(chainId: int, contractAddress: string, txData: JsonNode, hashedPassword: string, amount: Uint256): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, contractAddress, txData, hashedPassword, amount.toString(10)]
return core.callPrivateRPC("communitytokens_burn", payload)
proc estimateBurn*(chainId: int, contractAddress: string, fromAddress: string, amount: Uint256): RpcResponse[JsonNode] {.raises: [Exception].} =
@ -92,8 +92,8 @@ proc deployOwnerTokenEstimate*(): RpcResponse[JsonNode] {.raises: [Exception].}
let payload = %*[]
return core.callPrivateRPC("communitytokens_deployOwnerTokenEstimate", payload)
proc deployOwnerToken*(chainId: int, ownerParams: JsonNode, masterParams: JsonNode, txData: JsonNode, password: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %*[chainId, ownerParams, masterParams, txData, utils.hashPassword(password)]
proc deployOwnerToken*(chainId: int, ownerParams: JsonNode, masterParams: JsonNode, txData: JsonNode, hashedPassword: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %*[chainId, ownerParams, masterParams, txData, hashedPassword]
return core.callPrivateRPC("communitytokens_deployOwnerToken", payload)
proc getMasterTokenContractAddressFromHash*(chainId: int, transactionHash: string): RpcResponse[JsonNode] {.raises: [Exception].} =

View File

@ -1,6 +1,5 @@
import json
import ./core, ./response_type
import ../app_service/common/utils
export response_type
proc getEnsUsernames*(): RpcResponse[JsonNode] {.raises: [Exception].} =
@ -59,9 +58,9 @@ proc resourceURL*(chainId: int, username: string): RpcResponse[JsonNode] {.raise
return core.callPrivateRPC("ens_resourceURL", payload)
proc register*(
chainId: int, txData: JsonNode, password: string, username: string, pubkey: string
chainId: int, txData: JsonNode, hashedPassword: string, username: string, pubkey: string
): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, txData, utils.hashPassword(password), username, pubkey]
let payload = %* [chainId, txData, hashedPassword, username, pubkey]
return core.callPrivateRPC("ens_register", payload)
proc registerEstimate*(
@ -71,9 +70,9 @@ proc registerEstimate*(
return core.callPrivateRPC("ens_registerEstimate", payload)
proc release*(
chainId: int, txData: JsonNode, password: string, username: string
chainId: int, txData: JsonNode, hashedPassword: string, username: string
): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, txData, utils.hashPassword(password), username]
let payload = %* [chainId, txData, hashedPassword, username]
return core.callPrivateRPC("ens_release", payload)
proc releaseEstimate*(
@ -83,9 +82,9 @@ proc releaseEstimate*(
return core.callPrivateRPC("ens_releaseEstimate", payload)
proc setPubKey*(
chainId: int, txData: JsonNode, password: string, username: string, pubkey: string
chainId: int, txData: JsonNode, hashedPassword: string, username: string, pubkey: string
): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, txData, utils.hashPassword(password), username, pubkey]
let payload = %* [chainId, txData, hashedPassword, username, pubkey]
return core.callPrivateRPC("ens_setPubKey", payload)
proc setPubKeyEstimate*(

View File

@ -9,7 +9,7 @@ export response_type
logScope:
topics = "rpc-privacy"
proc changeDatabaseHashedPassword*(keyUID: string, oldHashedPassword: string, newHashedPassword: string): RpcResponse[JsonNode]
proc changeDatabasePassword*(keyUID: string, oldHashedPassword: string, newHashedPassword: string): RpcResponse[JsonNode]
{.raises: [Exception].} =
try:
let response = status_go.changeDatabasePassword(keyUID, oldHashedPassword, newHashedPassword)
@ -18,12 +18,6 @@ proc changeDatabaseHashedPassword*(keyUID: string, oldHashedPassword: string, ne
error "error", methodName = "changeDatabasePassword", exception=e.msg
raise newException(RpcException, e.msg)
proc changeDatabasePassword*(keyUID: string, password: string, newPassword: string): RpcResponse[JsonNode]
{.raises: [Exception].} =
let hashedPassword = hashPassword(password)
let hashedNewPassword = hashPassword(newPassword)
return changeDatabaseHashedPassword(keyUID, hashedPassword, hashedNewPassword)
proc getLinkPreviewWhitelist*(): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* []
result = callPrivateRPC("getLinkPreviewWhitelist".prefix, payload)

View File

@ -1,6 +1,5 @@
import json
import ./eth
import ../app_service/common/utils
import ./core, ./response_type
import web3/[ethtypes, conversions]
@ -40,8 +39,8 @@ proc buyEstimate*(chainId: int, fromAccount: Address, packId: string): RpcRespon
let payload = %* [chainId, $fromAccount, packId]
return core.callPrivateRPC("stickers_buyEstimate", payload)
proc buy*(chainId: int, txData: JsonNode, packId: string, password: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, txData, packID, utils.hashPassword(password)]
proc buy*(chainId: int, txData: JsonNode, packId: string, hashedPassword: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [chainId, txData, packID, hashedPassword]
return core.callPrivateRPC("stickers_buy", payload)
proc clearRecentStickers*(): RpcResponse[JsonNode] {.raises: [Exception].} =

View File

@ -73,8 +73,8 @@ proc getTransactionReceipt*(chainId: int, transactionHash: string): RpcResponse[
proc fetchCryptoServices*(): RpcResponse[JsonNode] {.raises: [Exception].} =
result = core.callPrivateRPC("wallet_getCryptoOnRamps", %* [])
proc createMultiTransaction*(multiTransactionCommand: MultiTransactionCommandDto, data: seq[TransactionBridgeDto], password: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [multiTransactionCommand, data, hashPassword(password)]
proc createMultiTransaction*(multiTransactionCommand: MultiTransactionCommandDto, data: seq[TransactionBridgeDto], hashedPassword: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [multiTransactionCommand, data, hashedPassword]
result = core.callPrivateRPC("wallet_createMultiTransaction", payload)
proc getMultiTransactions*(transactionIDs: seq[int]): RpcResponse[JsonNode] {.raises: [Exception].} =