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: allow b64 decoding using libcrypto for sidechannel resistance #5103

Merged
merged 16 commits into from
Feb 13, 2025

Conversation

jmayclin
Copy link
Contributor

Description

This PR gets rid of s2n-tls' b64 implementation and uses the libcrypto's implementation instead. If customers link against a libcrypto with sidechannel-resistant b64 decoding such as AWS-LC, then s2n-tls will also use this sidechannel-resistant implementation.

Additionally, s2n_is_base64_char no longer performs a table lookup.

Credit

We would like to thank researchers Zhiyuan Zhang and Gilles Barthe at 'The Max Planck Institute for Security and Privacy' for identifying and responsibly disclosing this issue to AWS. Security-related questions or concerns can be brought to our attention via [email protected] and reports can be submitted through our Vulnerability Disclosure Program via https://hackerone.com/aws_vdp.

Testing

All existing unit tests should pass. The CBMC test for is_base_64 should also pass.

I also spot checked the generated assembly of the new s2n_is_base64_char to ensure that there is minimal branching: here

@github-actions github-actions bot added the s2n-core team label Feb 10, 2025
* fix commenting style
* update is_base64_char to use addition instaed of bitwise or
* use bitwise xor. This seems less likely to get optimized away
stuffer/s2n_stuffer_base64.c Show resolved Hide resolved
stuffer/s2n_stuffer_base64.c Show resolved Hide resolved
stuffer/s2n_stuffer_base64.c Outdated Show resolved Hide resolved
stuffer/s2n_stuffer_base64.c Outdated Show resolved Hide resolved
stuffer/s2n_stuffer_base64.c Outdated Show resolved Hide resolved
stuffer/s2n_stuffer_base64.c Outdated Show resolved Hide resolved
stuffer/s2n_stuffer_base64.c Outdated Show resolved Hide resolved
stuffer/s2n_stuffer_base64.c Outdated Show resolved Hide resolved
@jmayclin jmayclin requested a review from lrstewart February 11, 2025 04:32
.gitmodules Outdated Show resolved Hide resolved
.gitmodules Outdated Show resolved Hide resolved
stuffer/s2n_stuffer_base64.c Show resolved Hide resolved
stuffer/s2n_stuffer_base64.c Outdated Show resolved Hide resolved
tests/unit/s2n_stuffer_base64_test.c Outdated Show resolved Hide resolved
jmayclin and others added 2 commits February 11, 2025 13:34
* add comment about side-channel resistant decoding
* remove debug bound that I added when fighting with CBMC
stuffer/s2n_stuffer_base64.c Outdated Show resolved Hide resolved
stuffer/s2n_stuffer_base64.c Outdated Show resolved Hide resolved
stuffer/s2n_stuffer_base64.c Outdated Show resolved Hide resolved
* cite docs on each quote
* use stuffer_wipe_n to clear the null terminator
* use base64_group convention
* add known value tests for b64 reading and writing related to padding
* copy paste old implementation for more in depth is-char testing
stuffer/s2n_stuffer_base64.c Outdated Show resolved Hide resolved
stuffer/s2n_stuffer_base64.c Outdated Show resolved Hide resolved
* move comment
* add posix ensure
* use posix ensure gte
@jmayclin jmayclin enabled auto-merge February 13, 2025 00:10
@jmayclin jmayclin added this pull request to the merge queue Feb 13, 2025
Merged via the queue into aws:main with commit 18adf02 Feb 13, 2025
45 checks passed
@jmayclin jmayclin deleted the libcrypto-b64wq branch February 13, 2025 03:04
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.

4 participants