Skip to content

[Bug]: [http3] 当字段段大小超过限制时,错误地将该情况作为连接级错误处理,而非流级错误 #845

Description

@qisefengzheng

What happened?

  1. xqc_h3_request_on_recv_header() 返回 -XQC_H3_INVALID_HEADER(第 845 行)
  2. xqc_h3_stream_process_bidi()xqc_h3_stream.c:1539-1558)捕获该错误,在第 1554 行调用 XQC_H3_CONN_ERR(h3c, H3_MESSAGE_ERROR, errcode),将错误升级为连接级错误
  3. 这导致整个连接被 CONNECTION_CLOSE 终止,而非仅重置违规流

根据 RFC 9114 第 10.5.1 节,建议的处理方式是服务器发送 HTTP 431 状态码(仅拒绝该请求),而非终止整个连接。RFC 9114 第 8.1 节也规定 malformed 消息 MUST 作为流错误(H3_MESSAGE_ERROR)处理,而非连接错误。xquic 的实现将单个超大头部段视为终止整个连接的理由,过于激进。

测试用例 xqc_test_h3_malformed_headers_uses_message_error()tests/unittest/xqc_h3_test.c:1027-1059)显式断言 conn->conn_err == H3_MESSAGE_ERROR,证明此行为是预期的,但与 RFC 推荐不符。

ngtcp2/nghttp3 参考实现

  • nghttp3z:\rfc-compare\ngtcp2\nghttp3\lib\nghttp3_conn.c:1966-1968 仅接收并存储对端的 max_field_section_size 设置, 在库内强制检查。应用层通过 recv_settings 回调获知对端限制并自行决定如何处理。这给予应用层更大的灵活性,可以发送 HTTP 431 响应或采取其他策略。

Steps To Reproduce

Information and Steps to reproduce the behavior.

Relevant log output

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