fix: limit LWP external entity response size and add timeout#296
Draft
toddr-bot wants to merge 1 commit into
Draft
fix: limit LWP external entity response size and add timeout#296toddr-bot wants to merge 1 commit into
toddr-bot wants to merge 1 commit into
Conversation
The lwp_ext_ent_handler fetched external entity content with no size limit or timeout, allowing denial-of-service via entities pointing at extremely large or slow remote resources. Add LWP_MaxEntitySize (default 1 MB) and LWP_Timeout (default 30s) constructor options. When a response is truncated by LWP (Client-Aborted header), reject it with a clear parse error. Users can set LWP_MaxEntitySize => 0 to restore the previous unlimited behavior. Fixes #276 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #296 +/- ##
==========================================
+ Coverage 76.40% 76.54% +0.14%
==========================================
Files 1 1
Lines 1102 1113 +11
Branches 346 351 +5
==========================================
+ Hits 842 852 +10
Misses 52 52
- Partials 208 209 +1
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
lwp_ext_ent_handlerfetched external entity content via LWP with no size limit or timeout, enabling denial-of-service by pointing external entities at extremely large or slow remote resources.This adds
LWP_MaxEntitySize(default 1 MB) andLWP_Timeout(default 30s) constructor options that configure the internalLWP::UserAgent. Responses truncated by the size limit are rejected with a clear parse error. SetLWP_MaxEntitySize => 0to restore the previous unlimited behavior.Fixes #276
Changes
Parser/LWPExternEnt.pl: Applymax_sizeandtimeoutto the UserAgent; detect and reject truncated responses viaClient-AbortedheaderParser.pm: DocumentLWP_MaxEntitySizeandLWP_Timeoutoptions in both the constructor options list and SECURITY sectiont/lwp_entity_limits.t: 9 tests covering defaults, custom values, truncation detection, limit disabling, and HTTP error passthroughTest plan
LWP_MaxEntitySize => 0Generated by Kōan /fix
Quality Report
Changes: 4 files changed, 217 insertions(+)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline