René's URL Explorer Experiment


Title: content-length is not policed when a stream ends with a trailers section · Issue #1328 · python-hyper/h2 · GitHub

Open Graph Title: content-length is not policed when a stream ends with a trailers section · Issue #1328 · python-hyper/h2

X Title: content-length is not policed when a stream ends with a trailers section · Issue #1328 · python-hyper/h2

Description: Summary A stream that ends with a trailers section never has its content-length policed, and a content-length in the trailers silently overrides the one declared in the header section. Description H2Stream.receive_headers is the handler ...

Open Graph Description: Summary A stream that ends with a trailers section never has its content-length policed, and a content-length in the trailers silently overrides the one declared in the header section. Description ...

X Description: Summary A stream that ends with a trailers section never has its content-length policed, and a content-length in the trailers silently overrides the one declared in the header section. Description ...

Opengraph URL: https://github.com/python-hyper/h2/issues/1328

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"content-length is not policed when a stream ends with a trailers section","articleBody":"## Summary\n\nA stream that ends with a trailers section never has its `content-length` policed, and a `content-length` in the trailers silently overrides the one declared in the header section.\n\n## Description\n\n`H2Stream.receive_headers` is the handler for every received HEADERS block — initial headers, informational responses and trailers. It called `self._initialize_content_length(headers)` unconditionally. But `_track_content_length`, which is where the actual comparison happens, was only ever called from `receive_data`:\n\n```python\nif expected is not None:\n    if expected \u003c actual:\n        raise InvalidBodyLengthError(expected, actual)\n\n    if end_stream and expected != actual:\n        raise InvalidBodyLengthError(expected, actual)\n```\n\nTrailers never go through `receive_data`, so `end_stream` is never `True` here and the short-body check never runs. Two concrete consequences:\n\n- **Trailers without `content-length`**: `_initialize_content_length` sets `_expected_content_length` back to `None`, so `if expected is not None:` skips validation altogether.\n- **Trailers with `content-length`**: the trailers value replaces the header-section value, so a peer could declare `content-length: 10` in the headers and `content-length: 3` in the trailers and have a 13-byte body accepted.\n\nThe too-much-data direction still errors, because `expected \u003c actual` trips while receiving DATA frames. Only the short-body direction is silently accepted.\n\n## RFC 9113 § 8.1.1\n\n> A request or response is also malformed if the value of a content-length header field does not equal the sum of the DATA frame payload lengths that form the content, unless the message is defined as having no content. For example, 204 or 304 responses contain no content, as does the response to a HEAD request.\n>\n> Malformed requests or responses that are detected MUST be treated as a stream error of type PROTOCOL_ERROR.\n\nThe listed exemptions are 204, 304 and HEAD. A trailers section is not one of them. This is the same check the project adopted in #123 (\"Police content lengths when provided\"), proposed in #114.\n\n## Steps to reproduce\n\nUnit level, no network, in-memory bytes:\n\n| scenario | result on 4.4.1 |\n|---|---|\n| `content-length: 3`, DATA 10, END_STREAM on DATA | `InvalidBodyLengthError` |\n| `content-length: 15`, DATA 13, END_STREAM on DATA | `InvalidBodyLengthError` |\n| **`content-length: 15`, DATA 13, trailers END_STREAM** | **accepted** |\n| **`content-length: 15`, no DATA, trailers END_STREAM** | **accepted** |\n| **`content-length: 15`, DATA 13, trailers `content-length: 13`** | **accepted** |\n\nExisting coverage only exercises the DATA-frame case: `test_insufficient_data` and `test_insufficient_data_empty_frame` in `tests/test_invalid_content_lengths.py`.\n\n## Environment\n\n- h2 4.4.1, `master` at `bc239af1d1b85bc70482804f30a0e0e587d90a08`\n- Python 3.14, macOS\n\n## Fix\n\nIn `receive_headers`, when the block is trailers: run the same `content-length` parse so a syntactically invalid value there is still a `ProtocolError`, then restore the previous expectation, and finally validate the body where the stream actually ends.\n","author":{"url":"https://github.com/feiiiiii5","@type":"Person","name":"feiiiiii5"},"datePublished":"2026-09-25T22:01:18Z","url":"https://github.com/python-hyper/h2/issues/1328"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:2352c639-c84e-eb8a-cfff-6f26f13d1da1
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9316:27372C:D66C6B:12EA58D:6B06EF8E
html-safe-nonce419daec3b7d5dd756cfdfb03b12ff2ed7ab6ad078ce938e5f5f10e11b0ea472b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MzE2OjI3MzcyQzpENjZDNkI6MTJFQTU4RDo2QjA2RUY4RSIsInZpc2l0b3JfaWQiOiI3Mjc1NDA0MTQyODM0MDIwMjM4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac9e8c241bf24ccb95e74dd84fb20dd4138ea33acc78f3943757fc61a7227a90ef
hovercard-subject-tagissue:5589032820
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-hyper/h2/1328/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6c6928caf4d7f84894710b90c16014b34cc4de56ebf8b2c5318b073bacedd653/python-hyper/h2/issues/1328
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6c6928caf4d7f84894710b90c16014b34cc4de56ebf8b2c5318b073bacedd653/python-hyper/h2/issues/1328
og:image:altSummary A stream that ends with a trailers section never has its content-length policed, and a content-length in the trailers silently overrides the one declared in the header section. Description ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamefeiiiiii5
hostnamegithub.com
expected-hostnamegithub.com
None351ea5ca38a5758919d44ee52c70fe9003c0c2dfa20f04effd7fac0c5330c16b
turbo-cache-controlno-preview
go-importgithub.com/python-hyper/h2 git https://github.com/python-hyper/h2.git
octolytics-dimension-user_id13035907
octolytics-dimension-user_loginpython-hyper
octolytics-dimension-repository_id37996233
octolytics-dimension-repository_nwopython-hyper/h2
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id37996233
octolytics-dimension-repository_network_root_nwopython-hyper/h2
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release891bde3f438884e9c6c7ccd826f33805910a978b
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python-hyper/h2/issues/1328#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-hyper%2Fh2%2Fissues%2F1328
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-hyper%2Fh2%2Fissues%2F1328
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python-hyper%2Fh2
Reloadhttps://github.com/python-hyper/h2/issues/1328
Reloadhttps://github.com/python-hyper/h2/issues/1328
Reloadhttps://github.com/python-hyper/h2/issues/1328
python-hyperhttps://github.com/python-hyper
h2https://github.com/python-hyper/h2
Codehttps://github.com/python-hyper/h2
Issues21 (21)https://github.com/python-hyper/h2/issues
Pull requests23 (23)https://github.com/python-hyper/h2/pulls
Actionshttps://github.com/python-hyper/h2/actions
Projectshttps://github.com/python-hyper/h2/projects
Wikihttps://github.com/python-hyper/h2/wiki
Security and quality2 (2)https://github.com/python-hyper/h2/security
Insightshttps://github.com/python-hyper/h2/insights
https://github.com/python-hyper/h2
New issuehttps://github.com/login?return_to=https://github.com/python-hyper/h2/issues/1328
New issuehttps://github.com/login?return_to=https://github.com/python-hyper/h2/issues/1328
#1329https://github.com/python-hyper/h2/pull/1329
content-length is not policed when a stream ends with a trailers sectionhttps://github.com/python-hyper/h2/issues/1328#top
#1329https://github.com/python-hyper/h2/pull/1329
https://github.com/feiiiiii5
feiiiiii5https://github.com/feiiiiii5
on Sep 25, 2026https://github.com/python-hyper/h2/issues/1328#issue-5589032820
#123https://github.com/python-hyper/h2/pull/123
#114https://github.com/python-hyper/h2/issues/114
S0N1CASHhttps://github.com/S0N1CASH
on Sep 29, 2026https://github.com/python-hyper/h2/issues/1328#event-32052940654
chore: pin Python 3.12 and add issue python-hyper#1328 trailers reprohttps://github.com/S0N1CASH/h2/commit/f1198749e3986834b2a150e459c51608c5f533a9
python-hyper#1328https://github.com/python-hyper/h2/issues/1328
f119874https://github.com/S0N1CASH/h2/commit/f1198749e3986834b2a150e459c51608c5f533a9
Sign up for freehttps://github.com/signup?return_to=https://github.com/python-hyper/h2/issues/1328
Sign in to commenthttps://github.com/login?return_to=https://github.com/python-hyper/h2/issues/1328
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.