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 CertificateCompressionAlgorithm to be read as 2-octet-wide #19600

Closed

Conversation

t184256
Copy link
Contributor

@t184256 t184256 commented Nov 3, 2022

RFC8879
defines CertificateCompressionAlgorithm as a two-octet-wide enum:

       enum {
           zlib(1),
           brotli(2),
           zstd(3),
           (65535)
       } CertificateCompressionAlgorithm;

OpenSSL is reading them as one-octet-wide values though,
so that yet-unallocated values like 770 (0x302) or 16385 (0x4001)
are considered valid algorithms and result in compression negotiated and used.

@tmshort, please also double-check the width in other places,
I only gave it a cursory look.

Checklist
  • documentation is added or updated
  • tests are added or updated

Copy link
Contributor

@tmshort tmshort left a comment

Choose a reason for hiding this comment

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

The committed code is working because the two-byte values have 0 as the leading byte, which is ignored, so it ends up being a no-op. But that does mean that only single-byte values can be used.

@tmshort tmshort added branch: master Merge to master branch approval: otc review pending This pull request needs review by an OTC member triaged: bug The issue/pr is/fixes a bug labels Nov 3, 2022
@beldmit
Copy link
Member

beldmit commented Nov 3, 2022

As after this change the tests still pass, it means we are undertested here :(

@tmshort
Copy link
Contributor

tmshort commented Nov 3, 2022

As after this change the tests still pass, it means we are undertested here :(

It's the nature of the allowed data. Even if there were unsupported algorithms, what would happen is that they would be ignored, unless one of the bytes matched a known but unsupported algorithm by the sender.

The only thing I can think of is some sort of fuzzing test where the client only sends algorithm (0x101 * a supported algorithm), (e.g. 0x101, 0x202 or 0x303, depending on config), which then gets interpreted as a supported algorithm. The test would fail if a compressed certificate is sent by the server. This would, of course, break once any of those values become valid. This would likely need to fall under the GREASE category of testing, and I haven't figured that out yet (since there almost no GREASE testing in OpenSSL that I can find).

@tmshort
Copy link
Contributor

tmshort commented Nov 3, 2022

@t184256, I'm assuming this is something that would be tested via an updated tlsfuzzer?

@t184256
Copy link
Contributor Author

t184256 commented Nov 3, 2022

Yes, this has been found with a test I'm planning to add to tlsfuzzer.

Copy link
Member

@t8m t8m left a comment

Choose a reason for hiding this comment

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

I agree with CLA: trivial

@t8m t8m added approval: done This pull request has the required number of approvals cla: trivial One of the commits is marked as 'CLA: trivial' and removed approval: otc review pending This pull request needs review by an OTC member labels Nov 7, 2022
@t8m
Copy link
Member

t8m commented Nov 7, 2022

@tmshort please confirm you're OK with CLA: trivial.

@t8m t8m added approval: review pending This pull request needs review by a committer and removed approval: done This pull request has the required number of approvals labels Nov 7, 2022
@tmshort
Copy link
Contributor

tmshort commented Nov 7, 2022

@tmshort please confirm you're OK with CLA: trivial.

I'm good with CLA:trivial

@t8m t8m added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Nov 7, 2022
@beldmit
Copy link
Member

beldmit commented Nov 7, 2022

@openssl/otc do we need to raise a separate issue because of the lack of tests here?..

@tmshort
Copy link
Contributor

tmshort commented Nov 7, 2022

@beldmit, this was discovered during the development of the tlsfuzzer support for encryption. So, once that's been updated, it will be available as part of the tlsfuzzer CI.

@beldmit
Copy link
Member

beldmit commented Nov 7, 2022

@tmshort let me disagree.

TLSFuzzer is external project and the level of its integration to OpenSSL is not enough (I don't have spare brain to extend the tests for more than 6 months and no signs I will get them soon). This issue should be tested locally.

@tmshort
Copy link
Contributor

tmshort commented Nov 7, 2022

@tmshort let me disagree.

TLSFuzzer is external project and the level of its integration to OpenSSL is not enough (I don't have spare brain to extend the tests for more than 6 months and no signs I will get them soon). This issue should be tested locally.

I understand. During the initial review there was a request to do GREASE-like permutations of the extensions, but there's no generic mechanism for GREASE right now (AFAIK, if I'm wrong please let me know, I'm not sure the TLSProxy can do it). I do intend to introduce some form of GREASE testing of the extensions, possibly writing it in a generic way to allow others to also GREASE some tests. Since I wrote the Certificate Compression code; it is top of mind for me.

@openssl-machine
Copy link
Collaborator

24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually.

@t8m
Copy link
Member

t8m commented Nov 8, 2022

Merged to master branch. @beldmit if you think there should be more testing of the certificate compression, feel free to open an issue.

@t8m t8m closed this Nov 8, 2022
openssl-machine pushed a commit that referenced this pull request Nov 8, 2022
CLA: trivial

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19600)
@tmshort tmshort mentioned this pull request Nov 11, 2022
2 tasks
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
CLA: trivial

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19600)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: done This pull request has the required number of approvals branch: master Merge to master branch cla: trivial One of the commits is marked as 'CLA: trivial' triaged: bug The issue/pr is/fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants