Skip to content

Resolved: Failed to invoke gnutls_handshake: An illegal parameter has been received. #13528

Closed

Description

systemd version the issue has been seen with

systemd 243 (243.0-1-arch)

Used distribution

Arch Linux

Expected behaviour you didn't see

$ resolvectl query github.com
github.com: 140.82.118.4                       -- link: wlan0

-- Information acquired via protocol DNS in 89.4ms.
-- Data is authenticated: no

Unexpected behaviour you saw

~ $ resolvectl query github.com
github.com: resolve call failed: All attempts to contact name servers or networks failed

Steps to reproduce the problem

Configure resolved to use Cloudflare DNS and enable DNS over TLS, like that:

~ $ cat /etc/systemd/resolved.conf
[Resolve]
DNS=1.1.1.1
DNSSEC=no
DNSOverTLS=yes

Restart systemd-resolved and observe how name resolution just stopped working. Interesting lines from journal (SYSTEMD_LOG_LEVEL set to debug):

wrz 11 18:47:15 Nidhoggr systemd-resolved[40115]: Retrying transaction 47682.
wrz 11 18:47:15 Nidhoggr systemd-resolved[40115]: Cache miss for github.com IN AAAA
wrz 11 18:47:15 Nidhoggr systemd-resolved[40115]: Transaction 47682 for <github.com IN AAAA> scope dns on */*.
wrz 11 18:47:15 Nidhoggr systemd-resolved[40115]: Using feature level TLS+EDNS0 for transaction 47682.
wrz 11 18:47:15 Nidhoggr systemd-resolved[40115]: Sending query via TCP since UDP isn't supported.
wrz 11 18:47:15 Nidhoggr systemd-resolved[40115]: Using feature level TLS+EDNS0 for transaction 47682.
wrz 11 18:47:15 Nidhoggr systemd-resolved[40115]: Retrying transaction 23197.
wrz 11 18:47:15 Nidhoggr systemd-resolved[40115]: Cache miss for github.com IN A
wrz 11 18:47:15 Nidhoggr systemd-resolved[40115]: Transaction 23197 for <github.com IN A> scope dns on */*.
wrz 11 18:47:15 Nidhoggr systemd-resolved[40115]: Using feature level TLS+EDNS0 for transaction 23197.
wrz 11 18:47:15 Nidhoggr systemd-resolved[40115]: Sending query via TCP since UDP isn't supported.
wrz 11 18:47:15 Nidhoggr systemd-resolved[40115]: Using feature level TLS+EDNS0 for transaction 23197.
wrz 11 18:47:15 Nidhoggr systemd-resolved[40115]: Failed to invoke gnutls_handshake: An illegal parameter has been received.
wrz 11 18:47:15 Nidhoggr systemd-resolved[40115]: Connection failure for DNS TCP stream: Connection refused

This is happening to me only when Cloudflare DNS is used.

Activity

  1. shibumi commented on Sep 20, 2019

    @shibumi

    Yes, it looks like cloudflare is not supporting TLS1.3 and seems like systemd-resolved is trying to speak TLS1.2 with 1.1.1.1. This fails, because of an unknown reason. At least that's what I saw with wireshark. According to a cloudflare employee their are working on TLS1.3, maybe it will get better. https://twitter.com/grittygrease/status/1171103043804286976

    wireshark log

    Google DNS (8.8.8.8) works fine, btw:
    wireshark log google

  2. GrantMoyer commented on Oct 19, 2019

    @GrantMoyer

    I can reproduce this, although the error message has changed somewhat:

    Oct 19 17:01:07 sotha-sil systemd-resolved[14415]: Failed to invoke gnutls_handshake: Error in the push function.
    Oct 19 17:01:07 sotha-sil systemd-resolved[14415]: Connection failure for DNS TCP stream: Connection refused
    
  3. Lekensteyn commented on Oct 20, 2019

    @Lekensteyn
    Contributor

    I reproduced the issue with systemd 243.78-1 and gnutls 3.6.10-1 on Arch Linux. It appears to be a GnuTLS systemd bug.

    The Client Hello sent by systemd-resolved contains a supported_versions extension with TLS 1.2 and TLS 1.3 (in that order). The order should have been reversed. If the server respects the client preference, then it will negotiate TLS 1.2, compliant with https://tools.ietf.org/html/rfc8446#section-4.2.1
    "The extension contains a list of supported versions in preference order, with the most preferred version first."

    Since the server (1.1.1.1 in this case) supports TLS 1.3, but the client indicates a preference for TLS 1.2, the server ends up negotiating TLS 1.2. Compliant with the specification, the server indicates a downgrade https://tools.ietf.org/html/rfc8446#page-32. This signal is most likely what triggers the "An illegal parameter has been received." error on the client side.

    Cloudflare is working on deploying a fix for this GnuTLS systemd bug, but GnuTLS systemd should be fixed too to avoid future interoperability failures between GnuTLS clients systemd-resolved and other implementations.

    The interoperability issue can be reproduced with:

    # fails
    gnutls-cli -p853 1.1.1.1 --priority="NORMAL:-VERS-ALL:+VERS-TLS1.2:+VERS-TLS1.3"
    # succeeds
    gnutls-cli -p853 1.1.1.1 --priority="NORMAL:-VERS-ALL:+VERS-TLS1.3:+VERS-TLS1.2"
    

    I'll submit a patch for systemd-resolved.

  4. shibumi commented on Oct 20, 2019

    @shibumi

    @Lekensteyn Thanks for looking into this. But I have one last question to this. You say that the reason for this issue is the wrong order of TLS algorithms, but why does it work with Googles 8.8.8.8 and TLSv1.3?

  5. Lekensteyn commented on Oct 20, 2019

    @Lekensteyn
    Contributor

    Google presumably uses boringssl for their 8.8.8.8 implementation which ignores the client preference for TLS 1.2 if TLS 1.3 is also reported as supported. This is also the reason why a future 1.1.1.1 change will address this issue.

    Servers using GnuTLS 3.6.9 or earlier will fail. Since GnuTLS 3.6.10, GnuTLS will also respect the server order, see https://gitlab.com/gnutls/gnutls/issues/837

  6. added a commit that references this issue on Oct 21, 2019
    6880558
  7. added a commit that references this issue on Nov 21, 2019
    eb732c2
  8. added a commit that references this issue on Nov 25, 2019
    a915208
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions