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

socket.syswrite return is value not checked; sent data can be truncated #30

Closed
zarmin opened this issue Aug 23, 2017 · 2 comments · Fixed by #49 · May be fixed by #32
Closed

socket.syswrite return is value not checked; sent data can be truncated #30

zarmin opened this issue Aug 23, 2017 · 2 comments · Fixed by #49 · May be fixed by #32

Comments

@zarmin
Copy link

zarmin commented Aug 23, 2017

Experiencing some issue using TLS.
Payloads are truncated after exactly 16k.

TLS RFC sets the record size to 16k, so with one write only 16k can be written.

Small ruby PoC to demonstrate:

require 'socket'
require 'openssl'

context = OpenSSL::SSL::SSLContext.new
tcp_client = TCPSocket.new 'google.hu', 443
ssl_client = OpenSSL::SSL::SSLSocket.new tcp_client, context
ssl_client.connect

payload = 'A' * (16 * 1024 + 123) # 16k + 123 byte

n = ssl_client.syswrite(payload)
puts "Payload size: #{payload.length}"
puts "Written bytes: #{n}"

ssl_client.close

output:

Payload size: 16507
Written bytes: 16384
AStevensTaylor pushed a commit to AStevensTaylor/logstash-output-tcp that referenced this issue Oct 30, 2017
AStevensTaylor pushed a commit to AStevensTaylor/logstash-output-tcp that referenced this issue Oct 30, 2017
AStevensTaylor pushed a commit to AStevensTaylor/logstash-output-tcp that referenced this issue Oct 30, 2017
@airikh
Copy link

airikh commented Jan 14, 2021

I'm also experiencing message truncation with TLS enabled.

I noticed there are 2 open PRs around this issue. Are there plans to incorporate a fix in the near future?

Also, I found a commit in the Lumberjack-related coded that fixed a similar issue: elastic/logstash-forwarder#384

Thanks!

raphaelsolarski added a commit to raphaelsolarski/logstash-output-tcp that referenced this issue Aug 4, 2021
…PSocket.syswrite in loop.

Fixes logstash-plugins#30 logstash-plugins#33 where messages longer than jruby-openssl OpenSSL::Buffering::BLOCK_SIZE were truncated.
raphaelsolarski added a commit to raphaelsolarski/logstash-output-tcp that referenced this issue Aug 5, 2021
…PSocket.syswrite in loop.

Fixes logstash-plugins#30 logstash-plugins#33 where messages longer than jruby-openssl OpenSSL::Buffering::BLOCK_SIZE were truncated.
@mashhurs mashhurs linked a pull request Aug 16, 2022 that will close this issue
@mashhurs
Copy link
Contributor

A 6.1.1 version of plugin addresses this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment