Refs #576: Reject control chars in wallet hex inputs#619
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughWallet input normalization now validates against ASCII control characters early. A regex pattern and rejection helper prevent inputs with hidden control bytes from reaching subsequent hex or address validation, with test coverage for wallet registration and transfer endpoints. ChangesControl character validation in wallet inputs
Possibly related PRs
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: c9e1e15c-b79e-4852-a81c-670c9ac1e76f
📒 Files selected for processing (2)
app/wallets.pytests/test_wallet_api.py
a9aa863 to
755aa3d
Compare
|
Review note on current head The implementation in Please extend Evidence inspected: PR diff for |
755aa3d to
e97ab0e
Compare
|
Thanks, that is a fair catch. I extended the same parametrized transfer regression to cover Re-ran validation after the update:
|
eliasx45
left a comment
There was a problem hiding this comment.
Reviewed current head e97ab0e9910a62bb4024d8e6e60c3422ce01154f.
Verdict: approve.
The updated wallet validation is focused and complete for this slice. Public key hex, signature hex, and wallet address normalization now reject raw control characters before trimming/normalization, and the transfer regression covers from_address, to_address, and signature_hex across tab/newline/C1 padding.
Validation:
git diff --check origin/main...HEAD
# clean
git merge-tree --write-tree origin/main HEAD
# 94cee3ca2fb14a29063f7460d32b13c82fd49c16
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ..\mergework\.venv\Scripts\python.exe -m pytest tests\test_wallet_api.py::test_wallet_register_api_rejects_public_key_control_characters tests\test_wallet_api.py::test_wallet_transfer_api_rejects_address_and_signature_control_characters -q
# 6 passed
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ..\mergework\.venv\Scripts\python.exe -m pytest tests\test_wallet_api.py tests\test_wallets.py -q
# 50 passed
..\mergework\.venv\Scripts\python.exe -m py_compile app\wallets.py tests\test_wallet_api.py
# passed
..\mergework\.venv\Scripts\python.exe -m ruff check app\wallets.py tests\test_wallet_api.py
# All checks passed
..\mergework\.venv\Scripts\python.exe -m ruff format --check app\wallets.py tests\test_wallet_api.py
# 2 files already formatted
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ..\mergework\.venv\Scripts\python.exe -m mypy app\wallets.py
# Success: no issues found in 1 source file
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ..\mergework\.venv\Scripts\python.exe scripts\docs_smoke.py
# docs smoke ok
No blockers found.
Summary
Evidence
Before this fix, wallet hex/address normalization accepted control-character-padded inputs as clean values. A focused repro showed
/api/v1/wallets/registerreturned200 OKforpublic_key_hexvalues prefixed with\t, suffixed with\n, and prefixed with C1\x85. The same normalization path also accepted control-character-padded transfer addresses and signatures after trimming.Distinctness
app/wallets.pyonly./wallets?q=...), PR Refs #576: Reject control chars in wallet type filters #609 (/wallets/{address}?type=...), PR Refs #576: Reject control chars in account transaction filters #610 (/accounts/{account}?tx_type=...), PR Refs #576: Reject control chars in JSON integer fields #614 JSON integer parsing, PR Refs #576: Reject control chars in MRWK amounts #617 MRWK amount parsing, or PR Refs #406: Reject control chars in public search queries #572 public search-query validation.Validation
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_wallet_api.py::test_wallet_register_api_rejects_public_key_control_characters tests/test_wallet_api.py::test_wallet_transfer_api_rejects_address_and_signature_control_characters -q-> 6 passed, 1 warningPYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_wallet_api.py tests/test_wallets.py -q-> 50 passed, 1 warningPYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest -q-> 488 passed, 1 warninguv run --extra dev ruff check app/wallets.py tests/test_wallet_api.py-> passeduv run --extra dev ruff format --check app/wallets.py tests/test_wallet_api.py-> 2 files already formattedPYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m mypy app/wallets.py-> successPYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python scripts/docs_smoke.py-> docs smoke okgit diff --check-> cleanNo private keys, wallet private material, tokens, signatures, production mutation, admin access, price/liquidity/exchange/bridge/off-ramp claims, or fabricated payout claims are included.
Summary by CodeRabbit
Bug Fixes
Tests