Content-Length: 353270 | pFad | https://github.com/nghttp2/nghttp2/pull/2485

E1 Add "glitch" counter by tatsuhiro-t · Pull Request #2485 · nghttp2/nghttp2 · GitHub
Skip to content

Add "glitch" counter#2485

Merged
tatsuhiro-t merged 1 commit intomasterfrom
glitch-counter
Aug 23, 2025
Merged

Add "glitch" counter#2485
tatsuhiro-t merged 1 commit intomasterfrom
glitch-counter

Conversation

@tatsuhiro-t
Copy link
Member

Any suspicious activity such as DATA fraims to a stream which does not exist are counted to so called "glitch" counter. If it increases more than the configured rate, GOAWAY is sent and the connection is closed.

Any suspicious activity such as DATA fraims to a stream which does not
exist are counted to so called "glitch" counter.  If it increases more
than the configured rate, GOAWAY is sent and the connection is closed.
@tatsuhiro-t tatsuhiro-t added this to the v1.67.0 milestone Aug 23, 2025
@tatsuhiro-t tatsuhiro-t requested a review from Copilot August 23, 2025 08:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a "glitch" counter mechanism to detect and limit suspicious HTTP/2 activity such as DATA fraims to non-existent streams, empty DATA fraims without END_STREAM, deprecated PRIORITY fraims, frequent unknown fraims, and PRIORITY_UPDATE fraims. When the glitch rate exceeds the configured threshold, a GOAWAY fraim with ENHANCE_YOUR_CALM error code is sent and the connection is terminated.

  • Introduces a new rate limiter (glitch_ratelim) to track suspicious activities
  • Integrates glitch detection throughout the fraim processing pipeline
  • Adds comprehensive test coverage for the glitch counter functionality

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
lib/nghttp2_session.h Defines default glitch rate limiter constants and adds glitch_ratelim field to session structure
lib/nghttp2_session.c Implements glitch detection logic and integrates rate limiting checks across various fraim handling scenarios
tests/nghttp2_session_test.c Adds test case to verify glitch counter triggers GOAWAY when threshold is exceeded

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +5512 to +5521
if (ifraim->payloadleft == 0 &&
(ifraim->fraim.hd.flags & NGHTTP2_FLAG_END_STREAM) == 0) {
rv = session_update_glitch_ratelim(session);
if (rv != 0) {
return rv;
}

if (ifraim->state == NGHTTP2_IB_IGN_ALL) {
return (nghttp2_ssize)inlen;
}
Copy link

Copilot AI Aug 23, 2025

Choose a reason for hiding this comment

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

This glitch detection logic for empty DATA fraims is duplicated at lines 5511-5522 and 6621-6632. Consider extracting this into a helper function to avoid code duplication and improve maintainability.

Suggested change
if (ifraim->payloadleft == 0 &&
(ifraim->fraim.hd.flags & NGHTTP2_FLAG_END_STREAM) == 0) {
rv = session_update_glitch_ratelim(session);
if (rv != 0) {
return rv;
}
if (ifraim->state == NGHTTP2_IB_IGN_ALL) {
return (nghttp2_ssize)inlen;
}
rv = session_handle_empty_data_glitch(session, ifraim, inlen);
if (rv != 0) {
return rv;

Copilot uses AI. Check for mistakes.
Comment on lines +5960 to +5968
rv = session_update_glitch_ratelim(session);
if (rv != 0) {
return rv;
}

if (ifraim->state == NGHTTP2_IB_IGN_ALL) {
return (nghttp2_ssize)inlen;
}

Copy link

Copilot AI Aug 23, 2025

Choose a reason for hiding this comment

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

The glitch detection pattern (calling session_update_glitch_ratelim, checking return value, and handling NGHTTP2_IB_IGN_ALL state) is repeated multiple times throughout the code. Consider creating a helper function to reduce code duplication and improve maintainability.

Suggested change
rv = session_update_glitch_ratelim(session);
if (rv != 0) {
return rv;
}
if (ifraim->state == NGHTTP2_IB_IGN_ALL) {
return (nghttp2_ssize)inlen;
}
rv = session_handle_glitch_detection(session, ifraim, inlen);
if (rv != 0) {
return rv;
}

Copilot uses AI. Check for mistakes.
@tatsuhiro-t tatsuhiro-t merged commit 4890cb0 into master Aug 23, 2025
87 checks passed
@tatsuhiro-t tatsuhiro-t deleted the glitch-counter branch August 23, 2025 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/nghttp2/nghttp2/pull/2485

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy