Skip to content

The remote address of UDP relay is not handled properly #230

@madeye

Description

@madeye

In shadowsocks/shadowsocks-android#2454, we found shadowsocks-rust handles the UDP relay incorrectly, which cause STUN and DNS (with checking the source address) tests failed.

The bug is related to these lines:

let _ = Address::read_from(&mut cur).await?;

Shadowsocks-rust ignores the "real" source address returned from remote, and didn't construct the relay packet with this address.

let payload = assemble_packet(Address::SocketAddress(src), &pkt);

To fix this issue in socks5-local, we should assemble the packet with the source address from shadowsocks remote.

In other implementations, we simply returns the plain packet (SOCKS5 address + payload) back to the socks5 client:

https://github.com/shadowsocks/shadowsocks-libev/blob/401d32348024f7a0871aef76d436a5a847ef3b5a/src/udprelay.c#L881

In the NAT redir mode, we need to rebind the UDP socket to the the "real" address to let the client think the packet is actually sent from that address.

https://github.com/shadowsocks/shadowsocks-libev/blob/401d32348024f7a0871aef76d436a5a847ef3b5a/src/udprelay.c#L875

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions