--- /dev/null
+ o Minor features (SOCKS):
+ - Detect invalid SOCKS5 username/password combinations according to
+ new extended parameters syntax. (Currently, this rejects any
+ SOCKS5 username beginning with "<torS0X>", except for the username
+ "<torS0X>0". Such usernames are now reserved to communicate additional
+ parameters with other Tor implementations.)
+ Implements proposal 351.
const char *password =
socks5_client_userpass_auth_getconstarray_passwd(trunnel_req);
+ /* Detect invalid SOCKS5 extended-parameter requests. */
+ if (usernamelen >= 8 &&
+ tor_memeq(username, "<torS0X>", 8)) {
+ /* This is indeed an extended-parameter request. */
+ if (usernamelen != 9 ||
+ tor_memneq(username, "<torS0X>0", 9)) {
+ /* This request is an unrecognized version, or it includes an Arti RPC
+ * object ID (which we do not recognize). */
+ res = SOCKS_RESULT_INVALID;
+ goto end;
+ }
+ }
+
if (usernamelen && username) {
tor_free(req->username);
req->username = tor_memdup_nulterm(username, usernamelen);