Reject wallet text control characters#151
Conversation
|
I noticed after opening this that PR #150 was opened a few minutes earlier with the same wallet label/memo control-character scope. This PR differs by checking raw input before trimming and by adding API-level coverage for both register and transfer, which addresses the boundary issue raised on #150. Still, the scope overlaps. Maintainers: please treat #151 as an alternative clean implementation only if useful; if #150 is updated and preferred, I am fine with closing this as duplicate. |
Ckeplinger199
left a comment
There was a problem hiding this comment.
No blockers found.
I reviewed the wallet text control-character change in app/ledger/service.py plus the service/API regressions in tests/test_wallets.py and tests/test_wallet_api.py.
The key correctness point is that this PR checks the raw label/memo input before trimming, so boundary control characters are rejected instead of silently normalized away. I verified labels with leading newline, trailing tab, embedded newline, and DEL were rejected, and transfer memos with leading tab, trailing newline, embedded newline, and DEL were rejected.
Verification on head 8ad4f160045488343406161059e2a8f630d44dc2:
uv run --extra dev python -m pytest tests/test_wallets.py tests/test_wallet_api.py -q-> 29 passeduv run --extra dev python -m pytest tests/test_security.py tests/test_ledger.py tests/test_wallets.py tests/test_wallet_api.py -q-> 66 passed- Ruff format/check on touched files passed
uv run --extra dev python -m mypy app-> Successscripts/check_agents.py,scripts/docs_smoke.py, andgit diff --check origin/main...HEADpassed
The scope overlaps with PR #150, as the author noted, so choosing between them is a maintainer dedupe question. From this PR's own correctness and verification evidence, I found no blocker.
Refs #122
Summary
Why
Wallet labels and transfer memos are public wallet surfaces, but they only had trimming/length checks. A newline or other ASCII control character could be accepted and stored, unlike the newer public URL and bounty text hardening. This keeps wallet-facing text fields on the same validation footing without changing normal labels or memos.
Verification
label="Main\nWallet"andmemo="line1\nline2".python -m pytest tests/test_wallets.py tests/test_wallet_api.py -q-> 29 passedpython -m pytest -q-> 148 passed, 2 warningsruff check app/ledger/service.py tests/test_wallets.py tests/test_wallet_api.py-> All checks passedruff format --check app/ledger/service.py tests/test_wallets.py tests/test_wallet_api.py-> 3 files already formattedmypy app-> Success: no issues found in 11 source filesscripts/docs_smoke.py-> docs smoke okscripts/check_agents.py-> AGENTS.md okgit diff --check-> passedDuplicate check:
No secrets, wallet material, deployment values, private context, or MRWK price claims are included.