Skip to content

chore: Change setup config dkim default key size to 2048 (open-dkim)#3508

Merged
polarathene merged 10 commits intodocker-mailserver:masterfrom
polarathene:chore/open-dkim-change-default-2048
Aug 28, 2023
Merged

chore: Change setup config dkim default key size to 2048 (open-dkim)#3508
polarathene merged 10 commits intodocker-mailserver:masterfrom
polarathene:chore/open-dkim-change-default-2048

Conversation

@polarathene
Copy link
Copy Markdown
Member

@polarathene polarathene commented Aug 28, 2023

Description

I originally raised this change as desired back in a March 2021 discussion (and again by me recently in April 2023 and Aug 2023), detailing why we should be set the default to 2048 (revert rather, as the change from 2048 to 4096 wasn't justified well but got through review).

Additional history for how the default became 4096 is detailed in:

I finally got around to tackling it 🎉 and improved the related DKIM docs and help command output while at it.

The DKIM UX and docs could probably do with some more improvements, but I mostly wanted to address the bad default of 4096-bit default key size. Potentially a breaking change if users rely on implicit defaults with automated config/deployment scripts.


Extra reference from RFC documents

Our docs reference RFC 6376, and I'll update that to reflect changes from RFC 8301 as noted below, and cited in the original March 2021 discussion referenced to motivate this change in DMS.

RFC 8301 3.2 Key Sizes (Jan 2018, Updates: RFC 6376):

Selecting appropriate key sizes is a trade-off between cost, performance, and risk. Since short RSA keys more easily succumb to off-line attacks:

  • Signers MUST use RSA keys of at least 1024 bits for all keys.
  • Signers SHOULD use RSA keys of at least 2048 bits.
  • Verifiers MUST be able to validate signatures with keys ranging from 1024 bits to 4096 bits, and they MAY be able to validate signatures with larger keys
  • Verifiers MUST NOT consider signatures using RSA keys of less than 1024 bits as valid signatures.

Compared to RFC 6376 3.3.3 Key Sizes (Sep 2011), the 1024-bit requirement for signers changed from long-lived keys to ALL keys, and that the verifiers minimum range for validation was raised to 1024-bit from 512-bit.

It additionally notes key size choice should be influenced by:

  • The practical constraint that large (e.g. 4096-bit) keys might not fit within a 512-byte DNS UDP response packet.
  • The security constraint that keys smaller than 1024 bits are subject to off-line attacks.
  • Larger keys impose higher CPU costs to verify and sign email.
  • Keys can be replaced on a regular basis; thus, their lifetime can be relatively short.
  • The security goals of this specification are modest compared to typical goals of other systems that employ digital signatures.

1024-bit should be fine, especially with key rotation and the lower impact to security when compromised vs private keys for other security purposes. 2048-bit should place more of our audience at ease, where those that prefer the perks of smaller key sizes are advised to adopt ECC keys (supported with rspamd, along with RSA fallback).


NOTE: Each commit has a message detailing changes, may provide extra context for review or easier to follow diffs.

Type of change

  • Improvement (non-breaking change that does improve existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update (DONE)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (README.md or the documentation under docs/)
  • New and existing unit tests pass locally with my changes

4096-bit is excessive in size for DKIM key. 2048-bit is plenty.
@polarathene polarathene added area/security area/scripts area/documentation kind/update Update an existing feature, configuration file or the documentation service/security/dkim-dmarc-spf labels Aug 28, 2023
@polarathene polarathene added this to the v13.0.0 milestone Aug 28, 2023
@polarathene polarathene self-assigned this Aug 28, 2023
@polarathene polarathene force-pushed the chore/open-dkim-change-default-2048 branch from dd457e0 to 7e040ba Compare August 28, 2023 07:05
- The examples use `keysize 2048`, but as that's the new default it makes sense to change that.
- Other help text was also revised.
- Last example for domains did not need to demonstrate the other options. Changed example domains to more appropriate values.
Primarily for the change in default key size, but does revise some text to better communicate to the user.
- While the referenced RFC advises 512-bit to 2048-bit key size, we now explicitly discourage `512-bit` as it's not secure. `1024-bit` is still likely safe for most, but `2048-bit` is a good default for those not rotating their keys.
- Adjusted the domains example to match the new `setup config dkim domain` domains example.
- Tip for changing default key size changed to "info" with added clarity of lowering security or increasing it (excessively).
- Rspamd section is minor formatting changes, with the exception of clarifying the "main domain" for the mail accounts is assumed as the DMS FQDN with any subdomain (like `mail.`) stripped away. This is not great, but a legacy issue that needs to be addressed in future.
- `docs-rspamd-override-d` ref removed, and usage replaced with equivalent ref `docs-rspamd-config-dropin`, while `docs-rspamd-config-declarative` ref was not in use and also removed.
- Revised the `<selector>.txt` DNS formatting info section to better communicate with the reader. Additionally it had mixed usage of default `mail` and custom `dkim-rsa` selectors (_file content and output_).
- Adopt the help options format style from the `rspamd-dkim` into `open-dkim` command. And convert `./setup.sh` to `setup`. `selector` option has been implemented. for a while now.
- Update `rspamd-dkim` examples help output to align with `open-dkim` command examples.
- Give both DKIM command tools a consistent description. The two tools differ in support for the `domain` option (_implicit domain sourcing for default account provisioner, and support for multiple domains as input_).
- DKIM docs for LDAP domain support revised to better communicate when explicit domain config is necessary.
`rspamd_dkim.bats`:
- Update assert for command help output.
- Don't bother creating a DKIM key at 512-bit size.

`setup_cli.bats`:
- Update assert for command help output of the `setup config dkim` (OpenDKIM) command.
The linked discussion from 2021 does mention this updated RFC over the original. That removes outdated advice about `512-bit` key length support.

The discussion link is still kept to reference a comment for the reader to better understand the security strength of 2048-bit RSA keys and why larger keys are not worthwhile, especially for DKIM.
Should be fine to be DRY here, not specific to `open-dkim` or `rspamd` generation/support. Previously rspamd lacked support of an equivalent command in DMS.
- Shifted out the info admonition on key size advice out of the content tabs as it's now generic information.
- Indented the 4096-bit warning into this, which is less of a concern as the default for our DKIM generation tools is consistently 2048-bit now.
- Reworked the LDAP and Rspamd multi-domain advice. To avoid causing a bad diff, these sections haven't been moved/merged yet.
Advice for managing domains individually with LDAP and Rspamd extracted out of the content tabs. Default domain behaviour explained with extra info about OpenDKIM + FILE provisioner sourcing extra domains implicitly.
@polarathene polarathene force-pushed the chore/open-dkim-change-default-2048 branch from 7e040ba to c50ba78 Compare August 28, 2023 07:19
@polarathene

This comment was marked as outdated.

@github-actions
Copy link
Copy Markdown
Contributor

Documentation preview for this PR is ready! 🎉

Built with commit: 21c03a9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation area/scripts area/security kind/update Update an existing feature, configuration file or the documentation service/security/dkim-dmarc-spf

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants