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

Connection hangs after delivery of 256GB of data #7065

Closed
AlexPeshkoff opened this issue Dec 12, 2021 · 9 comments
Closed

Connection hangs after delivery of 256GB of data #7065

AlexPeshkoff opened this issue Dec 12, 2021 · 9 comments

Comments

@AlexPeshkoff
Copy link
Member

ChaCha wire encryption, used by default since FB4, is using 32-bit counter. When counter overflows secure packets delivery becomes impossible without reconnect.

@AlexPeshkoff AlexPeshkoff self-assigned this Dec 12, 2021
@AlexPeshkoff AlexPeshkoff changed the title Connection hangs after delivery of 2**32 - 1 packets Connection hangs after delivery of 256GB of data Dec 12, 2021
@AlexPeshkoff
Copy link
Member Author

AlexPeshkoff commented Dec 12, 2021

Added configuration parameter CounterSize (in ChaCha.conf). Setting it to 64 makes it use 64-bit counter which is able to exchange with very big volume of data, practically unlimited.

Using this setting makes firebird server incompatible with 4.0.0 client

@mrotteveel
Copy link
Member

This is not an appropriate fix. The client has no way to know to know the counter size the server expects. In addition, this is no longer ChaCha20 as defined in RFC-7539, which makes it harder to support. If a bigger counter is needed, then a new variant of ChaCha needs to be added with a separate name, to distinguish it from the standard 32-bit counter variant.

@mrotteveel mrotteveel reopened this Dec 12, 2021
@AlexPeshkoff
Copy link
Member Author

AlexPeshkoff commented Dec 13, 2021

The client has a way to know the counter size the server expects. IV (nonce) is sent to client, and depending on it's size client does know what counter size should be used.

What about use of .conf for choosing chacha variant: we are not the only one who met this problem, see for example https://libsodium.gitbook.io/doc/advanced/stream_ciphers/chacha20. Pay attention - "The original ChaCha20 cipher with a 64-bit nonce". I.e. it has all reasons to be called 'ChaCha'.

And I disagree with you about "harder to support" - having single plugin with reasonable parameter much simpler to support compared with duplicated copies of same code.

@mrotteveel
Copy link
Member

mrotteveel commented Dec 13, 2021 via email

@AlexPeshkoff
Copy link
Member Author

Java only supports ... ChaCha20 with 32-bit counter

That's what you could say at once instead of loosing so many words... Will rework - never new that original for one people variant is not supported by others :-)

@aafemt
Copy link
Contributor

aafemt commented Dec 13, 2021

May I suggest to leave ChaCha as is and just move it deeper in configuration so rc4 is used by default with added warning that ChaCha while is "more secure" cannot be used for long lasting connections?

@asfernandes
Copy link
Member

Then ChaCha must be deprecated. I see no point in have this limitation.

AlexPeshkoff added a commit that referenced this issue Dec 13, 2021
@AlexPeshkoff
Copy link
Member Author

@asfernandes - chacha with 32-bit counter is IETF recommended solution and looks like the only one supported by java.
I know that RC4 is quite enough for us (with our use of secure key it has no security problems), but I can't explain it to some users. I.e. chacha is 'must be' to avoid loosing such users. What's cool is that now (with Mark's suggestion implemented) our default configuration has no 256Gb limitation.

@mrotteveel I've checked current default configuration for compatibility with FB4.0.0 client but additional check with jaybird is also welcome.

@mrotteveel
Copy link
Member

mrotteveel commented Dec 14, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants