SSH.NET Fails to Strictly Adhere to SSH Protocol Standards
維護者通常 3 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 42/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- csharp
研究方向
從 RFC 4253 和 RFC 5656 開始,然後重現所描述的兩種情況:大小寫混合的橢圓曲線名稱,以及使用八位元組字串表示 r 和 s 的 ECDSA 簽章。檢視涉及的 SSH.NET 驗證路徑,並為通訊協定邊界情況新增完整的測試。當格式錯誤的名稱和簽章能依照標準一致地被拒絕時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Issue Summary: SSH.NET Fails to Strictly Adhere to SSH Protocol Standards
1. Elliptic Curve Name Case Sensitivity
According to [RFC 5656], the elliptic curve name must strictly match the defined format, which is case-sensitive. For example, nistp256 (all lowercase) is the correct identifier for the NIST P-256 curve. However, SSH.NET incorrectly accepts nistP256 (mixed case) without raising an error.
Observed Behavior:
- SSH.NET tolerates curve names with incorrect case (e.g.,
nistP256), while strict implementations like OpenSSH reject these values, leading to compatibility issues.
Impact:
- This behavior violates the SSH protocol standard, potentially causing interoperability problems with compliant clients/servers.
- It may obscure configuration errors, leading to production issues that are difficult to debug.
Suggested Fix:
- Ensure that SSH.NET strictly enforces case-sensitive validation of elliptic curve names as defined in the standard.
2. Improper Handling of ECDSA Signature Format
The ECDSA signature in SSH must follow the format specified in RFC 4253:
- The signature is an
ecdsa_signature_blobcontaining twompintvalues:rands.
However, SSH.NET does not validate the format of the signature and accepts invalid representations, such as encoding r and s as octet strings instead of mpint.
Observed Behavior:
- When the server sends an invalid ECDSA signature (e.g.,
randsencoded as octet strings), SSH.NET does not report an error. - Strict clients, like OpenSSH, correctly reject such signatures with errors such as "Signature from server's host key is invalid."
Impact:
- Interoperability Risk: Inconsistent behavior when communicating with standards-compliant clients.
- Security Risk: Weak or incorrect signature validation could expose users to potential attacks (e.g., replay attacks or signature forgery).
Suggested Fix:
- Implement strict validation of the
ecdsa_signature_blobto ensurerandsare properly formatted asmpintvalues.
3. Steps to Reproduce
Case Sensitivity Issue:
- Configure SSH.NET to use the
nistP256curve name. - Attempt to connect to a strict client/server, such as OpenSSH.
- Observe that SSH.NET establishes the connection, while OpenSSH rejects the curve name if it’s mismatched.
Invalid ECDSA Signature Issue:
- Set up an SSH server to send an ECDSA signature with
randsencoded as octet strings. - Use SSH.NET to connect to the server.
- Observe that SSH.NET accepts the connection, while OpenSSH fails with a signature validation error.
4. Proposed Actions
- Validation Enforcement: Add strict checks for curve names and signature format in SSH.NET.
- Comprehensive Testing: Introduce test cases to cover protocol edge cases and ensure compliance with RFC standards.
- Community Discussion: Gather feedback on the potential impacts of enforcing stricter validation and provide configuration options if needed.
5. References
- 主要語言
- C#
- 星號
- 4.4k
- 分支
- 988
- 平均合併
- 4 天 22 小時
- 30 天內合併 PR
- 5
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
sshnet/SSH.NET 的其他 Issue
-
Proposal: built-in tracing and metrics via ActivitySource/Meter可能已有人在做 @YoussefElshemi 於 2 天前認領。 未關閉
難度 5/5 一週以上 新手友好度 35/100
sshnet/SSH.NET#1854 · 4 則留言 · 2 個 reaction ·
維護者通常 3 天內回覆
-
難度 4/5 3-5 天 新手友好度 45/100
維護者通常 3 天內回覆
-
難度 4/5 3-5 天 新手友好度 69/100
維護者通常 3 天內回覆
-
難度 3/5 1-2 天 新手友好度 55/100
維護者通常 3 天內回覆
-
難度 5/5 一週以上 新手友好度 45/100
維護者通常 3 天內回覆
相似的 Issue
-
bug effort:S P3
難度 2/5 1-3 小時 新手友好度 85/100
nightscout/nocturne#3093 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 67/100
維護者通常 3 天內回覆
-
難度 1/5 1 小時以內 新手友好度 85/100
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100