shadowsocks-org icon indicating copy to clipboard operation
shadowsocks-org copied to clipboard

Redirect attack on Shadowsocks stream ciphers

Open chenshaoju opened this issue 5 years ago β€’ 22 comments

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

chenshaoju avatar Feb 12 '20 08:02 chenshaoju

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.

riobard avatar Feb 12 '20 10:02 riobard

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.

Mygod avatar Feb 13 '20 01:02 Mygod

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

riobard avatar Feb 20 '20 09:02 riobard

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.

ghost avatar Feb 20 '20 09:02 ghost

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

riobard avatar Feb 20 '20 09:02 riobard

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

riobard avatar Feb 20 '20 09:02 riobard

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.)

ghost avatar Feb 20 '20 09:02 ghost

@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.

riobard avatar Feb 20 '20 09:02 riobard

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).

ghost avatar Feb 20 '20 09:02 ghost

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

madeye avatar Feb 20 '20 09:02 madeye

@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.

riobard avatar Feb 20 '20 09:02 riobard

@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?

Mygod avatar Feb 20 '20 16:02 Mygod

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???

riobard avatar Feb 20 '20 16:02 riobard

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

Mygod avatar Feb 20 '20 17:02 Mygod

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

riobard avatar Feb 20 '20 17:02 riobard

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.

Mygod avatar Feb 20 '20 17:02 Mygod

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 avatar Feb 20 '20 17:02 riobard

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

riobard avatar Feb 20 '20 17:02 riobard

@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

Mygod avatar Feb 20 '20 17:02 Mygod

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

riobard avatar Feb 20 '20 17:02 riobard

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

Mygod avatar Feb 20 '20 18:02 Mygod

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.

ghost avatar Apr 24 '20 05:04 ghost