Skip to content

fix(analytics): bound and validate event timestamp, require object properties - #333

Merged
ety001 merged 1 commit into
nextfrom
fix/analytics-s7-timestamp-validation
Sep 7, 2026
Merged

ety001 merged 1 commit into
nextfrom
fix/analytics-s7-timestamp-validation

Conversation

@ety001

@ety001 ety001 commented Sep 7, 2026

Copy link
Copy Markdown
Member

Summary

Closes the S7 residual flagged by the 2026-09-04 remediation re-verification of the 2026-08-04 audit (#322 capped event and properties, but timestamp was missed):

  • timestamp had no validation at all — no type check, no length cap — and is written straight into the log line. Under the 100 req/min rate limit each IP could still push ~100 MB/min of arbitrary log content via {"event":"x","timestamp":"<huge string>"}. Now: must be a string, ≤ 32 chars (ISO-8601 max is 29), and parseable by Date.parse; otherwise 400.
  • Non-object properties slipped through — the existing checks only counted Object.keys() and JSON.stringify() bytes, so a short string/number payload passed and was logged as-is. Now: must be a plain object (non-null, non-array); otherwise 400.

Legitimate traffic is unaffected: the client (src/lib/analytics/index.ts) always sends new Date().toISOString() (24 chars) and an object (default {}).

Verification

  • 6 new regression tests in tests/unit/analytics-event-route.test.ts (oversized / non-string / unparseable timestamp rejected; valid ISO timestamp logged through; string and null properties rejected)
  • Full suite green: 73 files / 652 tests passed; tsc --noEmit clean; eslint 0 errors (6 pre-existing warnings in untouched files)

…operties

Closes the S7 residual from the 2026-08-04 audit re-verification:
`timestamp` reached the log line with no type/length validation, and
non-object `properties` slipped through the key-count/byte-size checks.
Adds a 32-char cap with Date.parse sanity for timestamps and a
plain-object check for properties, plus regression tests.
@ety001
ety001 merged commit 5bd67be into next Sep 7, 2026
2 of 3 checks passed
@ety001
ety001 deleted the fix/analytics-s7-timestamp-validation branch September 7, 2026 08:01
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