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

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

Closed
madeye opened this issue Apr 20, 2020 · 5 comments
Closed

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

madeye opened this issue Apr 20, 2020 · 5 comments

Comments

@madeye
Copy link
Contributor

madeye commented Apr 20, 2020

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

madeye added a commit to madeye/shadowsocks-rust that referenced this issue Apr 20, 2020
@madeye
Copy link
Contributor Author

madeye commented Apr 20, 2020

I tried to fix this via edeff21.

It's tested with ss-local and socksfy (https://www.inet.no/dante/doc/1.3.x/socksify.1.html), and dig works now.

@zonyitoo
Copy link
Collaborator

That's a huge bug!

@zonyitoo
Copy link
Collaborator

zonyitoo commented May 1, 2020

@madeye Could you make a PR for this?

@Mygod
Copy link
Contributor

Mygod commented May 1, 2020

The commit is already in #211 right?

@madeye
Copy link
Contributor Author

madeye commented May 1, 2020

Yes, it's already in that PR.

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

No branches or pull requests

3 participants