[fix] Make the SSH missing host key policy configurable#1441
[fix] Make the SSH missing host key policy configurable#1441MichaelUray wants to merge 1 commit into
Conversation
The SSH connector hardcoded paramiko.AutoAddPolicy, which accepts any unknown device host key without verification. Because the configuration push carries device secrets (WiFi passwords, VPN private keys, PSKs), a man-in-the-middle on the management path could impersonate a device and capture them. Add the OPENWISP_SSH_MISSING_HOST_KEY_POLICY setting (default "paramiko.AutoAddPolicy", preserving the current behaviour) so operators can enforce host key verification, e.g. by setting it to "paramiko.RejectPolicy". When a non-AutoAdd policy is configured the system known hosts are loaded so trusted device host keys can still be verified. Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
📜 Recent review details⏰ Context from checks skipped due to timeout. (10)
🧰 Additional context used📓 Path-based instructions (2)**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{py,html}📄 CodeRabbit inference engine (Custom checks)
Files:
🧠 Learnings (8)📚 Learning: 2026-01-15T15:05:49.557ZApplied to files:
📚 Learning: 2026-02-17T19:13:10.088ZApplied to files:
📚 Learning: 2026-01-15T15:07:17.354ZApplied to files:
📚 Learning: 2026-06-07T12:07:08.468ZApplied to files:
📚 Learning: 2026-06-07T12:07:24.608ZApplied to files:
📚 Learning: 2026-06-25T12:20:18.414ZApplied to files:
📚 Learning: 2026-06-07T12:07:25.164ZApplied to files:
📚 Learning: 2026-06-25T12:20:45.387ZApplied to files:
🔇 Additional comments (6)
📝 WalkthroughWalkthroughAdds the Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant DjangoSettings
participant SSHConnector
participant ParamikoSSHClient
DjangoSettings->>SSHConnector: provide configured host key policy
SSHConnector->>SSHConnector: resolve policy class
alt policy is not AutoAddPolicy
SSHConnector->>ParamikoSSHClient: load system host keys
end
SSHConnector->>ParamikoSSHClient: apply policy instance
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (6 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Nice work on this security hardening. The change makes the SSH missing host key policy configurable while preserving the existing Files Reviewed (4 files)
Reviewed by hy3:free · Input: 43.5K · Output: 3.1K · Cached: 131.8K |
|
Hi @MichaelUray. Thanks for tackling this, its much appreciated. Before we proceed I have a few questions.
|
Problem
The SSH connector hardcodes
paramiko.AutoAddPolicy, which accepts any unknowndevice host key without verification. Since the configuration push carries
device secrets (WiFi passwords, VPN private keys, PSKs), a man-in-the-middle on
the management path could impersonate a device and capture them.
Fix
Add the
OPENWISP_SSH_MISSING_HOST_KEY_POLICYsetting (defaultparamiko.AutoAddPolicy, preserving current behaviour) so operators canenforce host key verification, e.g. by setting it to
paramiko.RejectPolicy.When a non-AutoAdd policy is configured, the system known hosts are loaded so
trusted device host keys can still be verified. Documented in
docs/user/settings.rst.Testing
New tests cover the default policy and the configurable (Reject) policy loading
the known hosts.
./run-qa-checksand the SSH connector tests pass.