aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet_rpc_server.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-06-24 23:26:58 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-08-17 16:23:58 +0000
commit7175dcb1078abbdaa130a8c5f5fd2b93fa7b3086 (patch)
tree640b83c4101dc992151630a76a13597913d2dd08 /src/wallet/wallet_rpc_server.cpp
parentMerge pull request #6736 (diff)
downloadmonero-7175dcb1078abbdaa130a8c5f5fd2b93fa7b3086.tar.xz
replace most boost serialization with existing monero serialization
This reduces the attack surface for data that can come from malicious sources (exported output and key images, multisig transactions...) since the monero serialization is already exposed to the outside, and the boost lib we were using had a few known crashers. For interoperability, a new load-deprecated-formats wallet setting is added (off by default). This allows loading boost format data if there is no alternative. It will likely go at some point, along with the ability to load those. Notably, the peer lists file still uses the boost serialization code, as the data it stores is define in epee, while the new serialization code is in monero, and migrating it was fairly hairy. Since this file is local and not obtained from anyone else, the marginal risk is minimal, but it could be migrated later if needed. Some tests and tools also do, this will stay as is for now.
Diffstat (limited to 'src/wallet/wallet_rpc_server.cpp')
-rw-r--r--src/wallet/wallet_rpc_server.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index 2391b51fd..0ed749cb7 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -838,10 +838,11 @@ namespace tools
static std::string ptx_to_string(const tools::wallet2::pending_tx &ptx)
{
std::ostringstream oss;
- boost::archive::portable_binary_oarchive ar(oss);
+ binary_archive<true> ar(oss);
try
{
- ar << ptx;
+ if (!::serialization::serialize(ar, const_cast<tools::wallet2::pending_tx&>(ptx)))
+ return "";
}
catch (...)
{
@@ -1550,14 +1551,31 @@ namespace tools
return false;
}
+ bool loaded = false;
tools::wallet2::pending_tx ptx;
+
try
{
std::istringstream iss(blob);
- boost::archive::portable_binary_iarchive ar(iss);
- ar >> ptx;
+ binary_archive<false> ar(iss);
+ if (::serialization::serialize(ar, ptx))
+ loaded = true;
}
- catch (...)
+ catch(...) {}
+
+ if (!loaded && !m_restricted)
+ {
+ try
+ {
+ std::istringstream iss(blob);
+ boost::archive::portable_binary_iarchive ar(iss);
+ ar >> ptx;
+ loaded = true;
+ }
+ catch (...) {}
+ }
+
+ if (!loaded)
{
er.code = WALLET_RPC_ERROR_CODE_BAD_TX_METADATA;
er.message = "Failed to parse tx metadata.";