Skip to content

Conversation

@kareem-wolfssl
Copy link
Contributor

Description

Send no_renegotiation alert when rejecting renegotation attempt as defined in RFC 5246 section 7.2.2.
Fixes zd#19378

Testing

Built in tests

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@kareem-wolfssl kareem-wolfssl self-assigned this Dec 30, 2025
@devin-ai-integration
Copy link
Contributor

🛟 Devin Lifeguard found 2 likely issues in this PR

  • use-c-style-comments snippet: Replace the “// SCR check is enabled” (and similar) lines in the code examples with C-style comments, e.g. “/* SCR check is enabled */”.
  • declare-const-pointers snippet snippet: Change wolfSSL_get_scr_check_enabled signature to int wolfSSL_get_scr_check_enabled(const WOLFSSL* ssl) (and similarly make the ssl and ctx parameters in test_SCR_check_remove_ext_io_cb const) since they are not modified within the functions.

@kareem-wolfssl
please take a look at the above issues which Devin flagged. Devin will not fix these issues automatically.

@kareem-wolfssl kareem-wolfssl removed their assignment Jan 8, 2026
@dgarske dgarske requested review from Copilot and dgarske and removed request for wolfSSL-Bot January 9, 2026 21:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a runtime option to enable or disable the secure renegotiation (SCR) check in wolfSSL. The feature allows clients to control whether to enforce RFC 9325 requirements that servers acknowledge the secure renegotiation extension. Additionally, it implements sending a no_renegotiation alert when rejecting renegotiation attempts on servers without secure renegotiation support.

Key changes:

  • Adds scr_check_enabled bit field to the WOLFSSL structure with getter/setter API functions
  • Implements logic to send no_renegotiation alert when server receives ClientHello after handshake completion without secure renegotiation support
  • Makes the existing SCR check in DoServerHello conditional on the new scr_check_enabled flag

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
wolfssl/ssl.h Adds API declarations for wolfSSL_get_scr_check_enabled and wolfSSL_set_scr_check_enabled
wolfssl/internal.h Adds scr_check_enabled bit field to WOLFSSL structure
src/ssl.c Implements getter/setter functions for the SCR check flag
src/internal.c Initializes scr_check_enabled to 1 (enabled by default); adds no_renegotiation alert logic; makes SCR check conditional on the flag
tests/api.c Adds comprehensive test for the SCR check enable/disable functionality
doc/dox_comments/header_files/ssl.h Adds documentation for the new API functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return EXPECT_RESULT();
}

/* Test SCR check when server doesn't reply to secure_renegotiation. */
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo in the PR title and line 12847 comment: "renegotation" should be "renegotiation" (missing 'i').

Copilot uses AI. Check for mistakes.
/* IO callback to remove secure renegotiation extension from ServerHello */
static int test_SCR_check_remove_ext_io_cb(WOLFSSL *ssl, char *buf, int sz, void *ctx)
{
static int sentServerHello = FALSE;
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The static variable 'sentServerHello' maintains state across multiple test invocations. This could cause test failures if the test is run multiple times in the same process, as the variable will remain TRUE after the first test execution. Consider resetting this variable at the beginning of each test or making it non-static and passed through the context parameter.

Copilot uses AI. Check for mistakes.
return test_memio_write_cb(ssl, buf, sz, ctx);

/* Search for the extension in the buffer */
for (i = 0; i < (size_t)sz - sizeof(renegExt); i++) {
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loop condition 'i < (size_t)sz - sizeof(renegExt)' could miss checking the last valid position. When i equals sz - sizeof(renegExt), we can still safely access buf[i] and buf[i+1] (since sizeof(renegExt) is 2). The condition should be 'i <= (size_t)sz - sizeof(renegExt)' to check all valid positions.

Copilot uses AI. Check for mistakes.
Comment on lines +18081 to +18082
if (ssl->options.handShakeState == HANDSHAKE_DONE && type == client_hello &&
ssl->options.side == WOLFSSL_SERVER_END){
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's inconsistent spacing in the conditional check. The opening parenthesis on line 18082 should align with standard formatting. The condition has extra spacing that makes it harder to read. Consider formatting as 'if (ssl->options.handShakeState == HANDSHAKE_DONE && type == client_hello && ssl->options.side == WOLFSSL_SERVER_END)'.

Copilot uses AI. Check for mistakes.

\sa wolfSSL_set_scr_check_enabled
*/
byte wolfSSL_get_scr_check_enabled(WOLFSSL* ssl);
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type in the documentation is 'byte' but the actual function declaration in wolfssl/ssl.h line 4731 returns 'int'. These should match for consistency and accuracy.

Suggested change
byte wolfSSL_get_scr_check_enabled(WOLFSSL* ssl);
int wolfSSL_get_scr_check_enabled(WOLFSSL* ssl);

Copilot uses AI. Check for mistakes.
Comment on lines +18080 to +18088
#if !defined(HAVE_SECURE_RENEGOTIATION)
if (ssl->options.handShakeState == HANDSHAKE_DONE && type == client_hello &&
ssl->options.side == WOLFSSL_SERVER_END){
WOLFSSL_MSG("Renegotiation request rejected");
SendAlert(ssl, alert_fatal, no_renegotiation);
WOLFSSL_ERROR_VERBOSE(SECURE_RENEGOTIATION_E);
return SECURE_RENEGOTIATION_E;
}
#endif
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title and description mention sending a no_renegotiation alert when rejecting renegotiation attempts. However, this logic in internal.c only sends the alert when HAVE_SECURE_RENEGOTIATION is not defined, and checks if the handshake is done and a client_hello is received on the server side. This appears to be checking for renegotiation attempts when secure renegotiation is disabled entirely, which is a different scenario than checking whether SCR is enabled/acknowledged. Consider clarifying if this is the intended behavior or if this logic should also be conditioned on the scr_check_enabled flag.

Copilot uses AI. Check for mistakes.
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

Successfully merging this pull request may close these issues.

3 participants