Skip to content

fix: Session and user zone rate limits can be bypassed via trailing-slash or case path variants#10501

Open
mtrezza wants to merge 1 commit into
parse-community:alphafrom
mtrezza:fix/rate-limit-login-path-variants
Open

fix: Session and user zone rate limits can be bypassed via trailing-slash or case path variants#10501
mtrezza wants to merge 1 commit into
parse-community:alphafrom
mtrezza:fix/rate-limit-login-path-variants

Conversation

@mtrezza

@mtrezza mtrezza commented Jun 11, 2026

Copy link
Copy Markdown
Member

Issue

Express routes case-insensitively and tolerates a trailing slash by default, so /login/, /LOGIN, and /sessions/me/ reach the same handlers as their canonical paths. The middleware checks that drop the inbound session token on /login (used for rate-limit zone keying) and that short-circuit session resolution on GET /sessions/me used a strict string comparison, so they did not recognize these routing-equivalent variants. As a result, a session- or user-zone rate limit configured on those routes could be keyed inconsistently (by token or user id instead of the client IP) and drawn from a separate window when the request used a variant path, splitting or evading the configured limit.

Tasks

  • Add tests

Summary by CodeRabbit

  • Bug Fixes
    • Rate-limiting windows are now consistent across equivalent URLs with different casing and trailing slashes. Requests to /login, /login/, and /LOGIN now correctly share the same rate-limit window. Similarly, /sessions/me and /sessions/me/ are treated identically for session-zone rate limiting.

@parse-github-assistant

Copy link
Copy Markdown

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant Bot changed the title fix: session and user zone rate limits can be bypassed via trailing-slash or case path variants fix: Session and user zone rate limits can be bypassed via trailing-slash or case path variants Jun 11, 2026
@parse-github-assistant

Copy link
Copy Markdown

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c6b9618a-dbc3-4c00-9916-a38711e4a925

📥 Commits

Reviewing files that changed from the base of the PR and between 0644675 and c5349e8.

📒 Files selected for processing (3)
  • spec/RateLimit.spec.js
  • src/batch.js
  • src/middlewares.js

📝 Walkthrough

Walkthrough

PR adds matchesExactRoute() helper function to normalize request paths (trailing slash removal, case-insensitive matching) for consistent rate-limit keying. The matcher is applied in middlewares.js session-token handling, batch.js sub-request logic, and verified via new rate-limit tests for /login and /sessions/me route variants.

Changes

Route normalization for exact static route matching

Layer / File(s) Summary
Exact route matcher implementation
src/middlewares.js
New exported matchesExactRoute(path, route) normalizes the incoming path by trimming trailing slashes and lowercasing, then compares it to the provided route.
Middleware route matching updates
src/middlewares.js
handleParseHeaders and handleParseSession replace strict path equality checks with matchesExactRoute() when detecting /login and /sessions/me routes for session token and auth resolution.
Batch sub-request rate-limit integration
src/batch.js
Import matchesExactRoute and apply it to the login-path check that removes info.sessionToken during batch sub-request rate-limit handling.
Rate-limit keying consistency tests
spec/RateLimit.spec.js
New test suite exact static route variants verifies that rate-limit windows remain unified across trailing-slash and case-variant routes for /login (session zone) and /sessions/me (user zone).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • parse-community/parse-server#10500: Both PRs update route-matching logic in src/middlewares.js for exact static endpoints to prevent rate-limit keying differences due to URL formatting.
  • parse-community/parse-server#10213: Both PRs modify handleParseSession logic for the /sessions/me endpoint route detection and early-exit behavior.
  • parse-community/parse-server#10349: Both PRs adjust batch sub-request rate-limit handling for the /login route session-token removal to ensure consistent rate-limiting across URL variants.
🚥 Pre-merge checks | ✅ 5 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Engage In Review Feedback ❓ Inconclusive Cannot verify engagement with review feedback; PR is recent and open with single commit. GitHub PR review comments are not accessible from repository state alone. Access the actual GitHub PR #10501 to view review comments and verify engagement; check if reviews exist and whether they were addressed through commits or discussion threads.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title begins with 'fix:' prefix and accurately describes the main change: fixing rate limit bypass vulnerabilities via path variants.
Description check ✅ Passed The PR description includes the Issue section explaining the problem and the Tasks section confirming tests were added, but lacks the Approach section detailing the specific changes made.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Check ✅ Passed PR fixes rate-limit bypass vulnerability by matching Express's case-insensitive, trailing-slash-tolerant routing. Implementation uses safe string operations with proper type checking, no injection...

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 OpenGrep (1.22.0)

OpenGrep fatal error (exit code 2): [00.10][ERROR]: Error: exception Unix_error: No such file or directory stat src/batch.js
Raised by primitive operation at UTmp.replace_named_pipe_by_regular_file_if_needed in file "libs/commons/UTmp.ml", line 145, characters 8-27
Called from Scan_CLI.replace_target_roots_by_regular_files_where_needed.(fun) in file "src/osemgrep/cli_scan/Scan_CLI.ml", lines 1086-1087, characters 19-65
Called from List_.fast_map in file "libs/commons/List_.ml", line 81, characters 17-20
Called from Scan_CLI.replac


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mtrezza mtrezza force-pushed the fix/rate-limit-login-path-variants branch from f5421c5 to c5349e8 Compare June 11, 2026 01:42
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.61%. Comparing base (880e8e6) to head (c5349e8).
⚠️ Report is 1 commits behind head on alpha.

Additional details and impacted files
@@            Coverage Diff             @@
##            alpha   #10501      +/-   ##
==========================================
- Coverage   92.62%   92.61%   -0.01%     
==========================================
  Files         193      193              
  Lines       16941    16942       +1     
  Branches      240      240              
==========================================
  Hits        15691    15691              
- Misses       1227     1228       +1     
  Partials       23       23              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant