Skip to content

Upgrade umami-extra-privacy to v1.0.0 - #50

Merged
nimble-turtle merged 2 commits into
mainfrom
dev/umami-extra-privacy-v1
Nov 25, 2026
Merged

nimble-turtle merged 2 commits into
mainfrom
dev/umami-extra-privacy-v1

Conversation

@nimble-turtle

Copy link
Copy Markdown
Contributor

Summary

Upgrades @activistchecklist/umami-extra-privacy to v1.0.0 and updates the Privacy page to match.

 POST /api/counter
   toWebRequest: x-forwarded-for = trusted client IP
   createRouteHandler({ level: "geo-hash" })
     anonymizeIp(ip)
-      sha256(ip + day + IP_HASH_SALT)    # anyone with the salt can redo any past day
+      keyed shuffle, random key           # memory only, wiped at UTC midnight and on restart
     sendUmamiEvent(payload)

What Umami receives:

Input v0.1.0 v1.0.0
IPv4 first 19 bits kept first 19 bits kept
IPv6 first 48 bits kept first 28 bits kept, interface ID zeroed
::ffff:1.2.3.4, 1.2.3.4:443, junk forwarded unchanged treated as IPv4, or left out
No IP_HASH_SALT 500 works

The pin is now #v1.0.0 instead of a SHA. Dependabot only updates git refs that look like version tags (latest_git_version_details in dependabot-core); a SHA ref is never updated, which is how this release went unnoticed. yarn.lock still pins commit cdc7422. A local test showed yarn 1 keeps the locked commit after a tag is moved, with or without --frozen-lockfile.

package.json, yarn.lock        # #v1.0.0, resolved to cdc7422
server/routes/counter.ts       # comment describes the in-memory key
server/routes/counter.test.ts  # new: drives the real route with fetch stubbed
.env.local.example             # IP_HASH_SALT removed
client/PrivacyPage.tsx         # "How we anonymize your IP" rewritten, shorter

lib/analytics/events.ts needs no change: the package's /client API is identical in v1.0.0.

Evidence

  • Before (v0.1.0, geo-hash):

    anonymizeIp("::ffff:203.0.113.77") -> "::ffff:203.0.113.77"
    anonymizeIp("203.0.113.77:443")    -> "203.0.113.77:443"
    anonymizeIp("unknown")             -> "unknown"
    anonymizeIp(ip) with no salt       -> throws
    

    After: server/routes/counter.test.ts, through the real route:

    64 neighbours in one /19 -> same /19, all distinct, low bits shuffled
    same address             -> same stand-in all day, new ones after UTC midnight
    ::ffff:203.0.113.77      -> IPv4 stand-in in 203.0.96.0/19
    IPv6                     -> first 28 bits kept, last 64 zero
    "unknown"                -> no ip in the payload
    no IP_HASH_SALT          -> 200
    
  • Full suite: 86 files, 852 tests pass. Lint, typecheck and build are clean.

  • Live relay against a local stand-in for Umami on 127.0.0.1 (run before rebasing onto Raise the Node floor to 24.22.3 and clear the minimatch alert #49):

    production client pageview                               -> POST /api/counter 200
    X-Forwarded-For: 198.51.100.200, 203.0.113.77            -> ip 203.0.98.194, same on repeat
    X-Forwarded-For: 2001:db8:1234:5678:9abc:def0:1234:5678  -> ip 2001:db5:8c8b:d562:0:0:0:0
    

    Both pages loaded only from their own origin.

Merge Danger

Door: two-way, while IP_HASH_SALT stays in the production env

v0.1.0 throws without the salt, so a revert after the variable is deleted would break the relay until it is restored. Delete it once this has been live for a while.

Blast Radius: analytics

Each deploy or restart starts a new key, so a visitor active across one counts as two sessions that day. The upgrade alone builds a byte-identical dist/ (checked before rebasing); the Privacy page copy changes it, so pushing main needs a WEBCAT signature.

v1.0.0 replaces the salted daily hash behind `geo-hash` with a random
key that lives only in the server process's memory and is wiped at each
UTC midnight (and on restart). A stand-in can no longer be traced back to
a real address after its day ends, even by someone holding our env files
and the Umami database. The `salt` option and IP_HASH_SALT are gone, and
the IPv6 stand-in now keeps 28 bits instead of 48 and zeroes the
interface ID.

It also stops forwarding addresses it cannot parse. v0.1.0 passed
`::ffff:1.2.3.4`, `1.2.3.4:443` and junk to Umami unchanged under
`geo-hash`. Our server listens on IPv4 and hands the route a plain address
from X-Forwarded-For, so this was latent here, but the new test pins it.

The dependency now points at the `v1.0.0` tag instead of a commit SHA.
Dependabot only follows git refs that look like versions; a SHA ref is
never updated, which is how this release went unnoticed. yarn.lock still
pins the resolved commit (cdc7422), and a yarn install keeps that commit
even if the tag is later moved, so the lockfile remains the real pin.

The client helper is unchanged, so lib/analytics needs no change, and
`yarn build` produces a byte-identical dist/. Only dist-server changes.

- server/routes/counter.ts: describe the new scheme, drop stale salt and
  Next.js notes.
- server/routes/counter.test.ts: drive the real route with fetch stubbed
  and pin what reaches Umami: the /19 kept and the rest shuffled, the
  same stand-in all day and new ones the next, mapped IPv6 handled as
  IPv4, IPv6 cut to 28 bits, unparseable addresses left out, no salt
  needed.
- .env.local.example: remove IP_HASH_SALT.
umami-extra-privacy v1.0.0 no longer uses a daily salt. The stand-in
address is made with a random key that is never saved and is erased
every day, after which nobody can map it back to a real address. The
"How we anonymize your IP" section said the salt rotated daily; it now
describes the key, in fewer words.

This changes dist/, so it needs a new WEBCAT signature.
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 54 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3cd87f2f-115e-4fe9-b946-1fea1c0d957d
Commits

Reviewing files that changed from the base of the PR and between e59d4ba and 2fae237.

Files ignored due to path filters: 1

  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing: 5

  • .env.local.example
  • client/PrivacyPage.tsx
  • package.json
  • server/routes/counter.test.ts
  • server/routes/counter.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@nimble-turtle
nimble-turtle merged commit 8eefa6a into main Nov 25, 2026
2 checks passed
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