[PR #7300] [CLOSED] feat(rate-limit): add IPv6 address normalization and subnet support #15456

Closed
opened 2026-04-13 10:02:24 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7300
Author: @himself65
Created: 1/12/2026
Status: Closed

Base: canaryHead: himself65/2026/01/12/ipv6


📝 Commits (1)

  • cd97767 feat(rate-limit): add IPv6 address normalization and subnet support

📊 Changes

7 files changed (+690 additions, -111 deletions)

View changed files

📝 docs/content/docs/concepts/rate-limit.mdx (+39 -1)
📝 packages/better-auth/src/api/rate-limiter/index.ts (+2 -1)
📝 packages/better-auth/src/api/rate-limiter/rate-limiter.test.ts (+175 -92)
📝 packages/better-auth/src/utils/get-request-ip.ts (+4 -17)
📝 packages/core/src/types/init-options.ts (+19 -0)
packages/core/src/utils/ip.test.ts (+240 -0)
packages/core/src/utils/ip.ts (+211 -0)

📄 Description

Summary by cubic

Adds IPv6-aware rate limiting with address normalization and optional subnet grouping to prevent bypass via alternate IPv6 forms or IPv4-mapped addresses. Also changes rate-limit keys to use a pipe separator to avoid collisions.

  • New Features

    • Normalize IPv6 to a canonical form and convert IPv4‑mapped IPv6 (e.g., ::ffff:192.0.2.1) to IPv4 before rate limiting.
    • Add rateLimit.ipv6Subnet (32/48/64/128; default 128) to group IPv6 requests by subnet when desired.
  • Migration

    • Rate-limit keys now use {ip}|{path} instead of {ip}{path}. Update any custom storage or tooling that reads/writes keys. Existing keys will be recreated automatically as requests arrive.

Written for commit cd9776780e. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7300 **Author:** [@himself65](https://github.com/himself65) **Created:** 1/12/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `himself65/2026/01/12/ipv6` --- ### 📝 Commits (1) - [`cd97767`](https://github.com/better-auth/better-auth/commit/cd9776780e27e35e6a8c578a145d246ad58c17b1) feat(rate-limit): add IPv6 address normalization and subnet support ### 📊 Changes **7 files changed** (+690 additions, -111 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/concepts/rate-limit.mdx` (+39 -1) 📝 `packages/better-auth/src/api/rate-limiter/index.ts` (+2 -1) 📝 `packages/better-auth/src/api/rate-limiter/rate-limiter.test.ts` (+175 -92) 📝 `packages/better-auth/src/utils/get-request-ip.ts` (+4 -17) 📝 `packages/core/src/types/init-options.ts` (+19 -0) ➕ `packages/core/src/utils/ip.test.ts` (+240 -0) ➕ `packages/core/src/utils/ip.ts` (+211 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Adds IPv6-aware rate limiting with address normalization and optional subnet grouping to prevent bypass via alternate IPv6 forms or IPv4-mapped addresses. Also changes rate-limit keys to use a pipe separator to avoid collisions. - **New Features** - Normalize IPv6 to a canonical form and convert IPv4‑mapped IPv6 (e.g., ::ffff:192.0.2.1) to IPv4 before rate limiting. - Add rateLimit.ipv6Subnet (32/48/64/128; default 128) to group IPv6 requests by subnet when desired. - **Migration** - Rate-limit keys now use {ip}|{path} instead of {ip}{path}. Update any custom storage or tooling that reads/writes keys. Existing keys will be recreated automatically as requests arrive. <sup>Written for commit cd9776780e27e35e6a8c578a145d246ad58c17b1. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 10:02:24 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#15456