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

fix: Increase received signature scheme limit #4544

Merged
merged 3 commits into from
May 7, 2024

Conversation

goatgoose
Copy link
Contributor

@goatgoose goatgoose commented May 6, 2024

Resolved issues:

Temporary workaround for #4543

Description of changes:

Currently, the maximum number of received signature schemes is set to 64:

#define TLS_SIGNATURE_SCHEME_LIST_MAX_LEN 64

Some clients have been found to send more than 64 signature schemes, which causes the connection to fail (see open-quantum-safe/oqs-provider#399). This PR increases the maximum number of received signature schemes, allowing these clients to connect successfully.

Note that the reason a limit exists at all is to allocate a separate buffer for received signature schemes, which isn't actually necessary. As a long-term solution for this issue, we should read the signature schemes straight from the TLS message rather than copy them into a separate buffer. See #4543.

Call-outs:

Lindsay also had the idea to remove the separate client and server signature scheme buffers in order to avoid increasing the memory used per connection, so this PR also does this refactor.

Testing:

A new test was added to ensure that the new limit is respected.

I reproduced this issue with the oqs-provider client connecting to an s2n-tls server, and confirmed that this fix resolved the issue:

Test results

Before fix:

% git branch --show
main

% ./s2nd 0.0.0.0 9000 --self-service-blinding
Listening on 0.0.0.0:9000
Failed to negotiate: 'Max supported length of SignatureAlgorithms/SignatureSchemes list is 32'. Error encountered in /home/vclarksa/s2n-tls-fork/tls/s2n_signature_algorithms.c:367
/ # openssl s_client -connect 127.0.0.1:9000
Connecting to 127.0.0.1
CONNECTED(00000003)
48FB09E4807F0000:error:0A000126:SSL routines::unexpected eof while reading:ssl/record/rec_layer_s3.c:687:
...

After fix:

% git branch --show
increase-sig-scheme-buffer

% ./s2nd 0.0.0.0 9000 --self-service-blinding
Listening on 0.0.0.0:9000
CONNECTED:
Handshake: NEGOTIATED|FULL_HANDSHAKE|WITH_SESSION_TICKET
Client hello version: 33
Client protocol version: 34
Server protocol version: 33
Actual protocol version: 33
Curve: NONE
KEM: NONE
KEM Group: NONE
Cipher negotiated: AES128-GCM-SHA256
Server signature negotiated: RSA+SHA256
Early Data status: NOT REQUESTED
JA3: eb5ad62b756102de4d2e853ee4e815e1
Wire bytes in: 1842
Wire bytes out: 2647
s2n is ready
/ # openssl s_client -connect 127.0.0.1:9000
Connecting to 127.0.0.1
CONNECTED(00000003)
Can't use SSL_get_servername
depth=2 CN=s2nTestRoot
verify error:num=19:self-signed certificate in certificate chain
verify return:1
depth=2 CN=s2nTestRoot
...
New, TLSv1.2, Cipher is AES128-GCM-SHA256
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : AES128-GCM-SHA256
...

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added the s2n-core team label May 6, 2024
tls/s2n_handshake.h Outdated Show resolved Hide resolved
@goatgoose goatgoose marked this pull request as ready for review May 7, 2024 01:14
@goatgoose goatgoose requested a review from jmayclin May 7, 2024 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants