Skip to content

fix: ssh-audit hardenings #897

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

scop
Copy link
Contributor

@scop scop commented May 24, 2025

Proposed Changes

Brings current ssh-audit output green again, and adds an additional moduli hardening per their recommendations.

# algorithm recommendations (for OpenSSH 9.9)
(rec) !diffie-hellman-group-exchange-sha256 -- kex algorithm to change (increase modulus size to 3072 bits or larger) 
(rec) -curve25519-sha256                    -- kex algorithm to remove 
(rec) [email protected]         -- kex algorithm to remove 
(rec) -diffie-hellman-group16-sha512        -- kex algorithm to remove 
(rec) -diffie-hellman-group18-sha512        -- kex algorithm to remove 

Summary by CodeRabbit

  • Security Improvements
    • Enhanced SSH configuration by restricting the moduli file to use stronger cryptographic parameters.
    • Broadened the list of disallowed SSH key exchange algorithms to improve security.

Brings current ssh-audit output green again, and adds an additional
moduli hardening per their recommendations.
Copy link

coderabbitai bot commented May 24, 2025

Walkthrough

The changes update the SSH Dockerfile to filter the moduli file for stronger cryptographic parameters and expand the list of disabled key exchange algorithms in the SSH daemon configuration to further restrict weaker or less preferred algorithms.

Changes

File(s) Change Summary
ssh/Dockerfile Adds a hardening step to filter /etc/ssh/moduli for entries with a minimum strength of 3071 bits.
ssh/rootfs/etc/ssh/sshd_config Expands the list of disabled KexAlgorithms to exclude additional key exchange algorithms.

Suggested labels

bugfix

Suggested reviewers

  • frenck

Poem

In the burrow where the strong keys dwell,
The moduli were filtered, their stories to tell.
More algorithms banished, the SSH gate tight,
Security’s garden, now guarded at night.
With every hop and every byte,
This bunny ensures your SSH is right! 🐇🔐

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 88f43c1 and 54735f6.

📒 Files selected for processing (2)
  • ssh/Dockerfile (1 hunks)
  • ssh/rootfs/etc/ssh/sshd_config (1 hunks)
🔇 Additional comments (2)
ssh/Dockerfile (1)

144-147: Excellent SSH moduli hardening implementation.

This change correctly implements the ssh-audit recommendation to filter SSH moduli for stronger cryptographic parameters. The awk command filters /etc/ssh/moduli to retain only entries where the 5th field (prime bit length) is >= 3071, which removes weaker Diffie-Hellman groups and ensures stronger key exchange security. The atomic file replacement pattern is also properly implemented.

ssh/rootfs/etc/ssh/sshd_config (1)

26-26:

❓ Verification inconclusive

Verify compatibility impact of aggressive algorithm restrictions.

This change significantly expands the list of disabled key exchange algorithms, including some that are generally considered secure like curve25519-sha256. While this aligns with strict security recommendations from ssh-audit, it may cause compatibility issues with older SSH clients or specific use cases.

Please verify that this restrictive configuration doesn't break legitimate SSH connections by testing with various client versions and scenarios.


🏁 Script executed:

#!/bin/bash
# Description: Check what key exchange algorithms remain available after these restrictions

# Find the default KexAlgorithms list in OpenSSH
ssh -Q kex

# Show what algorithms would be disabled by this configuration
echo "Disabled algorithms:"
echo "curve25519-sha256,[email protected],diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521"

Length of output: 626


Verify compatibility impact of aggressive algorithm restrictions.

The change in ssh/rootfs/etc/ssh/sshd_config now disables a broad set of KexAlgorithms—including curve25519-sha256 variants and several DH/NIST curves—that are normally enabled by default. Since these algorithms are widely supported and often negotiated by modern SSH clients, this configuration may break connections with certain clients or automated tooling.

To confirm no legitimate use cases are impacted, please:

• On your target SSH server (with the exact OpenSSH version you’re deploying), run:

ssh -Q kex

to list the remaining key-exchange algorithms after these exclusions.
• Verify successful SSH logins (interactively and non-interactively) from representative clients, including older versions and any specialized tooling that relies on default KEX lists.
• If you discover missing support, consider re-enabling specific secure algorithms (e.g. curve25519-sha256) rather than disabling the full default set.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@@ -23,7 +23,7 @@ HostKey /data/ssh_host_ed25519_key
# ===================
Ciphers [email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr
MACs -hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,[email protected],[email protected],[email protected]
KexAlgorithms -ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha256
KexAlgorithms -curve25519-sha256,[email protected],diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re removing diffie-hellman-group-exchange-sha256 -- I'm not sure what their "increase modulus size to 3072 bits or larger" recommendation for this algorithm exactly means, but at least leaving it in and making the moduli changes did not result the warning going away.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed jtesta/ssh-audit#334 asking for clarification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant