Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insecure DH parameters selected by default #12060

Closed
tomato42 opened this issue Jun 5, 2020 · 5 comments
Closed

Insecure DH parameters selected by default #12060

tomato42 opened this issue Jun 5, 2020 · 5 comments
Labels
issue: bug report The issue was opened to report a bug

Comments

@tomato42
Copy link
Contributor

tomato42 commented Jun 5, 2020

When using openssl s_server with RSA keys that are 1024 bit or 2048 bit long OpenSSL will select DH parameters from RFC 5114, a.k.a group 22 and group 23 for IKE.

Those parameters do not use a safe primes, they do have small subgroups, see also https://jhalderm.com/pub/papers/subgroup-ndss16.pdf

This affects both current 1.1.1 (8354f53) and master (c7f837c)

Reproducer:

openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes -subj "/CN=localhost"
openssl s_server -key key.pem -cert cert.pem -www &> openssl.err &
openssl_pid=$!
git clone https://github.com/tomato42/tlsfuzzer
pushd tlsfuzzer
git checkout ffdh-param-matching  # won't be needed after https://github.com/tomato42/tlsfuzzer/pull/668 is merged
git clone https://github.com/tomato42/tlslite-ng .tlslite-ng
ln -s .tlslite-ng/tlslite tlslite
git clone https://github.com/warner/python-ecdsa .python-ecdsa
ln -s .python-ecdsa/ecdsa ecdsa
PYTHONPATH=. python scripts/test-ffdhe-expected-params.py
popd
kill $openssl_pid

tlsfuzzer output:

sanity ...
OK

FFDH parameters check ...
Error encountered while processing node <tlsfuzzer.expect.ExpectServerKeyExchange object at 0x7f68949a6e10> (child: <tlsfuzzer.expect.ExpectServerHelloDone object at 0x7f68949a6e50>) with last message being: <tlslite.messages.Message object at 0x7f68949acc90>
Error while processing
Traceback (most recent call last):
  File "scripts/test-ffdhe-expected-params.py", line 217, in main
    runner.run()
  File "/home/hkario/dev/tlsfuzzer/tlsfuzzer/runner.py", line 239, in run
    node.process(self.state, msg)
  File "/home/hkario/dev/tlsfuzzer/tlsfuzzer/expect.py", line 1147, in process
    self._checkParams(server_key_exchange)
  File "/home/hkario/dev/tlsfuzzer/tlsfuzzer/expect.py", line 1084, in _checkParams
    "received: {0}".format(name))
AssertionError: DH parameters not from valid set, received: RFC5114 group 23

sanity ...
OK

Test to check if server selects the expected DH parameters
See tlslite.mathtls.FFDHE_PARAMETERS for supported names

Test end
====================
version: 1
====================
TOTAL: 3
SKIP: 0
PASS: 2
XFAIL: 0
FAIL: 1
XPASS: 0
====================
FAILED:
        'FFDH parameters check'

Using a larger RSA key, like 3072, will cause OpenSSL to select the secure RFC 3526 group 15 parameters.

(side note: it's possible to specify expected parameters using the --named-ffdh, e.g.: PYTHONPATH=. python scripts/test-ffdhe-expected-params.py --named-ffdh "RFC3526 group 15")

@tomato42 tomato42 added the issue: bug report The issue was opened to report a bug label Jun 5, 2020
@kroeckx
Copy link
Member

kroeckx commented Jun 5, 2020 via email

@tomato42
Copy link
Contributor Author

tomato42 commented Jun 5, 2020

there's BN_get_rfc2409_prime_1024() that does use a safe prime
and of course there's BN_get_rfc3526_prime_2048()

@kroeckx
Copy link
Member

kroeckx commented Jun 5, 2020 via email

@tomato42
Copy link
Contributor Author

tomato42 commented Jun 5, 2020

ok, sketched-out something in #12061

@tomato42
Copy link
Contributor Author

Backport to 1.1.1 branch is in #12160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug report The issue was opened to report a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants