Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
Trac
Trac
  • Project overview
    • Project overview
    • Details
    • Activity
  • Issues 246
    • Issues 246
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Operations
    • Operations
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Create a new issue
  • Issue Boards

GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

  • Legacy
  • TracTrac
  • Issues
  • #15961

Closed (moved)
Open
Opened May 08, 2015 by yurivict271@yurivict271

tor fails to handle half-closed TCP connections: it should forward data back on sockets that were shutdown(SHUT_WR) by client

I hit this situation when TCP client sent some data into the socket, then called "shutdown(fd, SHUT_WR)". Tor immediately initiates EOF in return.

However, "shutdown(fd, SHUT_WR)" only shuts down (sends EOF) in one direction. Another direction remains open, and tor should still send EOF into the circuit, receive response from TCP server, and forward it to the client through this half-closed connection, until the TCP server initiates EOF.

The easiest way to reproduce this is to run this script through torsocks:


echo "GET / HTTP/1.0
Connection: close

" | nc -N www.torproject.org 80

It returns no output. Remove "-N" and it will return an output. Run it without torsocks, and it will return output with and without "-N".

"-N" flag causes nc to call shutdown(SHUT_WR) once stdin had EOF.

So this script with -N option demonstrates how tor fails to handle half-closed TCP connections. (older versions of nc had no -N flag, and always called shutdown(SHUT_WR))

The correct behavior here is to keep writing response into such socket until 'write' returns some error condition.

To be fair, squid/DeleGate/nginx proxies all suffer from the same problem. But I believe, TOR should be better than them, and do things the right way.

To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
Tor: unspecified
Milestone
Tor: unspecified
Assign milestone
Time tracking
None
Due date
None
Reference: legacy/trac#15961