Skip to content

ProxySOCKS5 proposes to the server to authenticate using user name and password, even if we don't have any. #1006

@AlainKnaff

Description

@AlainKnaff

Currently, ProxySOCKS5 proposes unconditionally proposes 2 authentications modes to the Socks server:

  buf[lIndex=index++] = 2;
  buf[index++] = 0; // NO AUTHENTICATION REQUIRED
  buf[index++] = 2; // USERNAME/PASSWORD

no matter whether a username and password has been set or not.

With most servers, this is not a problem, as they won't request username/password if no compulsory authentication has been configured on their side, even if the client proposes it.

However, https://f-droid.org/packages/pan.alexander.tordnscrypt.stable/ does take the client up on its offer,even though it would not otherwise need username and password.

With the result that the client fails a couple of lines later:
case 2: // USERNAME/PASSWORD
if (user == null || passwd == null)
break;

If I don't offer USERNAME/PASSWORD if none is supplied, all is ok:

  int lIndex;
  buf[lIndex=index++] = 2;
  buf[index++] = 0; // NO AUTHENTICATION REQUIRED
  if(user != null && passwd != null)
    buf[index++] = 2; // USERNAME/PASSWORD
  buf[lIndex] = (byte) (index - lIndex - 1);
  out.write(buf, 0, index);

Other thing: the exception raised if the above condition happens just says "fail in SOCKS5 proxy", which is a little bit vague, and also ambiguous, because it might happen in 2 different circumstances:

  1. the one described above. => "SOCKS Server requires username/password, but none configured"
  2. if ever the server picks an authentication mechanism which hasn't been offered. => "SOCKS5: Auth mode "+((buf[1]) & 0xff)+" not supported"

Thanks,

Alain

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions