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

Panic in native decryption #171

Open
cole-miller opened this issue Dec 6, 2024 · 5 comments
Open

Panic in native decryption #171

cole-miller opened this issue Dec 6, 2024 · 5 comments
Labels
bug Something isn't working client

Comments

@cole-miller
Copy link

cole-miller commented Dec 6, 2024

Hi, thanks so much for the library!

At Zed we've seen panics in production originating from this unwrap, via Item::secret:

Apparently the encrypted secret read from DBus is sometimes found to be corrupt. To avoid crashing the app in this case we're currently wrapping Item::secret in catch_unwind (zed-industries/zed#21617 )---would you be open to updating oo7 to return an error in this situation instead? I'd be happy to put together a PR if so.

@cole-miller cole-miller changed the title Panic when in native decryption Panic in native decryption Dec 6, 2024
@A6GibKm
Copy link
Collaborator

A6GibKm commented Dec 6, 2024

If there are valid cases where the data is corrupt then it makes sense to return a Result, however I would like to understand first why they are failing in the first place.

@bilelmoussaoui
Copy link
Owner

Indeed. It would be nice to figure out what is the root of the issue as i havent seen it before given all the other apps using the library.

So I would like to know if the app is sandboxed or not, if it is using the dbus backend, what is the server implementation.

I think oo7 should provide enough logs using tracing, so might be worth digging into that and possibly adding more logs if needed.

@cole-miller
Copy link
Author

cole-miller commented Dec 7, 2024

Thanks for the feedback. I agree it would be great to know more about what's going on here; I'll look into adding a bit of telemetry to gather more information and let you know if I find anything. Right now I don't think our panic reports contain enough information to know which oo7 backend is in use, etc.

I do think that from a design standpoint returning an error instead of panicking is the correct choice here. The Secret is loaded from an external source (DBus or the filesystem) that oo7 doesn't entirely control, so finding that the raw loaded data is not valid according to the PKCS7 padding rules doesn't (necessarily) indicate that oo7 has a bug, and doesn't call for crashing the application to avoid operating in an incorrect state. With regard to gathering information about the root cause, that won't be any harder (for Zed at least) if the panic is replaced by an error return.

@A6GibKm
Copy link
Collaborator

A6GibKm commented Dec 7, 2024

The Secret is loaded from an external source (DBus or the filesystem)

Do you know who stored such secret in the filesystem?

@bilelmoussaoui
Copy link
Owner

I opened a PR in #172 that would avoid us from panicking at runtime which is not great. Although, i won't consider it as a fix for this issue as we really need to understand why.

@bilelmoussaoui bilelmoussaoui added bug Something isn't working client labels Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working client
Projects
None yet
Development

No branches or pull requests

3 participants