fix: harden dynamic forwarding, ssh-agent, and EC key parsing#175
Merged
vicajilau merged 2 commits intoJul 1, 2026
Merged
Conversation
Dynamic SOCKS forwarding: - Preserve half-close semantics while streaming: client EOF closes the remote sink and remote EOF destroys the local socket instead of treating EOF as a full connection close immediately. - Guard against concurrent dial attempts for the same SOCKS request. - Cancel the handshake timer before dialing and clean up a tunnel if the connection was closed while dial was in flight. - Tolerate malformed UTF-8 domain names in SOCKS requests and cap handshake buffering at 32 KiB. SSH agent: - Validate that fallback RSA signing produces an SSHRsaSignature with the requested signature type. - Reject zero-length and oversized agent frames to avoid unbounded buffering. EC private keys: - Parse EC PRIVATE KEY curve OIDs when present. - Validate embedded EC public points by deriving the expected public key from the private scalar. - Preserve UnsupportedError for unsupported key types/curves instead of wrapping it as SSHKeyDecodeError. - Decode OpenSSH key comments with allowMalformed to tolerate malformed comments. Adds protocol tests for the dynamic forward hardening and ssh-agent frame size checks.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #175 +/- ##
==========================================
+ Coverage 54.52% 54.59% +0.06%
==========================================
Files 66 66
Lines 5357 5409 +52
==========================================
+ Hits 2921 2953 +32
- Misses 2436 2456 +20
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR contains three small hardening fixes from ServerBox's fork, kept together:
Dynamic SOCKS forwarding
allowMalformed: trueso malformed UTF-8 cannot crash request parsing.SSH agent
SSHRsaSignaturewith the requested signature type.EC private key parsing
EC PRIVATE KEYcurve OIDs when present.UnsupportedErrorfor unsupported key types/curves instead of wrapping it asSSHKeyDecodeError.allowMalformed: trueto tolerate malformed comments.Test plan
dart test test/src/socket/dynamic_forward_io_test.dartdart test test/src/ssh_agent_test.dartdart test test/src/ssh_key_pair_test.dart test/src/ssh_pem_test.dartdart test test/src/socket/dynamic_forward_io_test.dart test/src/ssh_agent_test.dart test/src/ssh_key_pair_test.dart test/src/ssh_pem_test.dart(50 tests)dart analyze lib/src/dynamic_forward_io.dart lib/src/ssh_agent.dart lib/src/ssh_key_pair.dart test/src/socket/dynamic_forward_io_test.dart test/src/ssh_agent_test.dart