shadowsocks / shadowsocks-org

www.shadowsocks.org
MIT License
862 stars 531 forks source link

Redirect attack on Shadowsocks stream ciphers #154

Open chenshaoju opened 4 years ago

chenshaoju commented 4 years ago

Shadowsocks is a secure split proxy loosely based on SOCKS5. It’s widely used in china. However, we found a vulnerability in shadowsocks protocol which break the confdentiality of shadowsocks stream cipher. An attacker can easliy decrypt all the encrypted shadowsocks packet using our redirect attack. As the vulnerability is obvious and easy to exploit. I think the government has already know it. So, using shadowsocks in steam cipher cannot hide yourself from surveillance.

https://github.com/edwardz246003/shadowsocks

riobard commented 4 years ago

Interesting attack. Now we could finally get rid of stream ciphers (after deprecating them for years)!

To clarify: go-shadowsocks2 (not to be confused with the deprecated shadowsocks-go) supports AEAD ciphers from the very beginning, in addition to shadowsocks-libev, so the author's recommendation at the end is slightly incorrect.

Mygod commented 4 years ago

We have had active probing against stream ciphers since forever and that is already enough reason to not use stream ciphers already. (remember OTA?) I think stream ciphers are kept for improving performance if it is used along with plugins (https://github.com/shadowsocks/shadowsocks-libev/pull/2581). Again this is a niche usage of stream cipher and personally I would prefer it gone.

riobard commented 4 years ago

Should we remove all stream ciphers from the officially supported implementations now? Can't wait to delete legacy code! πŸ˜„

ghost commented 4 years ago

Windows implementation will remove all (maybe except few oldest cipher for special case) non-AEAD cipher in next major release. We're rewriting encryption using BouncyCastle, as they are not safe, we needn't implement them now.

riobard commented 4 years ago

@studentmain What's the (rough) time frame for the next major release? And why still keep some old ciphers around? πŸ˜‚

riobard commented 4 years ago

@madeye I'm removing all stream ciphers from go-ss2. Do you have any plan to deprecate them in ss-libev as well?

ghost commented 4 years ago

What's the (rough) time frame for the next major release?

When it down (or we give up).

And why still keep some old ciphers around?

plain/table/rc4/rc4-md5 for speed when user is hidden by plugin .If we finally decide keep them, user need edit config file in order to enable them, that make sure user know what they're doing.(Because of we dropped libsscrypto, they'll have a pure .NET implementation.)

riobard commented 4 years ago

@studentmain So maybe just leave plain (no encryption right?) is enough for plugin use? The most useful plugin is to wrap in TLS so there's no need to encrypt in SS at all.

ghost commented 4 years ago

I'd prefer plain(no encryption, stream cipher format with 0 bit IV) and rc4-md5, rc4-md5 is still wide supported, so user is more likely find a server has it. But it needn't be included in standard.

The reason I mentioned table and rc4 here is just I found their pure and simple C# implemenatation in git history and ported them into current codebase (of course, in personal branch).

madeye commented 4 years ago

The best practice is deprecating stream ciphers, not removing them: https://github.com/shadowsocks/shadowsocks-libev/pull/2581

riobard commented 4 years ago

@studentmain I see, so it's more about removing some dependencies.

@madeye Fair enough. I'm removing them in go-ss2 to force the deprecation.

Mygod commented 4 years ago

@madeye @riobard In general, I think it's a good idea to remove stream cipher (except for plain so user will definitely know what they are doing?) from server-side but keep it on client side (for backwards compatibility) to prevent user outcry. Thoughts?

riobard commented 4 years ago

For go-ss2 I don't need to consider the client-side use case that much as I don't think many people use it as a client???

Mygod commented 4 years ago

I'm actually considering using a golang/rust implementation for shadowsocks-android because libev is too cumbersome to work with... πŸ˜†

riobard commented 4 years ago

Is it easy to embed Go on Android? πŸ˜‚

Mygod commented 4 years ago

Not too hard: https://github.com/shadowsocks/v2ray-plugin-android/blob/e8cd1f3dff69329a0d2d7593ba8cec54e6257cda/app/build.gradle#L53-L69

Although golang has a large stdlib so apk size is going to take a hit.

riobard commented 4 years ago

A few extra MBs shouldn't hurt now that app sizes are usually measured in tens and hundreds of MBs. But I'm not sure about the memory usage on mobile though. Go has a runtime with GC, and it needs some free memory to work well, and on mobile we're actually short on memory. Would the Android OS impose any memory constraint? On iOS that's the major barrier because Network Extensions have some hard limit on memory.

riobard commented 4 years ago

@Mygod Is Android 32-bit or 64-bit?

Mygod commented 4 years ago

@riobard Android doesn't really care about GC and I have no interest in doing iOS. Anyway it sounds like you are proposing that we use rust and I agree. :)

List of ABIs we are building for go on android: https://github.com/shadowsocks/v2ray-plugin-android/blob/e8cd1f3dff69329a0d2d7593ba8cec54e6257cda/app/go-build.bash#L5

riobard commented 4 years ago

If running Go binary is not a major issue on Android, I'm perfectly happy to see you embed it πŸ˜„

Mygod commented 4 years ago

Please continue the discussion at https://github.com/shadowsocks/shadowsocks-android/issues/2452 if you want as we are getting off-topic.

ghost commented 4 years ago

ss-windows deprecated all stream cipher in v4.1.10

According to my recently survey. In 47 users, only 31(65%) user are using AEAD cipher. 12(25%) user are using aes-cfb, 12(25%) user are using chacha20-ietf, 13(27%) user are using rc4-md5. 5(10%) user are using chacha20 or salsa20.