Skip to content

Security hardening, review fixes and README screenshot - #3

Merged
Akshayab merged 3 commits into
developfrom
security-hardening
Nov 17, 2026
Merged

Akshayab merged 3 commits into
developfrom
security-hardening

Conversation

@Akshayab

@Akshayab Akshayab commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

Hardens the server against denial-of-service inputs, credential misuse, alert-recipient injection, webhook abuse and redaction gaps.

  • Denial of service: login, setup and invite emails are validated in linear time. DogStatsD lines are parsed without a regular expression, and a header or path API key is checked before the body. Tag-filter globs use a linear matcher with at most 20 wildcards. Metric intervals must be positive and are widened to at most 10,000 buckets. Private-key redaction is linear, and tags and names are bounded before redaction.
  • Process-wide state: sample data passes the time explicitly instead of replacing Date.now, and only one start per organization runs at a time.
  • Credentials: the public API accepts only an API key in DD-API-KEY, not an application key. Sessions are read only from the signed cookie, and every state-changing cookie request is origin-checked.
  • Monitors and webhooks: alert recipients come from the monitor's own template, so tag values inserted into the message cannot add channels. Each delivery has a 15 s total time limit. Each organization's monitors run independently, and retries run in parallel. IPv4 addresses inside IPv6 forms (mapped, compatible, NAT64, 6to4) and Teredo, site-local and other special ranges are refused. Connection and framing headers (Host, Transfer-Encoding and similar) cannot be set.
  • Redaction: every value under a secret-named key is masked, including arrays and numbers. Service and span names (which become trace metric names), short Basic credentials and separated card numbers are redacted.
  • HTTP: X-Frame-Options: DENY and frame-ancestors 'none'; PUBLIC_URL is required when NODE_ENV=production (Docker Compose already sets it); API keys in logged URLs are hidden regardless of case; logout returnTo accepts same-origin paths only.

Also included (merged in from #4 and #2):

  • Review fixes: lost or duplicated telemetry after storage failures, Datadog Agent sketches, monitor no-data and grouping gaps, formula and percentile values, dashboard overwrites, live tail, the Node exporter crash on a reset response, Flask streaming spans and graceful shutdown. Details are in Fix data loss, wrong values and monitor gaps #4.
  • The README screenshot recaptured with the UI's sans-serif font.

How it was tested

  • pnpm run format:check, typechecks and unit tests pass (49 tests; 12 new, each using the exact problem input and checking that normal input behaves as before)
  • scripts/e2e.sh passes (for intake, query or storage changes): on PostgreSQL and ClickHouse
  • Docs and the configuration reference are updated (for new settings or behavior): PUBLIC_URL requirement

Also checked on a running server: log search, facets, histogram, the v2 logs API and a log monitor, and the new response headers.

Final checks on the combined branch:

  • Browser pass on a running server: a precision-0 widget shows 10 (was 1); switching dashboards through global search loads the new dashboard, and saving it leaves the other one unchanged; live tail shows all 250 logs of a same-timestamp burst and drops old rows when the query changes.
  • Datadog Agent 7.85.4 live: 100 DogStatsD distribution values (one 0, ninety-nine 100) sent through the agent now report count 100, sum 9900, average 99, p50/p95/p99 100, min 0, max 100 (before: count 2, average 50, p95 95).

~ written by ⠕ Replit

- Login, setup and invite emails are validated without a backtracking regex; DogStatsD
  lines are parsed without one, and a header or path API key is checked first.
- Tag-filter globs use a linear matcher (at most 20 wildcards); metric intervals must be
  positive and are widened to at most 10,000 buckets.
- Sample data no longer replaces Date.now; one start per organization at a time.
- The public API accepts only an API key in DD-API-KEY; session ids are accepted only
  from the signed cookie, and every cookie request that changes state is origin-checked.
- Monitor recipients come from the monitor's template, not from inserted tag values.
  Webhook deliveries have a 15 s total limit, and each organization's monitors run
  independently; notification retries run in parallel.
- Private-key redaction is linear; tags and names are bounded before redaction. All
  values under secret-named keys are masked; service and span names, short Basic
  credentials and separated card numbers are redacted.
- Webhook filter: IPv4 addresses inside IPv6 forms (mapped, compatible, NAT64, 6to4) and
  Teredo, site-local and other special ranges are refused. Connection and framing
  headers cannot be set on webhooks.
- Anti-framing headers; PUBLIC_URL is required in production; API keys in log URLs are
  hidden regardless of case; logout returnTo accepts same-origin paths only.

Assisted-by: Replit
Intake: cumulative OTLP references are applied only after the data is stored; stream
keys include all resource, scope and point attributes; late samples are ignored;
histograms are subtracted by matching bucket layout; negative exponential buckets
are kept; disk usage keeps its device tag. ClickHouse insert errors return 503;
multi-chunk PostgreSQL writes are one transaction; series metadata is marked written
only after success. Datadog Agent sketches keep their bins as weighted points.

Monitors: groups that stop reporting go to No Data when notify_no_data is set; the
no-data timer starts at the newest data point; evaluation_delay is applied; updates
are validated as merged (no empty queries) and keep priority; log env and span group
fields work; percentile(N), change and pct_change are computed; state is saved with a
compare-and-set so one process announces each transition.

Queries: formulas combine only matching groups and share one bucket size; data is
selected from the exact start time; numeric filters ignore text values; facets and
charts find flat attribute keys; totals and timeseries are computed separately;
percentiles use the same interpolation on PostgreSQL and ClickHouse; the APM
backfill is limited by span id; query_index follows the source formula.

API and UI: dashboard updates lock the row and validate structure; list routes page
when asked; the dashboard page reloads when its id changes; precision-0 numbers keep
their zeros; live tail pages with the cursor and cancels stale requests.

SDKs and server: the Node exporter treats a reset response as a retryable failure;
Flask spans end when the response body is finished; SIGTERM drains requests, flushes
rollups and closes the database before exit. Errors after monitor create and update
are logged.

Assisted-by: Replit
@Akshayab Akshayab mentioned this pull request Nov 17, 2026
3 tasks done
Assisted-by: Replit
@Akshayab Akshayab changed the title Security hardening Security hardening, review fixes and README screenshot Nov 17, 2026

@samuelreplit samuelreplit left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Akshayab
Akshayab merged commit eb8208a into develop Nov 17, 2026
13 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.

3 participants