Skip to content

[#31] Limit anonymous log reads and rate limit public endpoints - #52

Merged
sksingh2005 merged 1 commit into
mnemosyne-systems:mainfrom
Mohamed-Alkafory:public-log-limits
Nov 13, 2026
Merged

sksingh2005 merged 1 commit into
mnemosyne-systems:mainfrom
Mohamed-Alkafory:public-log-limits

Conversation

@Mohamed-Alkafory

Copy link
Copy Markdown
Collaborator

Closes #31

Anonymous log reads are capped at PUBLIC_LOG_MAX_BYTES (2 MiB default) per
response, with offset/limit/tail and X-Log-* headers for paging.
Signed-in callers still get the full log. Anonymous requests to
/api/project-pages/** and /api/stats/public are rate limited per client
address, returning 429 with Retry-After. The public page pauses polling while
hidden and backs off when idle, and the log view appends new output, switches to
the tail when the inline view is full, and pages the full download.

@Mohamed-Alkafory Mohamed-Alkafory self-assigned this Nov 13, 2026
@Mohamed-Alkafory Mohamed-Alkafory added the bug Something isn't working label Nov 13, 2026

@sksingh2005 sksingh2005 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the overlapping log loads before merging. A build status change can trigger load() while an earlier request is pending. Both requests can read from the same offset and increment offsetRef.current, while only one response remains displayed.

I reproduced this with two responses containing abc: the view displays abc, but the next refresh requests offset 6 instead of 3, skipping output.

Please cancel or ignore superseded requests, update the offset only for the accepted response, and add a regression test for overlapping loads.

@ecleon26

Copy link
Copy Markdown
Collaborator

@Mohamed-Alkafory @sksingh2005 @jesperpedersen

i went thru the code and i am bit skeptical about security here, but idk how big of the concern it really is, so i would appreciate ur thoughts on it aswell.

  1. a rate limiter can be used to lock out new legititmate visitors: a hacker can easily keep the 10k address limit full, which will show 429 to new visitors.
  2. large anonymous download willl always fail - an anonymous user get 120 req per minute along with 2MiB per req. Any log over 240MiB will stop partway with 429, making it a loop

there are some more, but not as imp as these

@Mohamed-Alkafory

Copy link
Copy Markdown
Collaborator Author

Thanks @ecleon26, good catches both were valid.

Fixed: the limiter now evicts the oldest window instead of returning 429, so a full client map can’t lock out new visitors. Anonymous downloads now honor Retry-After and continue from the same offset with bounded retries, so large logs complete across windows.

@sksingh2005

Copy link
Copy Markdown
Collaborator

LGTM.

@sksingh2005
sksingh2005 merged commit b8a6945 into mnemosyne-systems:main Nov 13, 2026
2 checks passed
@sksingh2005

Copy link
Copy Markdown
Collaborator

Merged. Thanks for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Limit anonymous build log reads and add rate limiting for public endpoints

3 participants