#17182: security(line): fail closed when webhook token/secret are missing
stale
size: S
Cluster:
Webhook Security Enhancements
## Problem
LINE webhook startup accepted empty auth inputs, which weakens webhook trust assumptions and risks fail-open behavior.
## What Changed
- Added strict startup guards in `src/line/monitor.ts` to require non-empty `channelAccessToken` and `channelSecret`.
- Trimmed token/secret before wiring bot and webhook handler.
- Added regression tests in `src/line/monitor.auth-guards.test.ts` ensuring startup fails closed and bot creation is not attempted.
## Validation
- `pnpm vitest run src/line/monitor.auth-guards.test.ts`
Fixes #17158
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds startup validation to prevent LINE webhook initialization with empty credentials. Trims `channelAccessToken` and `channelSecret` before checking, and throws descriptive errors (referencing config paths) if either is empty. Test coverage ensures bot creation is never attempted when auth material is missing.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The changes implement straightforward security hardening with proper fail-closed behavior. The validation logic is correct (trim then check for emptiness), error messages are informative, and the test coverage verifies both edge cases. The guards execute early before any bot initialization or state recording, preventing potential security issues from empty credentials.
- No files require special attention
<sub>Last reviewed commit: 191c5a7</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#17593: security: fail closed when LINE webhook secret is missing
by davidahmann · 2026-02-15
92.7%
#13521: telegram: require webhook secret in runtime webhook mode
by davidahmann · 2026-02-10
76.8%
#23621: fix(LINE): keep startAccount promise alive to prevent auto-restart ...
by ttakanawa · 2026-02-22
75.6%
#11110: fix(line): false 'not configured' warnings when tokenSource=file
by lailoo · 2026-02-07
74.1%
#8067: fix(telegram): use timing-safe comparison for webhook secret
by yubrew · 2026-02-03
73.8%
#5834: fix(line): add timeout and size limit to readRequestBody to prevent...
by hclsys · 2026-02-01
73.6%
#18777: fix: LINE webhook acknowledges events before processing and drops f...
by coygeek · 2026-02-17
72.2%
#21128: Security/Voice Call: require trusted proxy IPs for forwarded-header...
by bmendonca3 · 2026-02-19
71.9%
#12803: fix(line): avoid false 'not configured' warnings for file/env token...
by puritysb · 2026-02-09
71.7%
#21531: Security/Webhooks: block signed replay for Nextcloud, Google Chat, ...
by bmendonca3 · 2026-02-20
71.7%