Skip to content

fix(line): limit webhook request body size to prevent DoS#1413

Merged
alexhoshina merged 2 commits intosipeed:mainfrom
ex-takashima:fix/line-webhook-body-limit
Mar 12, 2026
Merged

fix(line): limit webhook request body size to prevent DoS#1413
alexhoshina merged 2 commits intosipeed:mainfrom
ex-takashima:fix/line-webhook-body-limit

Conversation

@ex-takashima
Copy link
Contributor

Summary

  • Add io.LimitReader (1 MB cap) to the LINE webhook handler to prevent unauthenticated memory exhaustion via oversized POST requests
  • Reject oversized requests with 413 Request Entity Too Large before signature verification
  • Follow the same pattern used in the WeCom channel (io.LimitReader + overflow check)
  • Add webhook handler tests (body size limit, method check, signature validation)

Fixes #1407

Test plan

  • TestWebhookRejectsOversizedBody — verifies 413 for body > 1 MB
  • TestWebhookRejectsNonPostMethod — verifies 405 for non-POST
  • TestWebhookRejectsInvalidSignature — verifies 403 for bad signature
  • All 3 tests pass

🤖 Generated with Claude Code

Add io.LimitReader with 1 MB cap on the LINE webhook handler to prevent
unauthenticated memory exhaustion via oversized POST requests.

Follows the same pattern used in the WeCom channel (io.LimitReader).
Requests exceeding the limit are rejected with 413 Request Entity Too Large.

Fixes sipeed#1407

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@CLAassistant
Copy link

CLAassistant commented Mar 12, 2026

CLA assistant check
All committers have signed the CLA.

- Move maxWebhookBodySize to package-level const
- Add TestWebhookAcceptsMaxBodySize (exact limit → 403, not 413)
- Add TestWebhookRejectsOversizedBodyBeforeSignatureCheck
- Use const in test instead of magic number

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sipeed-bot sipeed-bot bot added type: bug Something isn't working domain: channel go Pull requests that update go code labels Mar 12, 2026
@alexhoshina alexhoshina merged commit 19835b2 into sipeed:main Mar 12, 2026
4 checks passed
neotty pushed a commit to neotty/picoclaw that referenced this pull request Mar 12, 2026
* fix(line): limit webhook request body size to prevent DoS

Add io.LimitReader with 1 MB cap on the LINE webhook handler to prevent
unauthenticated memory exhaustion via oversized POST requests.

Follows the same pattern used in the WeCom channel (io.LimitReader).
Requests exceeding the limit are rejected with 413 Request Entity Too Large.

Fixes sipeed#1407

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor(line): hoist body size const, add boundary tests

- Move maxWebhookBodySize to package-level const
- Add TestWebhookAcceptsMaxBodySize (exact limit → 403, not 413)
- Add TestWebhookRejectsOversizedBodyBeforeSignatureCheck
- Use const in test instead of magic number

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
neotty pushed a commit to neotty/picoclaw that referenced this pull request Mar 12, 2026
* fix(line): limit webhook request body size to prevent DoS

Add io.LimitReader with 1 MB cap on the LINE webhook handler to prevent
unauthenticated memory exhaustion via oversized POST requests.

Follows the same pattern used in the WeCom channel (io.LimitReader).
Requests exceeding the limit are rejected with 413 Request Entity Too Large.

Fixes sipeed#1407

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor(line): hoist body size const, add boundary tests

- Move maxWebhookBodySize to package-level const
- Add TestWebhookAcceptsMaxBodySize (exact limit → 403, not 413)
- Add TestWebhookRejectsOversizedBodyBeforeSignatureCheck
- Use const in test instead of magic number

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Anr-C pushed a commit to Anr-C/picoclaw that referenced this pull request Mar 12, 2026
* fix(line): limit webhook request body size to prevent DoS

Add io.LimitReader with 1 MB cap on the LINE webhook handler to prevent
unauthenticated memory exhaustion via oversized POST requests.

Follows the same pattern used in the WeCom channel (io.LimitReader).
Requests exceeding the limit are rejected with 413 Request Entity Too Large.

Fixes sipeed#1407

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor(line): hoist body size const, add boundary tests

- Move maxWebhookBodySize to package-level const
- Add TestWebhookAcceptsMaxBodySize (exact limit → 403, not 413)
- Add TestWebhookRejectsOversizedBodyBeforeSignatureCheck
- Use const in test instead of magic number

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
davidburhans added a commit to davidburhans/picoclaw that referenced this pull request Mar 13, 2026
Conflicts resolved:
- helpers.go: merged import sections (io, log, net/http + sync)
- config.go: merged AgentDefaults with Schedule, SafetyLevel, BirthYear

Upstream features merged:
- Config hot reload (PR sipeed#1187)
- Anthropic Messages protocol (PR sipeed#1284)
- Enhanced Skill Installer v2 (PR sipeed#1252)
- Model command CLI (PR sipeed#1250)
- ModelScope provider (PR sipeed#1486)
- LINE webhook DoS protection (PR sipeed#1413)
dj-oyu pushed a commit to dj-oyu/picoclaw that referenced this pull request Mar 14, 2026
* fix(line): limit webhook request body size to prevent DoS

Add io.LimitReader with 1 MB cap on the LINE webhook handler to prevent
unauthenticated memory exhaustion via oversized POST requests.

Follows the same pattern used in the WeCom channel (io.LimitReader).
Requests exceeding the limit are rejected with 413 Request Entity Too Large.

Fixes sipeed#1407

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor(line): hoist body size const, add boundary tests

- Move maxWebhookBodySize to package-level const
- Add TestWebhookAcceptsMaxBodySize (exact limit → 403, not 413)
- Add TestWebhookRejectsOversizedBodyBeforeSignatureCheck
- Use const in test instead of magic number

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
dj-oyu pushed a commit to dj-oyu/picoclaw that referenced this pull request Mar 16, 2026
* fix(line): limit webhook request body size to prevent DoS

Add io.LimitReader with 1 MB cap on the LINE webhook handler to prevent
unauthenticated memory exhaustion via oversized POST requests.

Follows the same pattern used in the WeCom channel (io.LimitReader).
Requests exceeding the limit are rejected with 413 Request Entity Too Large.

Fixes sipeed#1407

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor(line): hoist body size const, add boundary tests

- Move maxWebhookBodySize to package-level const
- Add TestWebhookAcceptsMaxBodySize (exact limit → 403, not 413)
- Add TestWebhookRejectsOversizedBodyBeforeSignatureCheck
- Use const in test instead of magic number

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
j0904 pushed a commit to j0904/picoclaw that referenced this pull request Mar 22, 2026
* fix(line): limit webhook request body size to prevent DoS

Add io.LimitReader with 1 MB cap on the LINE webhook handler to prevent
unauthenticated memory exhaustion via oversized POST requests.

Follows the same pattern used in the WeCom channel (io.LimitReader).
Requests exceeding the limit are rejected with 413 Request Entity Too Large.

Fixes sipeed#1407

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor(line): hoist body size const, add boundary tests

- Move maxWebhookBodySize to package-level const
- Add TestWebhookAcceptsMaxBodySize (exact limit → 403, not 413)
- Add TestWebhookRejectsOversizedBodyBeforeSignatureCheck
- Use const in test instead of magic number

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: channel go Pull requests that update go code type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] LINE webhook handler reads unlimited bodies (DoS risk)

3 participants