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

interfaces: recover panics when sanitizing plugs and slots #3208

Closed
wants to merge 2 commits into from

Conversation

zyga
Copy link
Collaborator

@zyga zyga commented Apr 19, 2017

This branch makes snapd more robust against denial of service attacks in case the interface code that is responsible for sanitization of user-controlled plug/slot definition itself panics.

Signed-off-by: Zygmunt Krynicki zygmunt.krynicki@canonical.com

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
This patch switches the interface repository to the new pair of
Sanitize{Plug,Slot} functions that recover panics if the interface
sanitization code panics.

The interface code is processing user input and like it was found in the
following forum thread, it is not immune to errors. This code will
prevent denial-of-service attacks where snapd would otherwise crash when
presented with a potentially malicious snap.

Forum: https://forum.snapcraft.io/t/snapd-service-doesnt-start/319/5
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Copy link
Contributor

@stolowski stolowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good idea, it saves us in cases where a bug in sanitize could paralyze snapd. However I think that it will delay a problem to a later stage (when we do connect), and we will inevitably panic anyway, becacuse addConnectedPlug/Slot method will most likely have similar issue to that of Sanitize (or it will panic explicitely because of missing sanitization).
The code in this PR looks fine, but with the above in mind I think we should in addition either: mark the interface as "broken" and do not attempt to connect it later, or handle panics on connect too. What do you think?

@zyga
Copy link
Collaborator Author

zyga commented Apr 20, 2017

@stolowski but if this code fails it will return an error so sanitize won't work so we won't even add the corresponding plug/slot. No way to connect to something that doesn't exist.

Copy link
Contributor

@stolowski stolowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, of course you are right! +1

@zyga zyga added this to the 2.25 milestone Apr 25, 2017
@niemeyer
Copy link
Contributor

This needs a more detailed conversation, as it's turning the system into an exception mechanism, which panics are not meant to be. Why this and not every single function we call?

Closing for the time being. Let's discuss elsewhere.

@niemeyer niemeyer closed this Apr 26, 2017
@zyga zyga deleted the rfc/recover-panics-on-sanitize branch August 22, 2017 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants