Skip to content

Drop the audit log's IP and user agent columns - #75

Merged
Flatts3000 merged 2 commits into
mainfrom
fix-70-drop-audit-ip-columns
Aug 30, 2026
Merged

Flatts3000 merged 2 commits into
mainfrom
fix-70-drop-audit-ip-columns

Conversation

@Flatts3000

Copy link
Copy Markdown
Owner

Closes #70. Part two, and the reason it is a separate release is in #74.

#74 stopped anything writing ip_address and user_agent, and that code is deployed. Dropping the columns is now safe, because the image currently serving does not name them in its INSERTs. Doing both at once would have broken production: deploy.sh migrates while the previous backend is still serving, and the rollback path restores that same image against the already-migrated schema.

What changed

The migration drops both columns, taking whatever history they held with them. The schema stops declaring them. The comment left in their place says why they are gone, so the next person to reach for a convenient req.ip finds the reasoning rather than an absence.

The migration uses DROP COLUMN IF EXISTS. CI re-applies every migration against an already-migrated database to prove idempotency, and drizzle-kit generates a bare DROP COLUMN, which succeeds once and then errors - that is how the first attempt at this failed.

Tests

The assertion moves from values to schema. Reading information_schema is the stronger guarantee: deleting the code that writes a column leaves the column behind, and the test now fails if it ever comes back. It also checks the table did not simply vanish, which is how that kind of assertion passes for the wrong reason.

The deck, and a claim it was going to get wrong

Slide 10 disclosed the IP and browser string. That is now false, so it says what is actually kept: an email, and which group they work with.

The "what is not there" line widens to IP addresses or cookies in anything Relay stores, which is narrower than the phrasing I first wrote. "For anyone at all" would have been wrong: authLoginRateLimiter and authVerifyRateLimiter use express-rate-limit's default key generator, which keys on raw req.ip and holds it in memory for the full fifteen-minute window. The file's own comment says so.

Rather than quietly narrow the wording, that now appears in the slide's known-limits line, next to the routing metadata Relay already volunteers: the login rate limiter holds a caller address in memory for fifteen minutes to make brute-forcing a sign-in expensive, and neither is written down.

docs/prd_to_mvp_plan.md still listed ip_address in its record of the schema. Removed.

Verification

  • test database dropped and rebuilt from scratch, then every migration re-applied by hand: no failures, and audit_log ends with neither column
  • 152 backend tests pass, lint and typecheck clean
  • migration journal validated: 12 entries, sequential, snapshots parseable
  • deck swept in Chromium and WebKit at 1440x900, 901x640, 430x932 and 320x700

#74 stopped anything writing `ip_address` and `user_agent`, and that code is deployed. Dropping the columns is now safe, because the image currently serving does not name them in its INSERTs. Doing both at once would have broken production: `deploy.sh` migrates while the previous backend is still serving, and the rollback path restores that same image against the already-migrated schema.

## What changed

The migration drops both columns, taking whatever history they held with them. The schema stops declaring them. The comment left in their place says why they are gone, so the next person to reach for a convenient `req.ip` finds the reasoning rather than an absence.

The migration uses `DROP COLUMN IF EXISTS`. CI re-applies every migration against an already-migrated database to prove idempotency, and drizzle-kit generates a bare `DROP COLUMN`, which succeeds once and then errors - that is how the first attempt at this failed.

## Tests

The assertion moves from values to schema. Reading `information_schema` is the stronger guarantee: deleting the code that writes a column leaves the column behind, and the test now fails if it ever comes back. It also checks the table did not simply vanish, which is how that kind of assertion passes for the wrong reason.

## The deck, and a claim it was going to get wrong

Slide 10 disclosed the IP and browser string. That is now false, so it says what is actually kept: an email, and which group they work with.

The "what is not there" line widens to **IP addresses or cookies in anything Relay stores**, which is narrower than the phrasing I first wrote. "For anyone at all" would have been wrong: `authLoginRateLimiter` and `authVerifyRateLimiter` use express-rate-limit's default key generator, which keys on raw `req.ip` and holds it in memory for the full fifteen-minute window. The file's own comment says so.

Rather than quietly narrow the wording, that now appears in the slide's known-limits line, next to the routing metadata Relay already volunteers: the login rate limiter holds a caller address in memory for fifteen minutes to make brute-forcing a sign-in expensive, and neither is written down.

`docs/prd_to_mvp_plan.md` still listed `ip_address` in its record of the schema. Removed.

## Verification

- test database dropped and rebuilt from scratch, then every migration re-applied by hand: no failures, and `audit_log` ends with neither column
- 152 backend tests pass, lint and typecheck clean
Four findings. The first is not a deck wording problem, it is a live violation
of a constraint CLAUDE.md calls non-negotiable.

nginx's stock access log format ends with $http_user_agent and
$http_x_forwarded_for, and Caddy appends the real client address to
X-Forwarded-For before proxying. Only the health-check location set access_log
off. So every page load wrote the visitor's IP and browser string to stdout,
which Docker's default json-file driver persists on the host unrotated - no
logging options are set in the compose file.

Verified by request rather than by reading: GET /directory logged
"Mozilla/5.0 TestBrowser" "203.0.113.77". That is who browsed the public
directory, which CLAUDE.md forbids in as many words, and the deck was about to
deny it in the same release.

A log_format carrying only time, request, status, size and duration replaces it.
Same request now logs none of the three identifying strings. $remote_addr is
omitted as well: it is only ever Caddy's container address, so it identifies
nothing while reading as though it might.

The deck also lost a disclosure it should have kept. Trimming the organizer line
to an email and a group removed the activity trail along with the IP -
auditMiddleware still records every authenticated write plus sign-in and
sign-out against a user id and timestamp, and nothing prunes it. The line says
so again.

The known-limits sentence contradicted itself inside one clause: it said the
routing metadata is stored in the clear and then that neither limit is written
down, immediately before an existing sentence using the same phrase to mean
documented. Rewritten.

And an assertion in the new test could not fail: db.select projects whatever the
Drizzle model declares, so checking the returned keys lack ipAddress would pass
even if the migration had never run. Removed, with a note pointing at the
information_schema assertion that is the real guarantee.
@Flatts3000
Flatts3000 merged commit 95b6018 into main Aug 30, 2026
12 checks passed
@Flatts3000
Flatts3000 deleted the fix-70-drop-audit-ip-columns branch August 30, 2026 18:18
Flatts3000 added a commit that referenced this pull request Aug 30, 2026
…76)

* Close the same access-log leak in the config that ships in the image

`frontend/nginx.conf` had no `access_log` directive, so it inherited nginx's stock format - which ends with `$http_user_agent` and `$http_x_forwarded_for`. The root `docker-compose.yml` runs the frontend image with **no bind mount**, so that config is the one actually serving there, and every page load recorded who was asking.

CLAUDE.md rules that out in as many words: no tracking of who browses the public directory, no IP logging on anonymous routes.

This is the same drift the `/deck` header block guards against, and the comment says so: production bind-mounts `deploy/nginx.prod.conf` over this file, so this copy never serves a real visitor - but if the two disagree, the protection disappears the moment that mount is dropped.

Verified the same way as #75, by request rather than by reading. `GET /deck/` with `X-Forwarded-For: 203.0.113.55` and a distinctive user agent:

```
[30/Aug/2026:18:22:14 +0000] "GET /deck/ HTTP/1.1" 200 1147551 0.000
```

Zero identifying strings in the log, against two before the change.

* Scope the privacy comment to the access log

The comment claimed the log carries nothing identifying, which is true of the
access log and not of the error log beside it. Verified: an upstream refusing a
connection writes 'client: 172.17.0.1' on every error-level event.

Production is largely insulated - nginx only ever sees Caddy's container address
there - but the root docker-compose.yml publishes the frontend directly on 3001,
so client: is the real peer for anyone running the stack locally.

Both configs now say what the claim covers, and #77 tracks the error log and the
fact that neither compose file rotates anything.
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.

audit_log retains organizer IP and user agent indefinitely, mapping email to group to IP

1 participant