What changed, and why it matters
This commit tightens filename validation in the Monero wallet's remote-control interface (RPC server). It now rejects wallet names that are just '.' or '..', contain a hidden null character, or contain path separators like '/' (and on Windows also '\' and ':'). This prevents callers from tricking the server into opening or creating wallet files outside the intended directory, which could lead to files being written in unexpected places or existing wallets being accessed.
Treat this as a security hardening fix and include it in the next maintenance release. RPC server operators should upgrade; in the meantime, restrict RPC access to trusted clients and avoid exposing the wallet RPC port to untrusted networks. No immediate incident response is required unless the RPC interface is already exposed to adversaries.
Security signals we found
Path-traversal defense: blocks directory separators and parent-directory references in wallet filenames
Null-byte injection defense: rejects embedded NUL characters that could truncate or confuse downstream path handling
RPC input validation hardening in wallet_rpc_server
Platform-specific Windows path separator and drive-colon filtering
Evidence from the diff
The patch replaces a C-style strchr check for ‘/’ with a more comprehensive std::string-based validation in is_valid_wallet_filename(). The new logic rejects ‘.’, ‘..’, embedded NUL bytes (‘\0’), and forward slashes on all platforms, plus backslashes and colons on Windows. The change is defensive hardening against path traversal and directory escape in wallet RPC operations such as create_wallet, open_wallet, or restore_wallet, where a malicious or compromised RPC client could previously supply a filename like ‘../.wallet’ or ‘otherdir/wallet’ to operate outside the configured wallet directory.
Changed components
src/wallet/wallet_rpc_server.cppMonero wallet RPC serveris_valid_wallet_filename() helperInspect captured patch +3 / −6
### src/wallet/wallet_rpc_server.cpp
@@ -191,14 +191,11 @@ namespace
//------------------------------------------------------------------------------------------------------------------------------
bool is_valid_wallet_filename(const std::string &filename, epee::json_rpc::error& er)
{
- const char *ptr = strchr(filename.c_str(), '/');
+ bool invalid = filename == "." || filename == ".." || filename.find('\0') != std::string::npos || filename.find('/') != std::string::npos;
#ifdef _WIN32
- if (!ptr)
- ptr = strchr(filename.c_str(), '\\');
- if (!ptr)
- ptr = strchr(filename.c_str(), ':');
+ invalid = invalid || filename.find_first_of("\\:") != std::string::npos;
#endif
- if (ptr)
+ if (invalid)
{
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
er.message = "Invalid filename";Why this scored 61/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.