bug_13028.patch 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From 2f0888c348561249d3083555db33c5619840dbfa Mon Sep 17 00:00:00 2001
  2. From: Mike Perry <mikeperry-git@torproject.org>
  3. Date: Mon, 29 Sep 2014 14:30:19 -0700
  4. Subject: [PATCH] Bug 13028: Prevent potential proxy bypass cases.
  5. It looks like these cases should only be invoked in the NSS command line
  6. tools, and not the browser, but I decided to patch them anyway because there
  7. literally is a maze of network function pointers being passed around, and it's
  8. very hard to tell if some random code might not pass in the proper proxied
  9. versions of the networking code here by accident.
  10. diff --git a/security/nss/lib/certhigh/ocsp.c b/security/nss/lib/certhigh/ocsp.c
  11. index cea8456606bf..86fa971cfbef 100644
  12. --- a/security/nss/lib/certhigh/ocsp.c
  13. +++ b/security/nss/lib/certhigh/ocsp.c
  14. @@ -2932,6 +2932,14 @@ ocsp_ConnectToHost(const char *host, PRUint16 port)
  15. PRNetAddr addr;
  16. char *netdbbuf = NULL;
  17. + // XXX: Do we need a unittest ifdef here? We don't want to break the tests, but
  18. + // we want to ensure nothing can ever hit this code in production.
  19. +#if 1
  20. + printf("Tor Browser BUG: Attempted OSCP direct connect to %s, port %u\n", host,
  21. + port);
  22. + goto loser;
  23. +#endif
  24. +
  25. sock = PR_NewTCPSocket();
  26. if (sock == NULL)
  27. goto loser;
  28. diff --git a/security/nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_socket.c b/security/nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_socket.c
  29. index e8698376b5be..85791d84a932 100644
  30. --- a/security/nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_socket.c
  31. +++ b/security/nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_socket.c
  32. @@ -1334,6 +1334,13 @@ pkix_pl_Socket_Create(
  33. plContext),
  34. PKIX_COULDNOTCREATESOCKETOBJECT);
  35. + // XXX: Do we need a unittest ifdef here? We don't want to break the tests, but
  36. + // we want to ensure nothing can ever hit this code in production.
  37. +#if 1
  38. + printf("Tor Browser BUG: Attempted pkix direct socket connect\n");
  39. + PKIX_ERROR(PKIX_PRNEWTCPSOCKETFAILED);
  40. +#endif
  41. +
  42. socket->isServer = isServer;
  43. socket->timeout = timeout;
  44. socket->clientSock = NULL;
  45. @@ -1433,6 +1440,13 @@ pkix_pl_Socket_CreateByName(
  46. localCopyName = PL_strdup(serverName);
  47. + // XXX: Do we need a unittest ifdef here? We don't want to break the tests, but
  48. + // we want to ensure nothing can ever hit this code in production.
  49. +#if 1
  50. + printf("Tor Browser BUG: Attempted pkix direct connect to %s\n", serverName);
  51. + PKIX_ERROR(PKIX_PRNEWTCPSOCKETFAILED);
  52. +#endif
  53. +
  54. sepPtr = strchr(localCopyName, ':');
  55. /* First strip off the portnum, if present, from the end of the name */
  56. if (sepPtr) {
  57. @@ -1582,6 +1596,13 @@ pkix_pl_Socket_CreateByHostAndPort(
  58. PKIX_ENTER(SOCKET, "pkix_pl_Socket_CreateByHostAndPort");
  59. PKIX_NULLCHECK_THREE(hostname, pStatus, pSocket);
  60. + // XXX: Do we need a unittest ifdef here? We don't want to break the tests, but
  61. + // we want to ensure nothing can ever hit this code in production.
  62. +#if 1
  63. + printf("Tor Browser BUG: Attempted pkix direct connect to %s, port %u\n", hostname,
  64. + portnum);
  65. + PKIX_ERROR(PKIX_PRNEWTCPSOCKETFAILED);
  66. +#endif
  67. prstatus = PR_GetHostByName(hostname, buf, sizeof(buf), &hostent);
  68. --
  69. 2.27.0