Skip to content
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

send dialog and plumbing does not handle over-long memos #323

Closed
hdevalence opened this issue Dec 28, 2023 · 11 comments
Closed

send dialog and plumbing does not handle over-long memos #323

hdevalence opened this issue Dec 28, 2023 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@hdevalence
Copy link
Member

hdevalence commented Dec 28, 2023

  1. generate a 512-byte memo plaintext, this is longer than the limit (the address and the text together are 512 bytes)
Python 3.9.6 (default, Nov 10 2023, 13:38:27)
[Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 'aaaaaaa ' * (512//8)
  1. paste into memo field in send dialog
  2. tx approval popup appears, click approve
  3. tx build fails with inscrutable error message
Screenshot 2023-12-28 at 2 30 58 PM

two problems here:

  1. form should be doing input validation on memo length
  2. errors should be propagated back to user
@turbocrime
Copy link
Contributor

turbocrime commented Dec 31, 2023

after some investigation, 'unreachable' is fully accurate: the wasm call throws a RuntimeError.unreachable. so as far as the extension and webapp can handle, propagation is correct.

we can wrap every impl's wasm calls in try/catch to add more detail, but it might be more correct to throw meaningful errors from wasm, either in wasm-ts, wasm-bundler, or from wasm itself

@turbocrime
Copy link
Contributor

it's worth considering that errors may contain potentially sensitive information

connectrpc has chosen deliberately to obfuscate errors in implementations as generic "internal" errors, unless they are thrown specifically as a ConnectError: connectrpc/connect-es#341

in the course of #295 we took the opposite attitude, but in routing-refactor #282 this behavior of obfuscating internal errors resumes, as we're now 'properly' using connectrpc server tooling

i'm going to add catch/rethrows around every wasm call in routing-refactor, and convert existing throws to ConnectError throws, as those are clearly intended to be explicitly returned

we should identify errors that might leak information

@hdevalence
Copy link
Member Author

Huh, that's very surprising. It seems like a very strange policy to me, since if a server is leaking sensitive info in its error messages that's a problem with the server, and censoring errors from one particular client doesn't really fix that.

@hdevalence
Copy link
Member Author

hdevalence commented Jan 2, 2024

i'm going to add catch/rethrows around every wasm call in routing-refactor, and convert existing throws to ConnectError throws, as those are clearly intended to be explicitly returned

Hmm, maybe we should wait to figure out if there's another solution before we go and add boilerplate code to all of our handlers. My instinct is that I don't think we should be doing any connect-specific error handling. We need to ensure that the extension's view server is just like any other, and that it would be possible (in principle) to swap it out for a network call to pclientd. The pclientd code will be using grpc-web, not connect, so it won't do any connect-specific error handling.

If this problem is caused by an upstream tooling choice, we should pause and wait to think through a solution before solving it, rather than adding wrappers around all of our code.

@turbocrime
Copy link
Contributor

turbocrime commented Jan 2, 2024

the choice is made to assist in correct implementation. you can still choose to throw from the service if you'd like, but the default is to obfuscate, and i think that's a good default.

upstream tooling is not causing a specific problem, the wasm implementation we currently have is failing to throw anything meaningful

my last comment was anticipating some issues in my refactor that i just noticed, and perhaps was better placed in the thread for that pr

@grod220
Copy link
Collaborator

grod220 commented Jan 2, 2024

the wasm call throws a RuntimeError.unreachable

Sadly, this likely means that the Rust code panicked. A part of addressing this task should mean finding the part of the Penumbra repo codebase that isn't using the Result/Err type (I suspect it's a .expect() somewhere) and fixing it.

so as far as the extension and webapp can handle

When I ran into this before, I had a hard time wrapping this in a try/catch on the javascript side. It's more like the whole process aborts.

but in routing-refactor #282 this behavior of obfuscating internal errors resumes, as we're now 'properly' using connectrpc server tooling

Obfuscating errors feels like a very painful road to continue on. This makes debugging user errors essentially impossible and turns troubleshooting into 🤷‍♂️ . I don't see why we wouldn't be more expressive in error messages and choose to intentionally throw ConnectError so that the web app can give meaningful feedback to users.

@turbocrime
Copy link
Contributor

ae2b745 in #282 catching all wasm calls in impls and logging all errors thrown out of impls

@turbocrime
Copy link
Contributor

ae2b745 reverted. current state is:

  • landed form validation
  • not performing validation in js impl
  • impl throws correctly propagate to client
  • wasm error messages are not meaningful

@grod220 grod220 moved this from 🗄️ Backlog to 📝 Todo in Penumbra web Jan 4, 2024
@grod220 grod220 added the bug Something isn't working label Jan 5, 2024
@turbocrime
Copy link
Contributor

length used in #329 was incorrect. wasm uses an 80-byte address in the memo, not a BECH32 address, so the boundary is 432/433

@turbocrime
Copy link
Contributor

#356 correct memo length in form validation

@github-project-automation github-project-automation bot moved this from 📝 Todo to ✅ Done in Penumbra web Jan 11, 2024
@turbocrime
Copy link
Contributor

view service validation merged penumbra-zone/penumbra#3585

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

3 participants