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

added check if the buf is at least RECORD_HEADER_SZ #7638

Merged
merged 2 commits into from
Jun 13, 2024

Conversation

gasbytes
Copy link
Contributor

Description

should fix this issue.

Testing

Forced it locally (no steps to reproduce were provided), and after some reading of the stacktrace I came up with this quick fix that doesn't require an extensive refactor. Tested like this:

./configure --enable-all --enable-aesni --enable-keylog-export --disable-ech CC="gcc -fsanitize=address"
make
sudo make install
./testsuite/testsuite.test

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

when adding the record headers through quic
@@ -774,6 +780,11 @@ int wolfSSL_quic_receive(WOLFSSL* ssl, byte* buf, word32 sz)
n = 0;
if (ssl->quic.input_head) {
n = quic_record_transfer(ssl->quic.input_head, buf, sz);

/* record too small to be fit into a RecordLayerHeader struct. */
if (n == -1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

n is unsigned here -- but there's a bigger problem, quic_record_transfer() is returning unsigned (word32), but it's returning -1 to signify error.

so you'll need to fix quic_record_transfer() to return sword32, fix signedness clashes that arise from that, and change n in wolfSSL_quic_receive() to be an sword32 and fix clashes that arise from that.

I'm quite surprised none of the analyzers are warning us about return -1 from word32 quic_record_transfer().

@douzzer douzzer assigned gasbytes and unassigned wolfSSL-Bot Jun 12, 2024
@gasbytes gasbytes requested a review from douzzer June 13, 2024 12:08
@douzzer douzzer merged commit 385a097 into wolfSSL:master Jun 13, 2024
113 checks passed
jefferyq2 pushed a commit to jefferyq2/wolfssl that referenced this pull request Jun 14, 2024
added check if the buf is at least RECORD_HEADER_SZ
@gasbytes gasbytes deleted the patch branch August 28, 2024 13:06
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.

[Bug]: Heap-Buffer-Overflow in add_rec_header
3 participants