Skip to content
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

Socks5 Compatible with multiple authentication methods #14036

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

Conversation

lvxiao1
Copy link

@lvxiao1 lvxiao1 commented May 6, 2024

SOCKS5 encoder and decoder are both limited to only performing username password authentication. Such a design obviously violates the SRP. Whether authentication methods are supported should be handled by the application layer rather than the encoding layer. Besides, when we implement other authentication methods, we have to rewrite these decoders and encoders.

Copy link
Contributor

@chrisvest chrisvest left a comment

Choose a reason for hiding this comment

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

The DefaultSocks5PasswordAuthRequest/Response are only concerned with password auth, not other auth types.

I don't think this is going in the right direction for adding support for other auth modes.

if (version != 1) {
throw new DecoderException("unsupported subnegotiation version: " + version + " (expected: 1)");
}
Socks5AuthMethod authMethod = Socks5AuthMethod.valueOf(version);
Copy link
Contributor

Choose a reason for hiding this comment

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

version is not an auth mode tag

@@ -75,7 +75,7 @@ private static void encodeAuthMethodResponse(Socks5InitialResponse msg, ByteBuf
}

private static void encodePasswordAuthResponse(Socks5PasswordAuthResponse msg, ByteBuf out) {
out.writeByte(0x01);
out.writeByte(msg.authMethod().byteValue());
Copy link
Contributor

Choose a reason for hiding this comment

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

No, version is always 1

@lvxiao1
Copy link
Author

lvxiao1 commented May 7, 2024

The DefaultSocks5PasswordAuthRequest/Response are only concerned with password auth, not other auth types.

I don't think this is going in the right direction for adding support for other auth modes.

The SOCKS5 protocol does not specify messages format for other authentication methods, so it is an unpredictable variation. Removing the restriction of the authentication method being set to 1 allows for better scalability and reuse. We have a requirement that newly connected customer accounts and passwords need to be encrypted instead of using plaintext, but it also needs to be compatible with the plaintext of old customers. Therefore, there will be two different authentication methods, but the decoding and encoding behaviors are consistent.

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.

None yet

2 participants