Skip to content

fix(auth): rate-limit /v1/auth/extension/session by session, not IP - #6137

Merged
JSONbored merged 1 commit into
mainfrom
fix/auth-extension-session-rate-limit-key
Jul 15, 2026
Merged

fix(auth): rate-limit /v1/auth/extension/session by session, not IP#6137
JSONbored merged 1 commit into
mainfrom
fix/auth-extension-session-rate-limit-key

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Pre-existing behavior from #556, unrelated to the #6114-#6117 GitHub-auth milestone — shipping as its own standalone fix.

Test plan

The same pre-auth-vs-session-authenticated gap #6117 fixed for
/v1/auth/github/token also applies to /v1/auth/extension/session (#556):
isPreAuthRateLimitPath's broad /v1/auth/ prefix match classified it as
pre-auth, keying its rate limit by client IP. But this endpoint always
requires (and validates) a real session bearer token to mint a new
extension-scoped session from it -- it is not a pre-auth flow. IP-keying
meant a caller with a stolen session token could bypass the strict 10/min
cap by rotating source IPs, and unrelated sessions behind a shared IP
(office NAT, CI infra) would throttle each other.

Generalized the #6117 fix's single-path exclusion into a small Set of
session-authenticated /v1/auth/* paths and added this one to it. Falls
through to token-based rate-limit keying when a valid bearer is present,
falling back to IP-keying only when no valid bearer is supplied, matching
every other authenticated route.
@JSONbored JSONbored self-assigned this Jul 15, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.33%. Comparing base (90da839) to head (11b3bab).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6137   +/-   ##
=======================================
  Coverage   95.33%   95.33%           
=======================================
  Files         598      598           
  Lines       47177    47178    +1     
  Branches    15025    15025           
=======================================
+ Hits        44974    44975    +1     
  Misses       1477     1477           
  Partials      726      726           
Flag Coverage Δ
shard-1 43.94% <100.00%> (-0.01%) ⬇️
shard-2 36.68% <100.00%> (+0.01%) ⬆️
shard-3 32.11% <100.00%> (-0.05%) ⬇️
shard-4 34.00% <100.00%> (-0.15%) ⬇️
shard-5 31.45% <100.00%> (-0.76%) ⬇️
shard-6 45.24% <100.00%> (+0.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/auth/rate-limit.ts 98.90% <100.00%> (+0.01%) ⬆️

@JSONbored
JSONbored merged commit 4a5bd94 into main Jul 15, 2026
17 checks passed
@JSONbored
JSONbored deleted the fix/auth-extension-session-rate-limit-key branch July 15, 2026 12:41
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant