Skip to content

Conversation

@avevad
Copy link
Member

@avevad avevad commented Dec 11, 2025

No description provided.

@avevad avevad self-assigned this Dec 11, 2025
@github-actions
Copy link

@codex review

@chatgpt-codex-connector
Copy link

To use Codex here, create a Codex account and connect to github.

Comment on lines +29 to +35
void start_up() override;
void tear_down() override;
void hangup() override;
void hangup_shared() override;
void wake_up() override;
void alarm() override;
void loop() override;
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't have to implement these if you don't use them. The default implementation is reasonable enough.

Copy link
Member Author

Choose a reason for hiding this comment

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

i'm not really familiar with td actor system, so i left them for debug logs in case of some unexpected signal from the scheduler

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would define this in an anonymous namespace inside quic-connection.cpp unless there is a legitimate reason why we want to import the implementation from multiple places.

Copy link
Member Author

Choose a reason for hiding this comment

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

that means you will need to declare all its ngtcp-insides in quic-connection.h, too
this is highly unwanted, as ngtcp exports some weird C symbols into global namespace -- they will contaminate the scope of every TU it's included into
see PImpl idiom

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, I know what pimpl is. I mostly don't like a separate header for implementation when this can be done in a single file, i. e. something resembling this: https://github.com/DanShaders/ton/blob/alpenglow/validator/consensus/block-producer.cpp#L11-L13.

Copy link
Member Author

Choose a reason for hiding this comment

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

anyways, i plan to reuse this impl structure in server-side connections, so it will be useful to keep it in separate files


std::string alpn_data(alpn.size() + 1, '\0');
alpn_data[0] = static_cast<int8_t>(alpn.size());
std::copy_n(alpn.c_str(), alpn.size(), alpn_data.begin());
Copy link
Collaborator

Choose a reason for hiding this comment

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

alpn_data.begin() + 1 as the last argument?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +65 to +67
params.initial_max_stream_data_bidi_local = 1 << 20;
params.initial_max_stream_data_bidi_remote = 1 << 20;
params.initial_max_data = 1 << 20;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is this 1MB(?) coming from?

Comment on lines +76 to +79
path.local.addr = const_cast<ngtcp2_sockaddr*>(local_address.get_sockaddr());
path.local.addrlen = static_cast<ngtcp2_socklen>(local_address.get_sockaddr_len());
path.remote.addr = const_cast<ngtcp2_sockaddr*>(remote_address.get_sockaddr());
path.remote.addrlen = static_cast<ngtcp2_socklen>(remote_address.get_sockaddr_len());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like const casts here, is ngtcp2 guaranteed not to change passed sockaddrs?

};

constexpr static size_t QUIC_MTU = 1350;
constexpr static size_t UDP_MTU = 2048;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not proper 65507 bytes if this is already larger than ethernet MTU?

virtual ~Callback() = default;
};

constexpr static size_t QUIC_MTU = 1350;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where does this come from? I think ngtcp2 does some form of dynamic MTU discovery, so we should probably query the value from it or use true maximum


option(USE_QUIC "use ngtcp2 QUIC library" OFF)
if (USE_QUIC)
find_package(OpenSSL 3.2 REQUIRED COMPONENTS SSL Crypto)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We build with OpenSSL 3.1.4 in CI. Not sure how this passed, I think this might just never execute as it sees previously set OpenSSL_FOUND (or something).

@github-actions
Copy link

Findings:

  • quic/quic-pimpl.cpp:9-24 sets SSL_VERIFY_NONE and never validates the server certificate/hostname (also ignores SSL_set_alpn_protos failure). That makes the QUIC client trivially MITM-able and defeats TLS authentication.
  • quic/quic-pimpl.cpp:176-177 always passes NGTCP2_WRITE_STREAM_FLAG_FIN, so every call to send_data(..., fin=false) still sends a FIN and closes the stream. Multi-chunk writes are impossible and the peer will see an immediate end-of-stream.
  • quic/quic-connection.cpp:51-55 leaves alarm() unimplemented and never drives ngtcp2_conn_handle_expiry via timers. If an Initial/Handshake packet is lost, no PTO fires, so the handshake can hang indefinitely.
  • quic/quic-pimpl.cpp:20-22 encodes ALPN length into an int8_t; lengths >127 wrap negative and produce an invalid ALPN extension, breaking negotiation for longer IDs. Use uint8_t/bounds checking.

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.

2 participants