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

PBE default work factor can cause OOM issues on memory-constrained environments #383

Open
tekul opened this issue May 1, 2023 · 0 comments

Comments

@tekul
Copy link

tekul commented May 1, 2023

I'm using PBE within a webapp to encrypt data on a per user basis. This appeared to work Ok, but I noticed my app was dying with an OOM error when I deployed it to fly.io. Further investigation shows that a single scrypt-based encryption is using over 500Mb which seems to be the cause. I've created a repo with the code I used to test the issue and added the output from heaptrack

heaptrack

I would like to be able to limit or set the work factor to cap memory usage - I notice there was a previous PR, #334, which did this, so I can create a fork along similar lines and use that with hard-coded values.

You mentioned a necessary refactor due to plans in the Go implementation to change PBE. Do you have a reference or a link for that? I realise there are different expectations between using a CLI to encrypt files and an API in an app, but it would be nice to have more control in the latter case since I have no control over how the work-factor is assigned on the cloud-based system and the performance-based work-factor estimate will also have an impact on the memory used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant