Repository navigation
fix(php): keep rate-limit counters in the private temp directory - #19
Merged
Merged
Conversation
The built-in limiter stored its counters in a fixed shared directory (dewee-webchat-rl) under the system temp dir. On a shared host another account could create it first and reset, inflate or redirect the counters. Counters now live in the per-user private directory, new files are created exclusively, and an existing file is used only when it is this user's own and not writable by others. Closes #18 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A1xMi7a6shAxFWLtFT4don
mrgoonie
marked this pull request as ready for review
October 31, 2026 05:39
This was referenced Oct 31, 2026
Merged
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.
Closes #18.
The PHP backend's built-in rate limiter stored its counters in
sys_get_temp_dir()/dewee-webchat-rl. On a shared host another account could create that directory first and then reset, inflate or redirect the counters.Changes
rl-<hash>) now live in the per-user private directory from fix(php): isolate shared temp files and require a secret #16 (dewee-webchat-<uid>,0700, not used when it is a link, foreign-owned or open to others). When that directory is unavailable, requests are not limited anderror_logsays why. This matches the existing fail-open behaviour.fopen(..., 'x+'), so a planted link is never followed, and set to0600. An existing file is opened only when it is this user's own regular file and nobody else can write to it.rl-*files, so the cached CCP config and the legacy-warning marker in the same directory are left alone.Verification
dewee-webchat-rlplanted in the temp dir stays empty, and the counters land in the private directory with no group or other permissions. The test fails on the old code and passes with the fix.pnpm test: 20 files, 267 tests pass.pnpm typecheckpasses.php -lis clean.Generated by Claude Code