fix: check whether a protocol is enabled during the length calculation in create_npn_advertisement#10381
Merged
randall merged 1 commit intoapache:masterfrom Sep 8, 2023
Merged
Conversation
…n in create_npn_advertisement
masaori335
approved these changes
Sep 7, 2023
Contributor
masaori335
left a comment
There was a problem hiding this comment.
Looks reasonable. The length should be incremented only if it's appended.
cmcfarlen
pushed a commit
to cmcfarlen/trafficserver
that referenced
this pull request
Jun 3, 2024
* asf/master: (22 commits) fix: check whether a protocol is enabled during the length calculation in create_npn_advertisement (apache#10381) Coverity 1518612: Remove dead code (apache#10384) prefetch_cmcd: make autests more robust by removing need for gold file wildcard (apache#10382) Give a chance to send a response before receiving next request on H2 (apache#9997) CID 1516688: Fix uninitialized member of AcceptOptions (apache#10152) Fix slice head request memory issue (apache#10285) Fixes the TSMgmt metrics APIs for new API metrics (apache#10379) Minor parent.config a/an change (apache#10372) Allow DbgCtl tag to be set after instance construction. (apache#10375) Fix more build dep issues, for later PRs to work (apache#10376) money_trace cid 1518569: string not null terminated (apache#10373) Fix a couple of Coverity issues in health check plugin, around filenames (apache#10371) Fixes some build issues that happens with other changes (apache#10374) Eliminate unreachable code covered by switch default (apache#10370) Add tests for disk failure (apache#10192) Disable copying/moving for DbgCtl. (apache#10321) Cmake autest (apache#10327) cmake: add unit tests from mgmt/rpc (apache#10366) Adjust CMakeLists with git worktree (apache#10298) Fix example plugins build (apache#10326) ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
If the following conditions are met, an issue occurs where ATS sends an invalid Server Hello during the TLS handshake:
How to reproduce
If reproduced, the following error will be displayed:
Cause
The issue is caused by ATS setting a length of the NPN string greater than the actual length in the NPN extension.
For example, when HTTP/2 is disabled in sni.yaml, the NPN string should be
8http/1.18http/1.0and its length should be 18, but ATS sets the length as 21.Here are some pointers to the relevant bits of code:
The
ssl_next_protos_advertised_callbackfunction is responsible for setting the NPN string and its length.trafficserver/iocore/net/SSLUtils.cc
Lines 1611 to 1616 in adac616
The NPN string is stored in the
ALPNSupport::npn, and its length is stored in theALPNSupport::npnsz.trafficserver/iocore/net/SSLUtils.cc
Lines 479 to 490 in adac616
trafficserver/iocore/net/ALPNSupport.cc
Lines 84 to 87 in adac616
trafficserver/iocore/net/P_ALPNSupport.h
Lines 58 to 63 in adac616
The values of
ALPNSupport::npnandALPNSupport::npnszare set in theSSLNextProtocolSet::create_npn_advertisementfunction.trafficserver/iocore/net/ALPNSupport.cc
Line 126 in adac616
In
SSLNextProtocolSet::create_npn_advertisement, it is checked whether each protocol is enabled when setting the value forALPNSupport::npn.trafficserver/iocore/net/SSLNextProtocolSet.cc
Lines 66 to 71 in adac616
However, when setting the value for
ALPNSupport::npnsz, it isn't checked whether each protocol is enabled.trafficserver/iocore/net/SSLNextProtocolSet.cc
Lines 56 to 59 in adac616
As a result, when HTTP/2 is disabled in sni.yaml, the value excluding HTTP/2 is set for
ALPNSupport::npn, but the value including HTTP/2 is set forALPNSupport::npnsz.Therefore, the length of the NPN string is greater than the actual length.