GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Generic writeFrame can emit frames over SETTINGS_MAX_FRAME_SIZE · Issue #17426 · netty/netty

Generic writeFrame can emit frames over SETTINGS_MAX_FRAME_SIZE #17426

New issue
Copy link
New issue
Copy link
Closed
#17779
Closed
Generic writeFrame can emit frames over SETTINGS_MAX_FRAME_SIZE#17426
#17779
Copy link

Description

@LiD0209
LiD0209
opened on Sep 10, 2026
Issue body actions

Issue

RFC 9113 applies SETTINGS_MAX_FRAME_SIZE to every frame payload. Netty stores the peer-advertised outbound limit and typed writers such as writeData honor it, but the public generic writeFrame(...) path writes the full payload length into one frame header. With maxFrameSize=16384, it emits a single generic frame whose payload length is 16385.

Standard

RFC 9113 Section 4.2:

The size of a frame payload is limited by the maximum size that a
receiver advertises in the SETTINGS_MAX_FRAME_SIZE setting.  This
setting can have any value between 2^14 (16,384) and 2^24-1
(16,777,215) octets, inclusive.

RFC 9113 Section 4.2:

An endpoint MUST send an error code of FRAME_SIZE_ERROR if a frame
exceeds the size defined in SETTINGS_MAX_FRAME_SIZE, exceeds any
limit defined for the frame type, or is too small to contain
mandatory frame data.

Code

Http2FrameWriter.java:204-215 exposes a generic writer for any HTTP/2 frame:

/** Generic write method for any HTTP/2 frame. This allows writing of non-standard frames. */
ChannelFuture writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId,
        Http2Flags flags, ByteBuf payload, ChannelPromise promise);

DefaultHttp2ConnectionEncoder.java:111-113 applies peer settings to the outbound frame-size policy:

Integer maxFrameSize = settings.maxFrameSize();
if (maxFrameSize != null) {
    outboundFrameSizePolicy.maxFrameSize(maxFrameSize);
}

DefaultHttp2FrameWriter.java:123-129 stores the validated limit:

public void maxFrameSize(int max) throws Http2Exception {
    if (!isMaxFrameSizeValid(max)) {
        throw connectionError(FRAME_SIZE_ERROR, "Invalid MAX_FRAME_SIZE specified in sent settings: %d", max);
    }
    maxFrameSize = max;
}

DefaultHttp2FrameWriter.java:157-170 shows the typed DATA path splitting payloads larger than the limit:

int remainingData = data.readableBytes();
...
if (remainingData > maxFrameSize) {
    frameHeader = ctx.alloc().buffer(FRAME_HEADER_LENGTH);
    writeFrameHeaderInternal(frameHeader, maxFrameSize, DATA, flags, streamId);
    ...
    ctx.write(data.readRetainedSlice(maxFrameSize), promiseAggregator.newPromise());
}

DefaultHttp2FrameWriter.java:473-495 shows the generic path has no maxFrameSize check and writes the whole payload length:

public ChannelFuture writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId,
        Http2Flags flags, ByteBuf payload, ChannelPromise promise) {
    ...
    writeFrameHeaderInternal(buf, payload.readableBytes(), frameType, flags, streamId);
    ctx.write(buf, promiseAggregator.newPromise());
    ...
    ctx.write(payload, promiseAggregator.newPromise());
}

DefaultHttp2ConnectionEncoder.java:393-395 delegates generic writes to that writer:

return frameWriter.writeFrame(ctx, frameType, streamId, flags, payload, promise);

Runtime evidence

The focused test configured the outbound maximum frame payload to 16,384 bytes and supplied a 16,385-byte payload to the dedicated DATA writer and the generic frame writer. It inspected the emitted payload lengths: DATA was split into 16,384 and 1 bytes, while the generic path emitted a single 16,385-byte frame. Both observation-based assertions passed.

Probe: SpecLitmusMaxFrameSizeGenericWriteFrameTest.

Command rerun:

cd implementions/netty-4.2
mvnw.cmd -pl codec-http2 -Dtest=SpecLitmusMaxFrameSizeGenericWriteFrameTest -Dsurefire.failIfNoSpecifiedTests=false -DskipITs=true -DskipHttp2Tests=false -Dcheckstyle.skip=true -DskipJapicmp=true -DskipNativeTests=true test

Observed behavior:

Test Configured max Input payload Emitted frame payload
writeDataSplitsAtMaxFrameSizeControl 16384 16385 16384, then 1
genericWriteFrameIgnoresMaxFrameSizeReproducer 16384 16385 one frame with 16385

Maven result: Tests run: 2, Failures: 0, Errors: 0, Skipped: 0; BUILD SUCCESS.

Impact and fix

Code that uses the generic HTTP/2 writer for extension or non-standard frames can send a frame larger than the peer limit. writeFrame should reject payloads larger than maxFrameSize, or split only for frame types whose semantics permit splitting.

Activity

  1. AbhishekShukla1289 commented on Oct 9, 2026

    @AbhishekShukla1289
    AbhishekShukla1289
    on Oct 9, 2026
    Contributor
    More actions

    Hi! I'd like to take this one. I have a fix that validates the payload length against maxFrameSize in DefaultHttp2FrameWriter.writeFrame (generic frames can't be split, so the write fails instead), with tests for the exceeding and at-limit cases. I'll open a PR against 4.2 shortly.

  2. AbhishekShukla1289
    added a commit that references this issue on Oct 19, 2026

    HTTP/2: Reject generic frames whose payload exceeds SETTINGS_MAX_FRAM…

    This issue will close once commit 5906d7c is merged into the '4.2' branch.
    5906d7c
  3. normanmaurer
    closed this as completedin #17779on Oct 22, 2026
  4. opensource-fork-sync
    added a commit that references this issue on Oct 22, 2026

    Http2: reject generic frames whose payload exceeds SETTINGS_MAX_FRAME…

    This issue will close once commit dc5655e is merged into the '4.2' branch.
    dc5655e
  5. normanmaurer
    added 2 commits that reference this issue on Oct 22, 2026

    Auto-port 5.0: Http2: reject generic frames whose payload exceeds SET…

    This issue will close once commit 792e0ea is merged into the '4.2' branch.
    792e0ea

    Auto-port 4.1: Http2: reject generic frames whose payload exceeds SET…

    This issue will close once commit 13ae2b2 is merged into the '4.2' branch.
    13ae2b2
  6. lltopk
    added a commit that references this issue on Oct 24, 2026

    Auto-port 4.1: Http2: reject generic frames whose payload exceeds SET…

    This issue will close once commit ca9ff7d is merged into the '4.2' branch.
    ca9ff7d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.