[PR #9192] fix(cimd): use ipaddr.js to better cover edge cases #25393

Open
opened 2026-04-15 22:51:59 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/9192
Author: @dvanmali
Created: 4/14/2026
Status: 🔄 Open

Base: nextHead: cimdIpAddr


📝 Commits (3)

  • d778d78 fix: use ipaddr.js to better cover private address ranges and IPv6
  • cd26f14 feat: improved ipAddr literal ranges
  • 6d3e51d fix: copilot suggestions

📊 Changes

7 files changed (+175 additions, -100 deletions)

View changed files

📝 .changeset/cimd-plugin.md (+1 -1)
📝 packages/cimd/package.json (+3 -0)
📝 packages/cimd/src/client-store.ts (+5 -1)
📝 packages/cimd/src/types.ts (+21 -0)
📝 packages/cimd/src/validate-metadata-document.test.ts (+87 -0)
📝 packages/cimd/src/validate-metadata-document.ts (+49 -98)
📝 pnpm-lock.yaml (+9 -0)

📄 Description

Use ipaddr.js package to better cover IP address ranges. For example, not all special ranges were covered and overall reduces maintained code/edge-cases.

Adds allowedIpRanges to allow users to further restrict/open ranges in advanced scenarios.


Summary by cubic

Replaces custom IP checks with ipaddr.js to validate IP‑literal hosts in client_id URLs and embedded fields. Adds allowedIpRanges to configure permitted ipaddr.js ranges (default unicast).

  • Bug Fixes

    • Use ipaddr.js for IPv4/IPv6 parsing, including IPv4‑mapped IPv6 and stripping IPv6 zone IDs; reject malformed IP‑literals.
    • Enforce range allowlist; keep metadata.google.internal blocked by name and allow localhost.
  • New Features

    • Add allowedIpRanges?: Set<...> in CimdOptions to narrow/expand allowed ranges (default new Set(["unicast"])).
    • Apply the option in validateClientIdUrl, validateCimdMetadata, and the client-store fetch path.

Written for commit 6d3e51d614. 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/9192 **Author:** [@dvanmali](https://github.com/dvanmali) **Created:** 4/14/2026 **Status:** 🔄 Open **Base:** `next` ← **Head:** `cimdIpAddr` --- ### 📝 Commits (3) - [`d778d78`](https://github.com/better-auth/better-auth/commit/d778d78db3cb20e028e8ac343d9b0fdac4b244e2) fix: use ipaddr.js to better cover private address ranges and IPv6 - [`cd26f14`](https://github.com/better-auth/better-auth/commit/cd26f14ba01514698aa581540206b3b2184bddcd) feat: improved ipAddr literal ranges - [`6d3e51d`](https://github.com/better-auth/better-auth/commit/6d3e51d614775baab4d7647565a4f275aaec4c2c) fix: copilot suggestions ### 📊 Changes **7 files changed** (+175 additions, -100 deletions) <details> <summary>View changed files</summary> 📝 `.changeset/cimd-plugin.md` (+1 -1) 📝 `packages/cimd/package.json` (+3 -0) 📝 `packages/cimd/src/client-store.ts` (+5 -1) 📝 `packages/cimd/src/types.ts` (+21 -0) 📝 `packages/cimd/src/validate-metadata-document.test.ts` (+87 -0) 📝 `packages/cimd/src/validate-metadata-document.ts` (+49 -98) 📝 `pnpm-lock.yaml` (+9 -0) </details> ### 📄 Description Use `ipaddr.js` package to better cover IP address ranges. For example, not all [special ranges](https://github.com/whitequark/ipaddr.js/blob/1915d222d66c1a9bfc7578fe7464f9bed4ccaac9/lib/ipaddr.js#L562) were covered and overall reduces maintained code/edge-cases. Adds `allowedIpRanges` to allow users to further restrict/open ranges in advanced scenarios. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Replaces custom IP checks with `ipaddr.js` to validate IP‑literal hosts in `client_id` URLs and embedded fields. Adds `allowedIpRanges` to configure permitted ipaddr.js ranges (default `unicast`). - **Bug Fixes** - Use `ipaddr.js` for IPv4/IPv6 parsing, including IPv4‑mapped IPv6 and stripping IPv6 zone IDs; reject malformed IP‑literals. - Enforce range allowlist; keep `metadata.google.internal` blocked by name and allow `localhost`. - **New Features** - Add `allowedIpRanges?: Set<...>` in `CimdOptions` to narrow/expand allowed ranges (default `new Set(["unicast"])`). - Apply the option in `validateClientIdUrl`, `validateCimdMetadata`, and the client-store fetch path. <sup>Written for commit 6d3e51d614775baab4d7647565a4f275aaec4c2c. 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-15 22:51:59 -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#25393