Bitcoin Forum
December 02, 2026, 11:03:21 PM *
News: Latest Bitcoin Core release: 32.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: PSA: Tor nodes and Guards, upgrade OpenSSL to ≥v3.5 for post-quantum encryption!  (Read 49 times)
This is a self-moderated topic. If you do not want to be moderated by the person who started this topic, create a new topic.
nullius (OP)
Copper Member
Hero Member
*****
Offline

Activity: 686
Merit: 2981


Privacy is necessary & sufficient for fungibility.


View Profile WWW
December 01, 2026, 06:00:00 PM
Merited by DireWolfM14 (1), NotATether (1)
 #1

The following is expanded from an off-hand post that I made in the Wall Observer.  I post this enhanced PSA to Development & Technology Discussion, because (a) I hope that more technical users will see it here, and (b) I show the code below.  Given that Tor has been a Bitcoin tradition since Satoshi, and Bitcoin Core has built-in Tor support, I believe it is on-topic here.
[H]e [Satoshi] always used Tor, as far as I can tell.

hahahahahahahahgaha

might as well publish all your secrets now and at least maybe earn money from the book sales and movie rights

Add intercepted Tor traffic.  I’d presume that NSA must have many petabytes/exabytes/whatever of such intercepts saved in their mass-surveillance dragnet’s multibillion-dollar data-hoarding facilities.  Tor very quietly added an opportunistic upgrade last year that makes some of its network opaque to a future QC attacker; most people don’t even know about this.

PSA to all Tor relay operators, especially but not only Guards:  Please upgrade your OpenSSL to version ≥3.5 yesterday.  Any version greater than or equal to three point five.

If your Tor daemon uses system OpenSSL, that’s all it takes to obtain some opportunistic post-quantum encryption.  If your system’ package manager already gave you OpenSSL ^3.5.0 (any release from the v3.5, v3.6, v4.0, or v4.1 branches), you should already be good; the v3.5 branch is the current LTS, which I recommend for Tor relays—and which I’ve extensively tested for this feature.  If your Tor daemon statically links OpenSSL, then you surely know how to compile with a new OpenSSL version, anyway.  This also works with LibreSSL, but I don’t know off the top of my head for which minimum version.

With that upgrade, your relay should automagically use post-quantum key exchange to talk to any other Tor daemons (relays and clients) that have also done the upgrade.  This applies only to the TLS outermost layer of encryption, not to Tor circuits’ onion encryption.

Tor Browser bundles an OpenSSL with an adequate version.  (On desktop; I don’t know how Android works, but I guess it’s probably similar here (?).)  If you use Tor Browser’s bundled Tor, you should automagically use post-quantum TLS with Guards that have adequate OpenSSL.  This does nothing with Guards that don’t have an adequate OpenSSL version; with all such Guards, every layer of your Tor encryption can be retrospectively decrypted by a future attacker with a large quantum computer.

The threat model here is HNDL (aka SNDL) attacks, which are certainly in-scope for Tor.  As more and more Tor nodes upgrade, the Tor network will become increasingly opaque to HNDL attackers.  They’ll be “going dark”, as certain alphabet-soup agencies call it.



Technical information

Tor has multiple layers of encryption.  The outermost layer is TLS.  The TLS layer is outside of all the layered onion-routing encryption, which uses Tor’s own encryption protocol; inside of a single TLS connection between two Tor daemons, Tor circuit connections are multiplexed.

Commit a64db5ad (April 23, 2025, 01:13:04 PM) made Tor daemons use TLS 1.3 X25519MLKEM768 key exchange opportunistically—if and only if both sides support it.  This is hybrid post-quantum encryption; it is expected to be secure against HNDL attacks, including QC retrospective decryption, if either or both of x25519 (ECDH) and/or ML-KEM 768 (Kyber 768) is secure.  It is expected that ML-KEM 768 will remain secure against an attacker who has a large quantum computer—who would/will Shor ECDH, thus decyrpting it almost as easily as rot13.

Code: (git log)
commit a64db5adaf14b72b5eb84d1e097c080815e583aa
Author: Nick Mathewson <nickm@torproject.org>
Date:   Wed Apr 23 09:13:04 2025 -0400

    TLS: When possible, enable ML-KEM768.
   
    Closes ticket 41041.

The issue on TPO’s self-hosted Gitlab:  Could we eliminate or unrestrict our SSL_CTX_set1_groups_list() usage in Tor with OpenSSL? (#41041).  To view it, JavaScript is required. 😿  Their Gitlab has been giving HTTP 403 to Tor exits Roll Eyes, so you should view it on the official Tor Gitlab onion (and verify that it’s official).

AFAIK, the only significant user-facing announcement was in the ChangeLog, when this commit made it into an alpha for the v0.4.9 release branch:

Code: (ChangeLog)
Changes in version 0.4.9.3-alpha - 2025-09-16
  This is the third alpha release and likely the last before going stable.
  This release contains the new CGO circuit encryption. See proposal 359 for
  more details. Several TLS minor fixes which will strengthen the link
  security.

[...]

  o Minor features (security, TLS):
    - When we are running with OpenSSL 3.5.0 or later, support using the
      ML-KEM768 for post-quantum key agreement. Closes ticket 41041.

To understand wtf this actually does, see src/lib/tls/tortls_openssl.c:tor_tls_context_new().  Quoted in pertinent part from the main branch, as of the latest commit that changed this file, bdbd8adc (November 14, 2026, 07:33:28 PM), which fixed a relevant bug for some later OpenSSL releases:

Code: (src/lib/tls/tortls_openssl.c:tor_tls_context_new())
  {
    // We'd like to say something like:
    //    "?X25519MLKEM768:P-256:P-224"
    // to mean that we prefer X25519MLKEM768 if it is present;
    // but we do insist on the presence of  P-256 and P-224.
    //
    // Unfortunately, we support back to OpenSSL 3.0, which did not provide
    // any syntax for saying "don't worry if this group isn't supported."
    // Instead, we have to make this preference list of preference lists.
    static const struct {
      // Minimal version with which to try this syntax.
      // We have to restrict, since older versions of openssl
      // can misunderstand-but nonetheless accept!-syntaxes
      // supported by newer versions.  See #41058 for one example.
      long min_version;
      const char *groups;
    } group_lists[] = {
#if defined(LIBRESSL_VERSION_NUMBER)
      // LibreSSL only supports the old-style, ':'-separated syntax.
      {
        OPENSSL_V_SERIES(4,4,0),
        "X25519MLKEM768:P-256:X25519:P-224"
      },
#endif
      // We do use the ? syntax here, since every version of OpenSSL
      // that supports ML-KEM also supports the ? syntax.
      // We also use the * and / syntaxes:
      //   '*' indicates that the client should send these keyshares.
      //   "/" separates tuples of groups that are "comparably secure".
      //
      // Note that we tell the client to send a P-256 keyshare, since until
      // this commit, our servers didn't accept X25519.
      //
      // Also note that until the upstream LibreSSL bug from tor#41134 gets
      // fixed, the order of groups common between each preference list must
      // be the same. We can't prefer P-256 in one, and X25519 in another.
      {
        OPENSSL_V_SERIES(3,5,0),
        "?*X25519MLKEM768 / ?SecP256r1MLKEM768 / *P-256:?X25519:?P-224"
      },
      { OPENSSL_V_SERIES(3,5,0), "P-256:?X25519:?P-224" },
      { 0, "P-256:X25519:P-224" },
      { 0, "P-256:P-224" },
    };
    bool success = false;
#ifdef LIBRESSL_VERSION_NUMBER
    /* LibreSSL doesn't have an equivalent runtime check to
     * OpenSSL_version_num */
    long our_version = LIBRESSL_VERSION_NUMBER;
#else
    long our_version = tor_OpenSSL_version_num();
#endif
    for (unsigned j = 0; j < ARRAY_LENGTH(group_lists); ++j) {
      const char *list = group_lists[j].groups;
      if (group_lists[j].min_version > our_version) {
        log_info(LD_NET, "Not trying groups %s because of OpenSSL version.",
                 list);
        continue;
      }
      int r = (int) SSL_CTX_set1_groups_list(result->ctx, list);
      if (r == 1) {
        static bool have_logged_already = false;
        if (!have_logged_already) {
          /* say it only once at startup, since the answer won't change */
          log_notice(LD_NET, "Set list of supported TLS groups to: %s", list);
          have_logged_already = true;
        }
        success = true;
        break;
      } else {
        static bool have_warned_failure = false;
        int severity = have_warned_failure ? LOG_INFO : LOG_WARN;
        log_fn(severity, LD_NET, "OpenSSL didn't accept group list %s. "
               "Maybe upgrade? Or report a bug?", list);
        have_warned_failure = true;
      }
    }
    if (! success) {
      log_warn(LD_NET, "No lists of TLS groups were supported. "
               "Using library defaults");
    }
  }

I’ve very carefully, both theoretically and empirically verified what this actually does.  Thus far, however, almost all of my tests and experiments have been run on OpenSSL’s v3.5 (LTS) branch; I need to do more tests on the v4 branches, which have important features not in v3.5.  Some months ago, I did briefly observe what looked like a bug with this in v4, but I didn’t take the time verify it and to figure it out; I need to see if the latest patches fix it, or maybe if the apparent bug was in my own setup.

I run a Tor daemon with my own local patches;


Post-quantum encryption everywhere!

This is the zeroth in a series of posts I will make on various boards, promoting upgrades to post-quantum encryption to protect against HNDL attacks.  (The zeroth, because my thread about GnuPG is the first; I began to draft it on 2026-10-29.)  OpenSSH has had hybrid post-quantum encryption since 2022, GnuPG since 2024, OpenSSL since 2025...  What are you waiting for!?

▄▄████████████████████▄▄
▄███████▀▀██████▀▀███████▄
█████▀██████████████▀█████
████████▄▄██████▄▄████▀███
██████████████████████████
██▄▄██████████████▄▄██████
██▀▀██████████████████▄▄██
██████▀▀██████████████▀▀██
██████████████████████████
███▄████▀▀██████▀▀████████
█████▄██████████████▄█████
▀███████▄▄██████▄▄███████▀
▀▀████████████████████▀▀

 DΞX.fo 
▄▄██████
█████████
██████████
██████████
██████████
█████████
▀▀██████

▄███████
▄██████████
████████████
█████████████
█████████████
|███████▄███▄███▄███▄██
█████████▄▀█████▀▄████
███▄████████▀█▀████████▄
█████████▀███████▀██████
████████████████████████
█▄██▄▀▀▀▀▀██▄▀▄██▀▀▀▀▀▄▀
▄████▄▀▀▀██▀███▀██▀▀▀▄
████████████████████
▀███████████████████▄
█▀████████████████████▄▄
████████████████████████
████████████████████████
███▀███████████████████▀
|
nullius (OP)
Copper Member
Hero Member
*****
Offline

Activity: 686
Merit: 2981


Privacy is necessary & sufficient for fungibility.


View Profile WWW
December 01, 2026, 06:01:25 PM
 #2

Reserved for a table of nullius-tested OpenSSL versions, etc. if/when I extensively test more than v3.5, and/or for other updated technical information.

▄▄████████████████████▄▄
▄███████▀▀██████▀▀███████▄
█████▀██████████████▀█████
████████▄▄██████▄▄████▀███
██████████████████████████
██▄▄██████████████▄▄██████
██▀▀██████████████████▄▄██
██████▀▀██████████████▀▀██
██████████████████████████
███▄████▀▀██████▀▀████████
█████▄██████████████▄█████
▀███████▄▄██████▄▄███████▀
▀▀████████████████████▀▀

 DΞX.fo 
▄▄██████
█████████
██████████
██████████
██████████
█████████
▀▀██████

▄███████
▄██████████
████████████
█████████████
█████████████
|███████▄███▄███▄███▄██
█████████▄▀█████▀▄████
███▄████████▀█▀████████▄
█████████▀███████▀██████
████████████████████████
█▄██▄▀▀▀▀▀██▄▀▄██▀▀▀▀▀▄▀
▄████▄▀▀▀██▀███▀██▀▀▀▄
████████████████████
▀███████████████████▄
█▀████████████████████▄▄
████████████████████████
████████████████████████
███▀███████████████████▀
|
nullius (OP)
Copper Member
Hero Member
*****
Offline

Activity: 686
Merit: 2981


Privacy is necessary & sufficient for fungibility.


View Profile WWW
December 01, 2026, 06:02:01 PM
 #3

Reserved for more technical information.  (I’m just getting started here!)

▄▄████████████████████▄▄
▄███████▀▀██████▀▀███████▄
█████▀██████████████▀█████
████████▄▄██████▄▄████▀███
██████████████████████████
██▄▄██████████████▄▄██████
██▀▀██████████████████▄▄██
██████▀▀██████████████▀▀██
██████████████████████████
███▄████▀▀██████▀▀████████
█████▄██████████████▄█████
▀███████▄▄██████▄▄███████▀
▀▀████████████████████▀▀

 DΞX.fo 
▄▄██████
█████████
██████████
██████████
██████████
█████████
▀▀██████

▄███████
▄██████████
████████████
█████████████
█████████████
|███████▄███▄███▄███▄██
█████████▄▀█████▀▄████
███▄████████▀█▀████████▄
█████████▀███████▀██████
████████████████████████
█▄██▄▀▀▀▀▀██▄▀▄██▀▀▀▀▀▄▀
▄████▄▀▀▀██▀███▀██▀▀▀▄
████████████████████
▀███████████████████▄
█▀████████████████████▄▄
████████████████████████
████████████████████████
███▀███████████████████▀
|
DireWolfM14
Legendary
*
Offline

Activity: 3066
Merit: 6177


فلسطين


View Profile WWW
Today at 07:52:31 PM
Merited by nullius (1)
 #4

I see that the older Debian based distros' default openssl version is 3.0.22 or older, but Debian13's package manager's default calls for 3.5.9.  It might be helpful to compile a list of the distros that are stuck on older versions for those relay operators that are still using older LTS operating systems.  

Debian is my go-to distro, so it's the only one I checked.  And, I know Debian is notoriously slow to update it's default packages.

nullius (OP)
Copper Member
Hero Member
*****
Offline

Activity: 686
Merit: 2981


Privacy is necessary & sufficient for fungibility.


View Profile WWW
Today at 09:54:02 PM
Last edit: Today at 10:51:05 PM by nullius
 #5

Terminology note:  I realized I should explain that X25519MLKEM768 is what OpenSSL calls a “group”, although that’s technically a misnomer here.  You will want to know that terminology, if you are exploring the code or trying to configure something like a webserver.

I see that the older Debian based distros' default openssl version is 3.0.22 or older, but Debian13's package manager's default calls for 3.5.9.

Useful info.  v3.5.10 is out, latest tag on branch openssl-3.5; Debian needs to speed up, as OpenSSL LTS point releases mean CVEs.  Undecided

Code: (git log)
commit 938b2b47eb2a7c2d12fd0f23aa14b560249883ca (tag: openssl-3.5.10)
Author: openssl-machine <openssl-machine@openssl.org>
Date:   Tue Dec 1 14:25:11 2026 +0000

    Prepare for release of 3.5.10
    
    Reviewed-by: Neil Horman <nhorman@openssl.org>
    Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
    Merge-date: Tue Dec  1 14:25:11 2026
    Release: yes

It might be helpful to compile a list of the distros that are stuck on older versions for those relay operators that are still using older LTS operating systems.  

Debian is my go-to distro, so it's the only one I checked.  And, I know Debian is notoriously slow to update it's default packages.

Indeed.  For those who are stuck with an old package, here is a workaround.

I build my own OpenSSL from git, and statically link it into my Tor daemon.  I do not recommend doing this generally; there’s generally no security reason, and it means you need to keep up-to-date with your own builds of both repos.  PITA and error-prone.  However, it gives you an escape hatch for upgrading OpenSSL without fighting your system’s package manager.  It also facilitates development and experimentation, which is why I started to do it years ago—and I guess it has various other specialized use cases.

Tor’s configure has explicit support for static link of OpenSSL—but getting it to work is a bit finicky due to OpenSSL’s weirdness.

Use ip:port of your Tor daemon; user:pass@ gives stream isolation:
Code: (.gitconfig)
[http]
proxy = socks5h://git:password1@192.0.2.1:65536

OpenSSL official repo.
Code:
git clone https://github.com/openssl/openssl

Tor (tpo) official repo.  Current URL, which I’ve had to change a bunch of times since it as a v2 onion for a different host.  Verify that this is gitlab.torproject.org.  Don’t blindly trust me; even if you think I’m trustworthy, always “trust-but-verify” this sort of thing!
Code:
git clone http://eweiibe6tdjsdprb4px6rqrzzcsi22m4koia44kc5pcjr7nec2rlxyad.onion/tpo/core/tor.git/

Important late edit:  Sorry, forgot!  You need to git switch to appropriate branches, openssl-3.5 and for Tor, release-0.4.9 (or maint-0.4.9 if you want).  Or git clone -b <branch> these branches to begin with—if you are only trying to build this, and not interested in Tor/OpenSSL development.

OpenSSL build script excerpt:  Just the tricky part to fit with the Tor build script.  I run it from anywhere, as I hardcode some paths to work with how OpenSSL’s build system works.  I am currently running with v3.5.10 in production, with build options stripping it down to about the minimum of what Tor needs; I have a different build script for v4.

Code: (#!/bin/sh)
prefix="${somewhere}/tls35"

# OSSLSRC is the root of the git repo:
"${OSSLSRC}/Configure" \
        "--prefix=${prefix}" \
        --libdir=lib \
[...]

Tor build script excerpt:  I run it from inside my clone of the Tor repo.

Code: (#!/bin/sh)
ossldir="${somewhere}/tls35/lib"

./autogen.sh # Needed for building from git.
./configure \
"--with-openssl-dir=${ossldir}" \
--enable-static-openssl \
--enable-gpl \
--enable-module-pow

Note:  I make distclean my tor between production builds, just to be extra-sure.  In my experience, that needs to be done before pulling any upstream changes; otherwise, make gets confused.  I build OpenSSL into a separate object directory, which I can simply rm -r.

Another important late edit:  Before deploying my binary, I make test OpenSSL (slooow), and make check Tor (pretty fast).  This is in parts of my build scripts that I didn’t quote.  When deploying your Tor binary, the three most important files (= what you actually need to run an up-to-date Tor) are build tree paths:

  • src/app/tor → /usr/local/bin/tor (or sbin or whatever)
  • src/config/geoip and src/config/geoip6 → /usr/local/share/tor/

(End this edit.  With apologies for the mess, that’s important info.)

Aargh, edit in one more helpful note:  If you’re only building OpenSSL to upgrade your Tor, then you probably want to use OpenSSL’s make install_sw and make uninstall_sw targets for a slimmer/faster (un)installation than the install/uninstall targets.

I see that at some point, I set something logically equivalent to export CPPFLAGS=-I${ossldir}/../include before my configure line for Tor.  However, I don’t think it’s necessary; IIRC, I added it when I was building a security release in a hurry and I’d made a mistake somewhere else.  There is history to each of these lines, and it’s not well-documented outside of my fallible human memory.

Embarrassed  It’s embarrassing that I’m actually not managing these build scripts in git, as I should.  The reason is git’s stupidly insisting on my choice of an identity to commit (user.name and user.email).  It is one thing that I hate about git.



Additional notes

OpenSSL v4 has some new features that are important for webservers, but (thus far) totally irrelevant to the Tor daemon.  To try to settle on v4 for all purposes, when v4.0.0 was first released, I tried it with my Tor and got problems with the opporunistic post-quantum.  The outcome would have been silent failure; I observed it in practice with custom patches to Tor.  It may have been caused by my very nonstandard build of OpenSSL, or it may have been something else.  I shrugged and went back to v3.5 LTS.  Tor and OpenSSL codebases have both substantially changed since that time; before I provide more advice to the public about this, I should re-test a bunch of stuff, as I suggested in OP.

.onion operators will surely want a strategy for post-quantum encryption.  I need to do more research to give advice on two points:

  • Post-quantum E2EE at the application layer.  Major browsers, including Tor Browser (Firefox ESR) support the same X25519MLKEM768 key exchange; if your webserver also does, then the content communicated remains E2EE even against a HNDL QC attacker, even if they deanonymize both endpoints.  At some point, I intend to make a new thread for webserver configurations for post-quantum hybrid encryption in TLS.  Onions have the added problem of obtaining a TLS certificate trusted by Tor Browser.  More to come on this...  I’ve been doing a lot of thinking about this.
      
  • Configuration for your onion’s Tor daemon.  I am very reluctant to give advice here; incorrect advice could be a massive footgun that deanonymizes you right now, to try to protect against future risks.  However, I do have some ideas for trying to preserve at least some location-hiding protection even against HNDL/QC, to mitigate and reduce future risks.  I need to work on it, and see if I can figure out a strategy that I feel comfortable advising people to deploy when their personal safety may be on the line.  I will NOT give any advice that I would not apply myself in the same situation; right now, I’m frankly not sure what I would do, if I ran an onion with a high threat model.

There is yet a huge amount of work to do on all of these issues.

▄▄████████████████████▄▄
▄███████▀▀██████▀▀███████▄
█████▀██████████████▀█████
████████▄▄██████▄▄████▀███
██████████████████████████
██▄▄██████████████▄▄██████
██▀▀██████████████████▄▄██
██████▀▀██████████████▀▀██
██████████████████████████
███▄████▀▀██████▀▀████████
█████▄██████████████▄█████
▀███████▄▄██████▄▄███████▀
▀▀████████████████████▀▀

 DΞX.fo 
▄▄██████
█████████
██████████
██████████
██████████
█████████
▀▀██████

▄███████
▄██████████
████████████
█████████████
█████████████
|███████▄███▄███▄███▄██
█████████▄▀█████▀▄████
███▄████████▀█▀████████▄
█████████▀███████▀██████
████████████████████████
█▄██▄▀▀▀▀▀██▄▀▄██▀▀▀▀▀▄▀
▄████▄▀▀▀██▀███▀██▀▀▀▄
████████████████████
▀███████████████████▄
█▀████████████████████▄▄
████████████████████████
████████████████████████
███▀███████████████████▀
|
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!