-
Notifications
You must be signed in to change notification settings - Fork 26
wallet: restrict sensitive RPC commands under --restricted-rpc #212
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
Changes from all commits
7f02243
0a496df
8ae179b
75f12f5
580ad8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1848,6 +1848,14 @@ skip: | |
| template<class t_core> | ||
| int t_cryptonote_protocol_handler<t_core>::handle_request_chain(int command, NOTIFY_REQUEST_CHAIN::request& arg, cryptonote_connection_context& context) | ||
| { | ||
|
|
||
| if (arg.block_ids.size() > CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT) | ||
| { | ||
| LOG_ERROR_CCONTEXT("Too many block IDs requested: " << arg.block_ids.size() << " (maximum " << CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT << ")"); | ||
| drop_connection(context, false, false); | ||
| return 1; | ||
| } | ||
|
|
||
|
Comment on lines
+1851
to
+1858
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 12 \
'HANDLE_NOTIFY_T2|load_t_from_binary|NOTIFY_REQUEST_CHAIN|MAX_PACKET|MAX.*MESSAGE' \
--glob '*.h' --glob '*.hpp' --glob '*.cpp' --glob '*.inl' . || trueRepository: Beldex-Coin/beldex Length of output: 50374 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- container serialization macros ---'
rg -n -C 8 'KV_SERIALIZE_CONTAINER_POD_AS_BLOB|serialize_container|load_from_binary|load_storage' \
contrib/epee/include/epee src/cryptonote_protocol \
--glob '*.h' --glob '*.hpp' --glob '*.cpp' --glob '*.inl' \
| head -n 500
printf '%s\n' '--- P2P deserialization call path ---'
rg -n -C 10 'buff_to_t_adapter|load_t_from_binary|handle_invoke_map|in_buff' \
contrib/epee/include/epee/net contrib/epee/include/epee/storages \
--glob '*.h' --glob '*.hpp' --glob '*.cpp' --glob '*.inl' \
| head -n 500Repository: Beldex-Coin/beldex Length of output: 50374 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- binary reader array and packet bounds ---'
sed -n '40,145p' contrib/epee/include/epee/storages/portable_storage_from_bin.h
sed -n '215,250p' contrib/epee/include/epee/storages/portable_storage_from_bin.h
sed -n '130,170p' contrib/epee/include/epee/net/levin_protocol_handler.h
sed -n '155,220p' contrib/epee/include/epee/storages/levin_abstract_invoke2.h
printf '%s\n' '--- blob-container deserialization ---'
rg -n -C 12 'perform_serialize_blob_container|serialize_blob_container|blob_container' \
contrib/epee/include/epee/serialization \
--glob '*.h' --glob '*.hpp' --glob '*.cpp'Repository: Beldex-Coin/beldex Length of output: 14352 🏁 Script executed: #!/bin/bash
set -euo pipefail
sed -n '180,290p' contrib/epee/include/epee/serialization/keyvalue_serialization_overloads.h
rg -n -C 15 'unserialize_stl_container_pod_val_as_blob|serialize_stl_container_pod_val_as_blob|MAX_STRING_LEN_POSSIBLE' \
contrib/epee/include/epee \
--glob '*.h' --glob '*.hpp' --glob '*.cpp'Repository: Beldex-Coin/beldex Length of output: 24708 Reject oversized
🤖 Prompt for AI Agents |
||
| MLOG_P2P_MESSAGE("Received NOTIFY_REQUEST_CHAIN (" << arg.block_ids.size() << " blocks"); | ||
| NOTIFY_RESPONSE_CHAIN_ENTRY::request r; | ||
| if(!m_core.find_blockchain_supplement(arg.block_ids, r)) | ||
|
|
@@ -2514,6 +2522,13 @@ skip: | |
| { | ||
| MLOG_P2P_MESSAGE("Received NOTIFY_RESPONSE_BLOCK_FLASHES: txs.size()=" << arg.txs.size()); | ||
|
|
||
| if (arg.txs.size() > CURRENCY_PROTOCOL_MAX_TXS_REQUEST_COUNT) | ||
| { | ||
| LOG_ERROR_CCONTEXT("Too many flash transactions received: " << arg.txs.size() << " (maximum " << CURRENCY_PROTOCOL_MAX_TXS_REQUEST_COUNT << ")"); | ||
| drop_connection(context, false, false); | ||
| return 1; | ||
| } | ||
|
|
||
|
Comment on lines
+2525
to
+2531
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 12 \
'handle_request_block_flashes|get_mined_flashes|NOTIFY_RESPONSE_BLOCK_FLASHES|CURRENCY_PROTOCOL_MAX_TXS_REQUEST_COUNT' \
--glob '*.h' --glob '*.hpp' --glob '*.cpp' --glob '*.inl' . || trueRepository: Beldex-Coin/beldex Length of output: 31334 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- handler and producer implementation ---'
sed -n '2488,2555p' src/cryptonote_protocol/cryptonote_protocol_handler.inl
sed -n '630,680p' src/cryptonote_core/tx_pool.cpp
printf '%s\n' '--- all flash request construction and dispatch sites ---'
rg -n -C 8 \
'NOTIFY_REQUEST_BLOCK_FLASHES|post_notify<NOTIFY_REQUEST_BLOCK_FLASHES>|heights\.push_back|heights\s*=' \
src tests --glob '*.h' --glob '*.hpp' --glob '*.cpp' --glob '*.inl' || true
printf '%s\n' '--- relevant limit definitions and uses ---'
rg -n -C 4 \
'CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT|CURRENCY_PROTOCOL_MAX_TXS_REQUEST_COUNT|NOTIFY_RESPONSE_BLOCK_FLASHES' \
src tests --glob '*.h' --glob '*.hpp' --glob '*.cpp' --glob '*.inl' || trueRepository: Beldex-Coin/beldex Length of output: 49584 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
import re
handler = Path("src/cryptonote_protocol/cryptonote_protocol_handler.inl").read_text()
pool = Path("src/cryptonote_core/tx_pool.cpp").read_text()
m = re.search(
r'int\s+t_cryptonote_protocol_handler<[^>]+>::handle_request_block_flashes\b.*?'
r'\n\s*}\n\s*//-+\n\s*template<class t_core>\n\s*int\s+t_cryptonote_protocol_handler<[^>]+>::handle_response_block_flashes',
handler,
re.S,
)
assert m, "flash handler region not found"
request_handler = m.group(0)
assert "get_mined_flashes" in request_handler
assert "post_notify<NOTIFY_RESPONSE_BLOCK_FLASHES>(r, context)" in request_handler
assert not re.search(r'get_mined_flashes.*?CURRENCY_PROTOCOL_MAX_TXS_REQUEST_COUNT', request_handler, re.S)
m = re.search(
r'tx_memory_pool::get_mined_flashes\b.*?\n\s*}\n',
pool,
re.S,
)
assert m, "get_mined_flashes implementation not found"
producer = m.group(0)
assert "result.push_back(hashes[i])" in producer
assert "CURRENCY_PROTOCOL_MAX_TXS_REQUEST_COUNT" not in producer
assert not re.search(r'result\.size\(\).*?(?:5000|CURRENCY_PROTOCOL_MAX_TXS_REQUEST_COUNT)', producer, re.S)
print("handle_request_block_flashes forwards the complete get_mined_flashes result.")
print("get_mined_flashes appends every matching hash and has no 5000-item bound.")
print("The response handler rejects a response above CURRENCY_PROTOCOL_MAX_TXS_REQUEST_COUNT before its GET_TXS batching loop.")
PYRepository: Beldex-Coin/beldex Length of output: 427 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- flash-pool capacity and insertion limits ---'
rg -n -C 5 \
'max.*(flash|tx)|flash.*max|max_txpool|max_tx_pool|m_txpool_max_size|m_max.*pool|tx_pool_max|add.*flash|m_flashes|flash_hashes_and_mined_heights' \
src/cryptonote_core src/cryptonote_protocol --glob '*.h' --glob '*.hpp' --glob '*.cpp' --glob '*.inl' || true
printf '%s\n' '--- request handlers and request-size validation ---'
sed -n '288,306p' src/cryptonote_protocol/cryptonote_protocol_defs.h
sed -n '124,140p' src/cryptonote_protocol/cryptonote_protocol_defs.cpp
rg -n -C 15 \
'handle_request_block_flashes|arg\.heights\.size\(\)|NOTIFY_REQUEST_BLOCK_FLASHES' \
src/cryptonote_protocol --glob '*.h' --glob '*.hpp' --glob '*.cpp' --glob '*.inl' || true
printf '%s\n' '--- flash-related configuration ---'
rg -n -i -C 3 \
'flash.*(limit|count|size)|limit.*flash|flash.*pool|pool.*flash' \
src tests --glob '*.h' --glob '*.hpp' --glob '*.cpp' --glob '*.inl' --glob '*.conf' --glob '*.ini' || trueRepository: Beldex-Coin/beldex Length of output: 50375 Limit or batch flash responses before posting them.
🤖 Prompt for AI Agents |
||
| m_core.get_pool().keep_missing_flashes(arg.txs); | ||
| if (arg.txs.empty()) | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.