Don't hardcode dh params #618

Closed
opened 2026-10-05 04:33:43 +02:00 by adam · 9 comments
Owner
Break the hardcoded DH params and you can break encryption on all ZNCs. - https://github.com/znc/znc/blob/znc-1.6.1/src/Utils.cpp#L44-L51 or is there even a need of breaking? - https://www.eff.org/deeplinks/2015/10/how-to-protect-yourself-from-nsa-attacks-1024-bit-DH - https://freedom-to-tinker.com/blog/haldermanheninger/how-is-nsa-breaking-so-much-crypto/ ## <bountysource-plugin> --- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/27480625-don-t-hardcode-dh-params?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github). </bountysource-plugin> <!-- github-sync-id:111948403 -->
adam closed this issue 2026-10-05 04:33:43 +02:00
Author
Owner

Just to measure things, I generated my own dhparams. This printed three pages of mixtures of dots and pluses and took 6 minutes. In the same time I was using the computer in other ways, so I guess there was more entropy available than in some freshly booted server doing nothing else.

Just to measure things, I generated my own dhparams. This printed three pages of mixtures of dots and pluses and took 6 minutes. In the same time I was using the computer in other ways, so I guess there was more entropy available than in some freshly booted server doing nothing else. <!-- github-comment-id:148909504 -->
Author
Owner

Let me put my two cents.

Firstly, it doesn't take too long to generate the dhparams for 2048bit. Secondly, let's take a page out of webservers: Allow a custom dhparams file to be used.

This then is the logic:

if (CUSTOM DHPARAM PROVIDED) then (USE CUSTOM)
else (USE HARDCODED).

Most webservers seem to still do this type of function. Let people generate the dhparams with OpenSSL or others and then use the custom ones if they have been provided as a config option.

Let me put my two cents. Firstly, it doesn't take too long to generate the dhparams for 2048bit. Secondly, let's take a page out of webservers: Allow a custom dhparams file to be used. This then is the logic: if (CUSTOM DHPARAM PROVIDED) then (USE CUSTOM) else (USE HARDCODED). Most webservers seem to still do this type of function. Let people generate the dhparams with OpenSSL or others and then use the custom ones if they have been provided as a config option. <!-- github-comment-id:148915186 -->
Author
Owner

We allow custom dhparams... It's read from znc.pem.
The default hardcoded one is used only during znc --makepem to write znc.pem

We allow custom dhparams... It's read from `znc.pem`. The default hardcoded one is used only during `znc --makepem` to write `znc.pem` <!-- github-comment-id:148915686 -->
Author
Owner

Custom dhparams on a separate file seem to have become supported (by https://github.com/znc/znc/pull/1192?) or I don't see ZNC complaining about SSLDHParamFile = /home/znc/.znc/ssl/dh.pem.

I am still not sure on the default hardcoded ones though.

Custom dhparams on a separate file seem to have become supported (by https://github.com/znc/znc/pull/1192?) or I don't see ZNC complaining about `SSLDHParamFile = /home/znc/.znc/ssl/dh.pem`. I am still not sure on the default hardcoded ones though. <!-- github-comment-id:519896729 -->
Author
Owner

I dont think they are hard coded in ZNC but in the SSL libs. Which is why we support the params file now...

I dont think they are hard coded in ZNC but in the SSL libs. Which is why we support the params file now... <!-- github-comment-id:519909023 -->
Author
Owner

It's read from SSLDHParamFile, yes, which defaults to ~/.znc/znc.pem. If that file doesn't have DH params, the pregenerated (hardcoded in libssl) one is used.

I don't see the problem.

It's read from `SSLDHParamFile`, yes, which defaults to `~/.znc/znc.pem`. If that file doesn't have DH params, the pregenerated (hardcoded in libssl) one is used. I don't see the problem. <!-- github-comment-id:520095439 -->
Author
Owner

I think the bigger issue here is, that we don't have DHParams. It's almost like this request is "If there are no defined DHParams in znc.pem AND there are no separate dhparam files, generate some.

@Mikaela is this what you're looking for? All libssl driven systems 'inherit' the default DHParams. (We could alter default SSL Ciphers to drop all DHE ciphers (but not ECDHE which uses elliptical curves instead of DHParams))

I think the bigger issue here is, that we don't *have* DHParams. It's almost like this request is "If there are no defined DHParams in znc.pem AND there are no separate dhparam files, generate some. @Mikaela is this what you're looking for? All libssl driven systems 'inherit' the default DHParams. (We could alter default SSL Ciphers to drop all DHE ciphers (but not ECDHE which uses elliptical curves instead of DHParams)) <!-- github-comment-id:520104385 -->
Author
Owner

I am under impression that ZNC has dhparams in https://github.com/znc/znc/blob/znc-1.7.4/src/Utils.cpp#L69-L76 that are put to znc.pem or used by default and that if they are broken (or is that like a private key that doesn't need to be broken as it's there for anyone to see?), the traffic between most of ZNC instances and IRC client is followable by parties such as the NSA as indicated by the articles I linked four years ago.

I don't know about the default parameters of lbssl systems and I am not sure if I even understand DH.

I am under impression that ZNC has dhparams in https://github.com/znc/znc/blob/znc-1.7.4/src/Utils.cpp#L69-L76 that are put to znc.pem or used by default and that if they are broken (or is that like a private key that doesn't need to be broken as it's there for anyone to see?), the traffic between most of ZNC instances and IRC client is followable by parties such as the NSA as indicated by the articles I linked four years ago. I don't know about the default parameters of lbssl systems and I am not sure if I even understand DH. <!-- github-comment-id:520152770 -->
Author
Owner

dhparams are not private. Moreover, if server supports DH at all, it tells the SSL client what the values are.

dhparams are not private. Moreover, if server supports DH at all, it tells the SSL client what the values are. <!-- github-comment-id:520153420 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#618