Opened 11 months ago

Closed 11 months ago

Last modified 11 months ago

#28332 closed defect (duplicate)

Nyx configurashion editor reproducibly crashes if custom ordering is set

Reported by: wagon Owned by: atagar
Priority: Medium Milestone:
Component: Core Tor/Nyx Version: Tor: 0.3.4.9
Severity: Normal Keywords: config
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Nyx 2.0.4 at Linux. How to reproduce:

  1. Go to configuration editor.
  2. Press s and select the following order: Is Set, Name, Description.
  3. "Toggle filtering" by pressing a.
  4. Nyx immediately crashes with the following log:
    Traceback (most recent call last):
      File "/usr/local/bin/nyx", line 9, in <module>
        load_entry_point('nyx==2.0.4', 'console_scripts', 'nyx')()
      File "/usr/local/lib/python3.4/dist-packages/nyx/__init__.py", line 176, in main
        nyx.starter.main()
      File "/usr/local/lib/python3.4/dist-packages/stem/util/conf.py", line 289, in wrapped
        return func(*args, config = config, **kwargs)
      File "/usr/local/lib/python3.4/dist-packages/nyx/starter.py", line 118, in main
        nyx.curses.start(nyx.draw_loop, acs_support = config.get('acs_support', True), transparent_background = True, cursor = False)
      File "/usr/local/lib/python3.4/dist-packages/nyx/curses.py", line 217, in start
        curses.wrapper(_wrapper)
      File "/usr/lib/python3.4/curses/__init__.py", line 94, in wrapper
        return func(stdscr, *args, **kwds)
      File "/usr/local/lib/python3.4/dist-packages/nyx/curses.py", line 215, in _wrapper
        function()
      File "/usr/local/lib/python3.4/dist-packages/nyx/__init__.py", line 243, in draw_loop
        keybinding.handle(key)
      File "/usr/local/lib/python3.4/dist-packages/nyx/panel/__init__.py", line 84, in handle
        self._action()
      File "/usr/local/lib/python3.4/dist-packages/nyx/panel/config.py", line 258, in _toggle_show_all
        self._sort_content()
      File "/usr/local/lib/python3.4/dist-packages/nyx/panel/config.py", line 325, in _sort_content
        self._all_content = sorted(self._all_content, key = lambda entry: [entry.sort_value(field) for field in self._sort_order])
      File "/usr/local/lib/python3.4/dist-packages/nyx/panel/config.py", line 325, in <lambda>
        self._all_content = sorted(self._all_content, key = lambda entry: [entry.sort_value(field) for field in self._sort_order])
      File "/usr/local/lib/python3.4/dist-packages/nyx/panel/config.py", line 325, in <listcomp>
        self._all_content = sorted(self._all_content, key = lambda entry: [entry.sort_value(field) for field in self._sort_order])
      File "/usr/local/lib/python3.4/dist-packages/nyx/panel/config.py", line 128, in sort_value
        return self.description
      File "/usr/local/lib/python3.4/dist-packages/nyx/panel/config.py", line 148, in description
        return getattr(manual(self.name), 'description')
    AttributeError: 'NoneType' object has no attribute 'description'
    

I guess it would also crash with many other types of ordering.

Child Tickets

Attachments (1)

log.png (5.6 KB) - added by wagon 11 months ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 11 months ago by atagar

Resolution: duplicate
Status: assignedclosed

Hi wagon, I just tried those repro steps with the current nyx and stem git codebases. No crash. Please give those a try.

This looks to be a case of: https://trac.torproject.org/projects/tor/ticket/24401

comment:2 Changed 11 months ago by wagon

I don't know how to use git version safely. I guess it is not even signed. Could you post a tarball and its sig for current developers version? You could add the links here in Sec. "Python Package Index" and regularly update them (each month or week, so it could be an analog of "alpha" versions).

Last edited 11 months ago by wagon (previous) (diff)

comment:3 Changed 11 months ago by atagar

Hi wagon. Git is pretty simple - simply run 'git clone https://git.torproject.org/nyx.git'. Gi

Version 0, edited 11 months ago by atagar (next)

comment:4 Changed 11 months ago by wagon

simply run git clone ​https://git.torproject.org/nyx.git

So, I can install on my system any trojan, run it, and later verify that this trojan was OK? No, it doesn't work this way. Once you installed it in /usr, and once it touched some important files, your system cannot be trusted again.

Well, I can clone it in some virtual machine and (suppose) verify it by the last commit. Then, what's the next? I need to move this trusted tree to my main system, where old nyx was installed using pip3. As I understand, git nyx version is not a python package, so it is not that simple. Either I have to learn how to install it to some local directory in parallel to main installation, or figure out how to replace all files of existing installation manually.

And all of that just because you cannot give a link to current version with singed tarball. I spent few days to commit my tickets, I'm not payed for it, and I am not eager to learn git and pip3 internals now only to commit a couple of more tickets. I'm sorry.

Last edited 11 months ago by wagon (previous) (diff)

comment:5 Changed 11 months ago by atagar

So, I can install on my system any trojan, run it, and later verify that this trojan was OK? No, it doesn't work this way.

Ummm... no. It doesn't.

moirai:~% cd /tmp

moirai:/tmp% git clone https://git.torproject.org/nyx.git
Cloning into 'nyx'...
remote: Counting objects: 13147, done.
remote: Compressing objects: 100% (36/36), done.
remote: Total 13147 (delta 17), reused 0 (delta 0)
Receiving objects: 100% (13147/13147), 10.73 MiB | 2.10 MiB/s, done.
Resolving deltas: 100% (10090/10090), done.
Checking connectivity... done.

moirai:/tmp% cd nyx

moirai:/tmp/nyx% git rev-parse HEAD
d3dd23cec8cab7eea4969d0c462a2e1abfa5b19d

[ ok, the cryptographic signature is correct ]

moirai:/tmp/nyx% ./run_nyx --help

There's no need to install, and if you have the HEAD signature that can be used for verification just the same as a gpg signed tarball. It provides the same thing. The only thing you *can't* safely trust is this message from me that's providing you with the above signature. If a meanie snagged my trac password, exploited the Tor git repository (to circumvent the https), and MITM your connection you're completely right - someone could do something nasty.

But this is both requires the exploitation of multiple core Tor systems (in which case honestly your system is the least of our worries) and it wouldn't exploit root since nyx does not need to be installed to /usr.

Anywho, if you're still worried I can pgp sign this message later. I'm at work at the moment so I don't have my keys handy but if you're really that worried let me know.

Last edited 11 months ago by atagar (previous) (diff)

comment:6 Changed 11 months ago by wagon

it wouldn't exploit root since nyx does not need to be installed to /usr

Then it cannot find Stem:

$ pip3 list | grep stem
stem (1.7.0-dev)
$ ./run_nyx --help
Traceback (most recent call last):
  File "./run_nyx", line 7, in <module>
    import nyx
  File "[/path/to]/nyx/nyx/__init__.py", line 54, in <module>
    import stem
ImportError: No module named stem

If a meanie snagged my trac password, exploited the Tor git repository (to circumvent the https), and MITM your connection you're completely right - someone could do something nasty. But this is both requires the exploitation of multiple core Tor systems (in which case honestly your system is the least of our worries)

There is good security practice: sign your code. It is much simpler than thinking about possible ways of exploitation.

if you're still worried I can pgp sign this message later.

I am not hurry with this. Please, sign it when you will have time.

comment:7 Changed 11 months ago by atagar

Then it cannot find Stem

Gotcha. Personally I just clone a copy of stem into nyx's directory or add a symlink for wherever it's located. Here's what I usually do...

% git clone https://git.torproject.org/nyx.git
% git clone https://git.torproject.org/stem.git

% cd nyx
% ln -s ../stem/stem stem

I am not hurry with this. Please, sign it when you will have time.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

As of 11/6/18 the master branches of Stem and Nyx reference the following
commits...

* Stem (git clone https://git.torproject.org/stem.git)

  atagar@morrigan:~/Desktop/stem$ git rev-parse origin/master
  c15c8a5af1f7a9a85a092b932f380b4823ebe86d

* Nyx (git clone https://git.torproject.org/nyx.git)

  atagar@morrigan:~/Desktop/nyx$ git rev-parse origin/master
  d3dd23cec8cab7eea4969d0c462a2e1abfa5b19d

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQEcBAEBAgAGBQJb4eKPAAoJEIiEBMGH8waQ3lEH/iwkvkKS3MyOTm84Bz9HFQzW
ZxEjQlKKgD4tW98Ig+B988AB95F712AT1cvAfedMMbPeJL7BhFnXvxJ47eLIig8O
kit32erXhYEBbBRLLGPCdpNLzqdpSAZhkwS9azugUlGfSFRVUMqRNgZPMVnp9ABe
3U2EZNtA0UyiDPa62OKx7JXLNmdh6Kgq2vkICcIhVfY+h7FZIrM9wH0+ZLtchQgB
5Bj8YRh84ck5UXe5DiUJjxpo3a8Ivfk51/F9He14GnwufcFNC03IB9kbvW+2PeOb
cFkhSY/4LlOeEwzJ5YgKJPteorLetIt2Lti0DFGrV2T9xzCK2LPd+vC8/namPso=
=tXQm
-----END PGP SIGNATURE-----
Last edited 11 months ago by atagar (previous) (diff)

comment:8 Changed 11 months ago by wagon

Thank you! Now everything works, but we are probably moving to the stage "old bugs fixed, new bugs added".

Stable version (2.0.4) didn't have artifacts during startup. Git version has. I think it is related to your fixes to panels (which were crashing during scrolling). I'll attach screenshot. Left scrolling panel is connected to upper symbols, some words are changed (hidden]n] instead of hidden], and file.e instead of file). I checked few terminals, and it is everywhere. It is easily fixed if after startup I refresh the terminal with Ctrl+L, but should it be fixed anyway?

Another thing is more essential: stable version displayed cpu usage by Tor and its uptime, but git version doesn't do that. cpu is always 0.0, uptime value is empty. However, if I use root to run git version of Nyx, both cpu and uptime are shown. It looks like permissions issue, but everything else works OK, and I failed to find what's wrong with my setup (stable Nyx worked good also with non-root user).

I think it would be good to have Nyx version also shown at the top. Now it can be accessed through menu, but since you write 'nyx' at the left top corner anyway, why not to add its version too? With tor-prompt it is worse: I cannot see any way to learn its version, even as command-line switch.

Both git and stable tor-prompt have one strange behavior:

$ tor-prompt            
Tor isn't running. Starting a temporary Tor instance for our interpreter to
interact with. This will have a minimal non-relaying configuration, and be
shut down when you're done.

--------------------------------------------------------------------------------

Unable to start tor: Process terminated: Failed to bind one of the listener ports.

But:

$ tor-prompt -i 127.0.0.1:9051
Welcome to Stem's interpreter prompt. This provides you with direct access to
Tor's control interface.

This acts like a standard python interpreter with a Tor connection available
via your 'controller' variable...

  >>> controller.get_info('version')
  '0.2.5.1-alpha-dev (git-245ecfff36c0cecc)'

You can also issue requests directly to Tor...

  >>> GETINFO version
  250-version=0.2.5.1-alpha-dev (git-245ecfff36c0cecc)
  250 OK

For more information run '/help'.

>>> 

Why it doesn't recognize standard port as its default? Is it a bug or feature? If it is the feature, I would make the default to be the opposite: if somebody wants to start extra Tor, he should specify some command-line option.

And the last thing is wrong Nyx log messages (problem exists for both git and stable):

[NYX_NOTICE] Unused configuration entry: unicode_support
[NYX_NOTICE] Unused configuration entry: data_directory
[NYX_NOTICE] Unused configuration entry: acs_support

At first, Nyx always says that these options are "unused" independently on the value in nyxrc config (true or false). My terminal has unicode support, everything looks OK with pseudo-graphics, so I cannot understand why it is "not used". When I disable acs_support, pseudo-graphics is replaced by other symbols, so this option works. But NYX_NOTICE is always "unused" for both acs_support false and acs_support true. Maybe you have added these options, but forgot to update Nyx config validator?

Changed 11 months ago by wagon

Attachment: log.png added

comment:9 Changed 11 months ago by wagon

old bugs fixed, new bugs added

When I am at log window in git Nyx version, some combination of keys ESC, Enter and q transforms Nyx to a state, where any keys pressed is just typed in terminal. Nyx cannot quit, and kill -2 doesn't help, only -9 works. If I look at ps | grep nyx in this moment, as see new lines after Nyx process. I checked what it is: many zeros (0x20) are added to the name of Nyx command at the end. I never experienced this behavior on stable 2.0.4 version. And got this trouble with git version about 3 times. However, I still cannot figure out what is the exact sequence of keys which lead Nyx to this abnormal state.

Note: See TracTickets for help on using tickets.