Skip to content

Conversation

@akshatsinha0
Copy link

The S2N_BLOB_LABEL macro creates const blob structures but the underlying data array was not marked const, breaking const-correctness. so the data will be modified even though the blob is const. CHange the data array as const in S2N_BLOB_LABEL macro & add cast to maintain surity with non-const data pointer

Release Summary:

Fixes const-correctness in S2N_BLOB_LABEL macro to prevent modification of immutable TLS protocol label strings.

Testing:

How is this change tested (unit tests, fuzz tests, etc.)? What manual testing was performed? Are there any testing steps to be verified by the reviewer?
How can you convince your reviewers that this PR is safe and effective?
Is this a refactor change? If so, how have you proved that the intended behavior hasn't changed?
all tests using S2N_BLOB_LABEL validate this change (s2n_tls13_prf_test.c, s2n_tls13_record_aead_test.c, all TLS 1.3 tests using labels from crypto/s2n_tls13_keys.c)

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

The S2N_BLOB_LABEL macro creates const blob structures but the
underlying data array was not marked const, breaking const-correctness.
This allows the data to be modified even though the blob is const.

Changes:
- Mark the data array as const in S2N_BLOB_LABEL macro
- Add explicit cast to maintain compatibility with non-const data pointer

This ensures that blobs created with S2N_BLOB_LABEL have truly immutable
data, preventing accidental modifications to what should be constant
string literals used throughout the TLS 1.3 implementation.

File changed:
- utils/s2n_blob.h (line 72-75: added const to data array)
@boquan-fang
Copy link
Contributor

Hello @akshatsinha0,

Thanks for cutting these PRs to us! I will assign reviewer for your PRs.

@jmayclin
Copy link
Contributor

Hey there! It looks like your test is failing CI, unfortunately. I haven't looked at this part of the codebase deeply, but could you expand on the why of this PR, and also fix the failing CI?

@akshatsinha0
Copy link
Author

@boquan-fang
Yes I will look into it.

@akshatsinha0 akshatsinha0 force-pushed the fix/blob-label-const-correctness branch from e6c1883 to 131f3f2 Compare October 24, 2025 05:58
@akshatsinha0
Copy link
Author

If the update doesnot work, I will close this pr becaue originally const and non-const desings both work

@jmayclin
Copy link
Contributor

jmayclin commented Nov 6, 2025

Hey @akshatsinha0 ! Are you still interested in working on this? We'll go ahead and close this next week if there isn't a response.

@akshatsinha0
Copy link
Author

@jmayclin
Pleass give me a week.

I) Introduced struct s2n_ro_blob and S2N_RO_BLOB_LABEL.

II) Added s2n_hkdf_expand_label_ro for const labels.

III) Migrated TLS 1.3 static labels and call sites to the RO path.

IV) Kept S2N_BLOB_LABEL for mutable use cases.

Signed-off-by: Akshat Sinha
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