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

Prevent memory exhaustion attacks via serialization #56

Open
2 of 4 tasks
ecton opened this issue May 21, 2021 · 1 comment
Open
2 of 4 tasks

Prevent memory exhaustion attacks via serialization #56

ecton opened this issue May 21, 2021 · 1 comment
Labels
bug Something isn't working networking Issues relating to either the networked server or client
Milestone

Comments

@ecton
Copy link
Member

ecton commented May 21, 2021

We shouldn't ever use bincode::deserialize directly. The preferred method is to use the Options trait. The DefaultOptions struct talks about what options are set up by default, and the important part for us is the byte limit.

Technically since PliantDb relies on Fabruic, to truly be preventing it, this issue should also be fixed before closing this one out fully: GitHub issue/pull request detail

For cbor, the situation is more complicated. Here's a devlog describing my experiment of writing my own serialization format. As of this edit (July 13), my thoughts are now that we should:

  • Adopt pbor. And... rename it for goodness sake. (done, now named Pot)
  • Add max_size configuration options to pot
  • Switch wire protocol to Pot (Blocked by Allow sending with other serialization formats fabruic#28)
  • Add a configuration option to the database, and use this single setting for bincode and pot. CBOR isn't an attack vector when it's export-only.
@ecton ecton added the bug Something isn't working label May 21, 2021
@ecton ecton changed the title Prevent memory exhaustion attacks via bincode Prevent memory exhaustion attacks via bincode and cbor Jun 23, 2021
@ecton ecton added this to the v0.1.0 milestone Jul 13, 2021
@ecton ecton changed the title Prevent memory exhaustion attacks via bincode and cbor Prevent memory exhaustion attacks via serialization Jul 13, 2021
@ecton ecton modified the milestones: v0.1.0, 0.1.0-alpha.1 Oct 27, 2021
@ecton
Copy link
Member Author

ecton commented Oct 27, 2021

Made some progress on this today, but mostly just familiarized myself with what needs to be done. I realized that we're currently relying on Fabruic to encode the payload being sent across the wire, and it's using bincode. Currently, the CustomApi Request/Response types are being serialized directly onto this structure. Either we need to switch the Fabruic protocol to Pot (my proposal of allowing this is in khonsulabs/fabruic#28) or we need to wrap the end-user data structure in a pre-serialized Vec that is encoded using Pot.

Outside of that, the plan should be able to be implemented as it was before. To save my future-self some time from pondering the same thing again: The documents are encoded on the client, which means that view map decoding must consider document decoding potentially malicious. Thus, even document deserialization should have a max-size option, but perhaps it should be independent from the settings used for the wire protocol. This is possible because the document is serialized as a Vec before being placed into the wire protocol's structure.

@ecton ecton moved this to Todo in Beta Roadmap Oct 27, 2021
@ecton ecton added the networking Issues relating to either the networked server or client label Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working networking Issues relating to either the networked server or client
Projects
Status: Todo
Development

No branches or pull requests

1 participant