mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #509] [MERGED] fix(diagnostics): bound the rejection-announce caches + unify CSRF 403 schema #4650
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4650
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/509
Author: @LukaTheHero
Created: 5/7/2026
Status: ✅ Merged
Merged: 5/7/2026
Merged by: @LukaTheHero
Base:
main← Head:fix/bounded-rejection-cache-and-csrf-field-consistency📝 Commits (1)
1be71ccfix(diagnostics): bound the rejection-announce caches and unify CSRF 403 schema📊 Changes
2 files changed (+24 additions, -2 deletions)
View changed files
📝
packages/server/src/config/cors-config.ts(+9 -0)📝
packages/server/src/middleware/csrf-protection.ts(+15 -2)📄 Description
Summary
Two follow-ups from CodeRabbit's post-merge review of #507:
csrf-protection.tsandcors-config.ts. They were keyed by attacker-controlled strings (Origin / Referer values) so a long-lived client streaming unique values could grow process memory without bound. Both sites now hold at most 2048 entries and drop the oldest when full (Set's insertion order acts as a FIFO). The rare case of a fresh origin from a long-lived attacker eventually re-logging once is an acceptable trade-off for unbounded growth.refererfield while the sibling branches returnedorigin. Clients parsing the body had to handle both keys. Standardised onorigin(the error string still names "Referer" so the operator knows which header carried the offending value).Why
Both items were flagged by CodeRabbit's second review pass after #507 merged:
cors-config.ts. Fixing both for consistency rather than waiting for the next review round.What changed
packages/server/src/middleware/csrf-protection.ts— addedMAX_ANNOUNCED_REJECTED_ORIGINS = 2048cap with FIFO eviction inannounceRejectedOrigin. Renamed the 403refererfield tooriginfor the Referer-not-trusted branch.packages/server/src/config/cors-config.ts— same cap + FIFO eviction pattern in the cross-origin announce site (proactive, not flagged but identical code).Notes
Set.values().next()(Set preserves insertion order in JS). Could be upgraded to LRU later if we ever see real-world recycling patterns, but that's overkill for a log-throttle cache.main(rebased after the unrelatedbase-provider.ts/context-fit.test.tsmerge).Test plan
origin: "<value>"and notreferer: "<value>". (Easiest: hit any POST to/api/...from a browser context where the page strips Origin but leaves Referer; or curl with--referer https://other.exampleand no Origin.)[cors] Rejected cross-origin request from …) still fires for cross-origin requests not inCORS_ORIGINS.[csrf] Rejected request: Origin '…' is not in the trusted list. …) still fires for requests whose Origin is unknown.Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.