Skip to content

fix(affiliates): authenticate forwarded client IPs - #781

Merged
unjica merged 2 commits into
developfrom
fix/affiliate-client-ip-secret
Oct 12, 2026
Merged

unjica merged 2 commits into
developfrom
fix/affiliate-client-ip-secret

Conversation

@unjica

@unjica unjica commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

Affiliate application callers could spoof x-tt-client-ip to bypass the per-IP limit. The API now accepts a valid forwarded IP only when x-tt-client-ip-secret matches the non-empty AFFILIATE_CLIENT_IP_FORWARD_SECRET using equal-length buffers and timingSafeEqual; otherwise it uses request.ip.

The dashboard server action sends both headers using the runtime secret. Both services redact the credential from Sentry events. Includes API regression tests, dashboard action tests, updated integration fixtures, env examples, deployment instructions, and an Unreleased changelog entry.

Validation:

  • API: 137 test files passed, 1,114 tests passed; 20 files / 163 database-gated tests skipped.
  • Dashboard: 56 test files / 302 tests passed.
  • API + dashboard ESLint passed with zero warnings.
  • API and dashboard production builds passed.
  • Full tsc --noEmit attempted for both apps: 106 API and six dashboard errors, exactly identical to checks on origin/develop. No new type errors.
  • Final targeted API check: 26 tests passed, 15 database-gated tests skipped.
  • Full diff reviewed; git diff --check passed.

Deployment requires the same random non-empty runtime secret on API and dashboard. Missing or mismatched configuration safely falls back to request IP, so dashboard applicants share its connection limit.

No merge, deployment, publication, production-data changes, or changes to MCP/cron/Besedolov.

unjica and others added 2 commits October 12, 2026 11:53
Require a non-empty shared server-side secret and an equal-length timing-safe
comparison before using forwarded visitor IPs for affiliate application limits.
Send credentials from the dashboard action, redact them from error reporting,
and document runtime configuration with regression coverage.
@unjica
unjica merged commit bb0d8a4 into develop Oct 12, 2026
7 checks passed
@unjica unjica mentioned this pull request Oct 12, 2026
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