Skip to content

Conversation

@akshatsinha0
Copy link

Introduce a new error code S2N_ERR_ILLEGAL_PARAMETER to distinguish between unexpected message types (S2N_ERR_BAD_MESSAGE) and invalid message content. This improves TLS alert compliance by mapping the new error to S2N_TLS_ALERT_ILLEGAL_PARAMETER.

Changes:
add S2N_ERR_ILLEGAL_PARAMETER to error enum in s2n_errno.h,add error description in s2n_errno.c,map S2N_ERR_ILLEGAL_PARAMETER to S2N_TLS_ALERT_ILLEGAL_PARAMETER
This resolves the TODO comment about incomplete alert mappings

Release Summary:

Introduces a new error code S2N_ERR_ILLEGAL_PARAMETER for TLS alert compliance by distinguishing b/w unexpected message types and invalid message content in accordance with RFC specifications

Resolved issues:

Partially addresses the TODO comments in tls/s2n_alerts.c regarding incomplete error-to-alert mappings.

Description of changes:

Describe s2n’s current behavior and how your code changes that behavior. If there are no issues this PR is resolving, explain why this change is necessary.

Call-outs:

Address any potentially confusing code. Is there code added that needs to be cleaned up later? Is there code that is missing because it’s still in development? If a callout is specific to a section of code, it might make more sense to leave a comment on your own PR file diff.

Testing:

Code compiles without syntax errors, verified error enum ordering is correct (added after S2N_ERR_BAD_MESSAGE in S2N_ERR_T_PROTO category)

Remember:

  • Any change to the library source code should at least include unit tests.
  • Any change to the core stuffer or blob methods should include CBMC proofs.
  • Any change to the CI or tests should:
    1. prove that the test succeeds for good input
    2. prove that the test fails for bad input (eg, a test for memory leaks fails when a memory leak is committed)

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

Introduce a new error code S2N_ERR_ILLEGAL_PARAMETER to distinguish
between unexpected message types (S2N_ERR_BAD_MESSAGE) and invalid
message content. This improves TLS alert compliance by mapping the
new error to S2N_TLS_ALERT_ILLEGAL_PARAMETER.

Changes:
- Add S2N_ERR_ILLEGAL_PARAMETER to error enum in s2n_errno.h
- Add error description in s2n_errno.c
- Map S2N_ERR_ILLEGAL_PARAMETER to S2N_TLS_ALERT_ILLEGAL_PARAMETER
- Update comments to clarify error-to-alert mappings

This resolves the TODO comment about incomplete alert mappings and
provides a foundation for more precise error reporting throughout
the codebase.
@jouho jouho requested a review from maddeleine November 6, 2025 18:49
Copy link
Contributor

@maddeleine maddeleine left a comment

Choose a reason for hiding this comment

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

This is incomplete. The problem is not only that we don't have an error for illegal parameter. It's that sometimes we emit S2N_ERR_BAD_MESSAGE in places that actually indicate S2N_TLS_ALERT_ILLEGAL_PARAMETER instead of S2N_TLS_ALERT_UNEXPECTED_MESSAGE. So the complete fix would be to go through our code and swap out S2N_ERR_BAD_MESSAGE for S2N_ERR_ILLEGAL_PARAMETER where it is more appropriate.

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.

2 participants