Opened 5 years ago

Closed 5 years ago

#7598 closed defect (fixed)

STREAM event can have a zero port

Reported by: robinson Owned by: atagar
Priority: Medium Milestone: Tor: 0.2.4.x-final
Component: Core Tor/Tor Version:
Severity: Keywords: events tor-client spec
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Now that there is some event handling, I've begun trying to develop against Stem and I found this crash:

  File "/usr/lib64/python2.7/site-packages/stem/response/events.py", line 55, in _parse_message
    self._parse()
  File "/usr/lib64/python2.7/site-packages/stem/response/events.py", line 459, in _parse
    raise stem.ProtocolError("Source location's port is invalid: %s" % self)
ProtocolError: Source location's port is invalid: STREAM 14 NEW 0 
176.28.51.238.$649F2D0ACF418F7CFC6539AB2257EB2D5297BAFA.exit:443 
SOURCE_ADDR=(Tor_internal):0 PURPOSE=DIR_FETCH

StreamEvent should use is_valid_port(port, allow-zero=True) due to DIR_FETCH.

Child Tickets

Change History (7)

comment:1 Changed 5 years ago by atagar

Component: StemTor
Summary: Crash in StreamEvent handlerSTREAM event can have a zero port

Hi robinson, thanks for the catch! Fixed and added a test for that event...

https://gitweb.torproject.org/user/atagar/stem.git/commitdiff/61b74b1d924abb7be2cbc8e5a8ca7e95c379117e

Next assigning this to Nick to see if the spec can be improved. Questions that I have are...

  1. The STREAM event's Target and SOURCE_ADDR are both defined in the same way...
Target = Address ":" Port
"SOURCE_ADDR=" Address ":" Port

Should the spec be specify that the SOURCE_ADDR's port can be zero? Can the Target's port also be zero?

  1. The 'Address' is defined as...
Address = ip4-address / ip6-address / hostname   (XXXX Define these)

... but in this case the address is "(Tor_internal)". This is a special value that comes from 'connection_edge.c'. We should probably document what it means.

comment:2 Changed 5 years ago by nickm

Keywords: tor-client spec added
Milestone: Tor: 0.2.4.x-final

comment:3 Changed 5 years ago by robinson

atagar,

I've found that Target can also have a zero port for PURPOSE=DNS_REQUEST.

ProtocolError: Target location's port is invalid: STREAM 1113 NEW 0 www.google.com:0
 SOURCE_ADDR=127.0.0.1:15297 PURPOSE=DNS_REQUEST

So, it appears safest to allow_zero=True for both source and target.

comment:4 Changed 5 years ago by atagar

I've found that Target can also have a zero port for PURPOSE=DNS_REQUEST.

Thanks! Fixed and added a test...

https://gitweb.torproject.org/user/atagar/stem.git/commitdiff/994275a169aa8e436549ecb7c70d54c0a8aea891

comment:5 Changed 5 years ago by robinson

These two commits look good.

I would close this ticket, but I am not sure if you want it still open for the information request.

comment:6 Changed 5 years ago by atagar

Parent ID: #7328

I would close this ticket, but I am not sure if you want it still open for the information request.

At this point this ticket is pending a fix for the tor spec. Removing the parent id so this won't keep stem's events ticket open.

comment:7 Changed 5 years ago by nickm

Resolution: fixed
Status: newclosed

Fixed in 3ad9d19e03bd816e1e0f0b9eeb839ee1eedcaedf

Note: See TracTickets for help on using tickets.