Skip to content

Security closes (SEC-1..5) + kill the last fake data on the server#7

Draft
aurph wants to merge 2 commits into
mainfrom
fix/security-closes
Draft

Security closes (SEC-1..5) + kill the last fake data on the server#7
aurph wants to merge 2 commits into
mainfrom
fix/security-closes

Conversation

@aurph

@aurph aurph commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Two long-standing audit items, both verified live before this PR.

1. The five security closes (cherry-pick of da97234 from stale PR #1)

  • SEC-1: GET /api/newsletter/preview now requires admin (was leaking subscriber count)
  • SEC-2: POST /api/social/generate now requires admin
  • SEC-3: /api/stack timeframe allowlisted to 1D/5D/1M, cache keyed on the normalized value (kills the ~200-Yahoo-call cache-miss amplification)
  • SEC-4: news scanners (which write JSON) no longer run from public GET /api/news; admin /api/admin/scan-news-now only. Reminder: the daily cron-job.org hit on scan-news-now keeps freshness automated.
  • SEC-5: datacenter names HTML-escaped before Leaflet divIcon interpolation
  • auth-boundary.test.ts covers every admin route

Cherry-pick applied cleanly onto current main (no conflicts). PR #1 can be closed once this merges.

2. Real data replaces the synthetic uranium scatter (audit M5)

The Stack's CCJ/CEG correlation card was Box-Muller noise tuned to target r values, regenerated per request. It now plots real trailing-year weekly closes: Sprott Physical Uranium Trust (SRUUF, physical U3O8 proxy; URA would be circular since it holds CCJ) vs CCJ, with Pearson r computed from the observed series for both CCJ and CEG. Pure math module server/correlation.ts (date-joined pairing, 7 tests), 6h cache, explicit empty state on Yahoo failure instead of fallback data.

First real readings: CCJ r 0.872 (fake claimed 0.82), CEG r -0.298 (fake claimed +0.65 - the utility does not track spot at all this year). Chart labels, tooltip, and methodology copy updated to say exactly what is plotted.

Also: reusePort now Linux-only (macOS dev fix), CLAUDE.md known-debt updated.

Verification

  • tsc clean, 76/76 tests, production build green
  • Booted locally and hit the live server: /api/stack returns 55 real weekly points; newsletter/preview and social/generate return 401 without key, 200 with; garbage timeframe coerces to 1D and serves from cache

After merge: redeploy on Replit to ship.

aurph added 2 commits July 15, 2026 10:39
- SEC-1: require admin on GET /api/newsletter/preview (was public, leaked
  the subscriber count). The internal call from /newsletter/send forwards
  the server's own admin key so sends keep working.
- SEC-2: require admin on POST /api/social/generate (was public).
- SEC-3: allowlist /api/stack timeframe to [1D,5D,1M] and key the cache on
  the normalized value, killing the ~200-Yahoo-call cache-miss amplification.
- SEC-4: stop running the backlog/uranium news scanners (which write JSON)
  from public GET /api/news; they now run only via authenticated
  /api/admin/scan-news-now. Wire that into cron to restore automation.
- SEC-5: HTML-escape datacenter names before Leaflet divIcon interpolation.
- TEST-1: add auth-boundary.test.ts (every admin route rejects missing key,
  correct key accepted, SEC-3 coercion). 33/33 tests pass.
The CCJ/CEG correlation card was the last fabricated data on the server:
Box-Muller noise tuned to target r values (0.82 / 0.65), regenerated per
request and presented as 52 weeks of observations (audit finding M5).

Now it plots real trailing-year weekly closes from Yahoo: Sprott Physical
Uranium Trust (SRUUF) as the spot proxy (holds physical U3O8; URA would be
circular, it holds CCJ) against CCJ, with Pearson r computed from the same
observed series for both CCJ and CEG. Math is a pure module
(server/correlation.ts, date-joined so a dropped OTC bar can't shift the
pairing, 7 tests). 6h cache; on Yahoo failure the card shows an explicit
empty state instead of fallback data, and r reads null, never a default.

First real readings: CCJ r 0.872, CEG r -0.298 - the fake data had CEG at
+0.65; reality says the utility does not track spot at all this year.

Also: reusePort now Linux-only in server/index.ts (macOS dev fix, known
issue), CLAUDE.md known-debt entries updated.
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