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

Fix DoS #183 #184

Merged
merged 1 commit into from Dec 2, 2020
Merged

Fix DoS #183 #184

merged 1 commit into from Dec 2, 2020

Conversation

junorouse
Copy link
Contributor

Print warning message when language is a NULL pointer.

Copy link
Contributor

@aburgm aburgm left a comment

Choose a reason for hiding this comment

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

If you are concerned about this, you might also want to consider handling the case of language_id being empty, which would probably lead to the same segmentation fault?

code/commands/view-commands.cpp Outdated Show resolved Hide resolved
@aburgm
Copy link
Contributor

aburgm commented Oct 6, 2020

I'm sorry, I just had another look at #183, and I don't believe this is a correct fix for the issue. Looking at the location of the crash (from #183), we got:

Thread 1 "gobby-0.5" received signal SIGSEGV, Segmentation fault.
0x000055555561d681 in Gobby::TextSessionView::set_language (this=0x0, language=language@entry=0x0) at code/core/textsessionview.cpp:429
429		gtk_source_buffer_set_language(m_buffer, language);

I don't think the problem is that language is NULL, but that this is NULL. In other words, when you make your dbus call with an existing language ID, I would still expect the application to crash, and it is the g_assert(m_current_view != NULL) that needs to be protected with a proper guard, not the language. A NULL language is actually valid, it just disables syntax highlighting altogether (see docs).

I'm not sure why m_current_view would be NULL; are you maybe making the call when there is no document open in Gobby? I think the menu item is greyed out in this case, but maybe the d-bus call can still be made. In that case I would expect many other "invalid" menu actions could be triggered that way as well, leading to similar problems.

@junorouse
Copy link
Contributor Author

@aburgm Sorry, I mislead the root cause of this crash.

are you maybe making the call when there is no document open in Gobby?

  • Yes.

In that case I would expect many other "invalid" menu actions could be triggered that way as well, leading to similar problems.

So the proper solutions might be ...

  1. Patch all the g_assert codes to print warning message instead of crashing.
juno@ubuntu:~/Desktop/gobby$ grep -R 'g_assert(m_current_view != NULL);' .
./code/commands/view-commands.cpp:	g_assert(m_current_view != NULL);
./code/commands/edit-commands.cpp:	g_assert(m_current_view != NULL);
./code/commands/edit-commands.cpp:	g_assert(m_current_view != NULL);
./code/commands/edit-commands.cpp:	g_assert(m_current_view != NULL);
./code/commands/edit-commands.cpp:	g_assert(m_current_view != NULL);
./code/commands/edit-commands.cpp:	g_assert(m_current_view != NULL);
./code/commands/edit-commands.cpp:	g_assert(m_current_view != NULL);
./code/commands/edit-commands.cpp:	g_assert(m_current_view != NULL);
./code/commands/edit-commands.cpp:	g_assert(m_current_view != NULL);
./code/commands/edit-commands.cpp:	g_assert(m_current_view != NULL);
./code/commands/edit-commands.cpp:	g_assert(m_current_view != NULL);
./code/dialogs/goto-dialog.cpp:		g_assert(m_current_view != NULL);
./code/dialogs/goto-dialog.cpp:	g_assert(m_current_view != NULL);
  1. to do nothing and maintain the current logic. (won't fix)

@aburgm
Copy link
Contributor

aburgm commented Oct 8, 2020

Patch all the g_assert codes to print warning message instead of crashing.

This would be fine with me.

to do nothing and maintain the current logic. (won't fix)

But this too. :)

Instead of crashing, print the following warning message and ignore it
when no current view exists.
dbus should not be called when there is no document open.

** (gobby-0.5:78328): WARNING **: 10:01:05.468: No current view exists.
@junorouse
Copy link
Contributor Author

@aburgm I made a patch with the former one.

@junorouse
Copy link
Contributor Author

@aburgm ping!

@aburgm aburgm merged commit 295e697 into gobby:master Dec 2, 2020
@aburgm
Copy link
Contributor

aburgm commented Dec 2, 2020

Looks good to me, sorry for the delay!

@abergmann
Copy link

CVE-2020-35450 was assigned to this issue.

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

Successfully merging this pull request may close these issues.

None yet

3 participants