Comment 4 for bug 1410839

Revision history for this message
costales (costales) wrote : Re: [Bug 1410839] Re: Shell Command injection in ufw_backend.py

Hi! I was thinking about this...

I think, as you said, the vulnerability could be the import/export by
the path. I added these lines for check that:
=== modified file 'gufw/view/gufw.py'
--- gufw/view/gufw.py 2014-12-13 15:33:17 +0000
+++ gufw/view/gufw.py 2015-01-16 15:51:03 +0000
@@ -344,6 +344,12 @@

      def on_menu_import_activate(self, widget, data=None):
          import_profile = self._file_dialog('open', _("Import Profile"))
+
+ # Shell injection?
+ if not os.path.exists(import_profile):
+ self.show_dialog(self.winMain, _("Path not valid"),
_("Please, report a bug here http://bugs.launchpad.net/gui-ufw"))
+ return
+
          profile = os.path.basename(import_profile) #Filename
          profile = os.path.splitext(profile)[0] # Ext

@@ -367,6 +373,11 @@
      def on_menu_export_activate(self, widget, data=None):
          export_profile = self._file_dialog('save', _("Export Profile"))

+ # Shell injection?
+ if not os.path.exists(export_profile):
+ self.show_dialog(self.winMain, _("Path not valid"),
_("Please, report a bug here http://bugs.launchpad.net/gui-ufw"))
+ return
+
          if not export_profile:
              self.set_statusbar_msg(_("Export cancelled"))
              return

In other way, I think the profile name can't give a Shell injection,
because the init profiles are read as regular files from
/etc/gufw/*.profile, a new profile will be check this pattern:
^[A-Za-z0-9_-]*$ and a deleted profile will have the previous patter or
it will be a regular file.

What do you think? :)

Thanks a lot for your awesome feedback!
Costales