Screening service: limits, timeouts and region matching #16

Merged
Taskuler-bot merged 3 commits from fix/screening-service-limits into main 2026-11-30 02:01:43 +00:00
Member

Follow-up to the Taskuler Security review of df205df (H2, M1, M2, M4, L1, L2) and Legal's provider-terms item (R6). Built on web #14: it targets #14's branch, so merge #14 first and this PR then retargets to main. No deploy.

H2 (service reachable from outside): already fixed in #14. The service listens on 127.0.0.1 by default (RAMPS_HOST), checked with ss -ltn (127.0.0.1 only). This PR adds the 8 KB request cap inside the service itself as well.

What changes, in plain words:

  • Quota protection (M1):
    • One IPv6 network (/64) shares one limit, so rotating addresses doesn't get around it.
    • One wallet is limited across all IPs (SCREEN_WALLET_LIMIT, default 20 per 10 minutes).
    • Location/VPN lookups stop at 900 a day (IPAPI_DAILY_CAP), below ipapi.is's free 1,000. Chainalysis has its own daily cap (CHAINALYSIS_DAILY_CAP, default 5,000).
    • Over a cap, posting, bidding and withdrawing pause until 00:00 UTC (6 PM CT). The server logs it once.
    • The limit tables can't grow without bound.
  • Timeouts (M2):
    • Every provider call gives up after 5 seconds (PROVIDER_TIMEOUT_MS) and counts as "unavailable", so the action stays paused.
    • A failed Tor-list download waits 5 minutes before retrying.
    • The browser gives up after 10 seconds and shows "Screening is unavailable".
  • Occupied regions (M4):
    • The Crimea, Sevastopol, Donetsk and Luhansk block now matches whether the provider says Ukraine or Russia.
    • It also matches common spellings (Krym, Sebastopol, Lugansk, Luhans'k, Donets'k…).
    • Live ipapi.is lookups today reported Sevastopol as "Sebastopol City", which the old match missed.
    • It also matches Ukrainian and Russian Cyrillic names, the ISO region codes (UA-43, UA-40, UA-14, UA-09, RU-CR, RU-SEV), "DNR"/"LNR", and the larger towns, in case only a city comes back. These areas are under EO 13685 (Crimea) and EO 14065 (DNR/LNR).
    • This is not a complete block. It only works when the provider returns a region or town for the visitor. Many Crimean provider addresses come back as Moscow, St Petersburg or Krasnodar, and then there's nothing to match. Some lookups return no region at all. What the provider returns for Donetsk and Luhansk is unverified. The code comment above REGION_ALIASES lists these gaps.
  • Location lookups per network (re-review N2):
    • Lookups are cached and shared per IPv6 /64 (IPv4: per address), so many addresses in one /64 cost one lookup. Concurrent requests share one call.
    • Each /64 or IPv4 address gets 20 new lookups per UTC day (IPAPI_NETWORK_DAILY_CAP). Past that, that network's checks are "unavailable" until 00:00 UTC (6 PM CT).
    • Daily counts (global caps and per-network allowances) are saved to daily-counters.json in systemd's StateDirectory=taskuler-app (STATE_DIRECTORY), so a restart doesn't reset them. With no state directory, they're kept in memory only.
  • Provider terms (Legal R6):
    • Outside mock previews, the screening answer is only pass/blocked and the reason. Provider details stay on the server.
    • Chainalysis results are no longer cached.
    • The ipapi.is key now goes in a POST body instead of the URL.
  • Robustness (L1, L2):
    • A request error returns 500 instead of stopping the service.
    • Bodies over 8 KB get 413.
    • When the server is told to trust a client-IP header, a missing or invalid one gets 400, instead of every visitor sharing the server's address.
    • Generic check details.

Checked:

  • npm test 167/167, both tsc passes and vite build pass.
  • A manual run of the service: 413 on a 9 KB body; the live-mode screen returns {ok:false, reason:'unavailable', checks:[]} with no keys; it listens on 127.0.0.1 only.
Follow-up to the Taskuler Security review of `df205df` (H2, M1, M2, M4, L1, L2) and Legal's provider-terms item (R6). **Built on web #14:** it targets #14's branch, so merge #14 first and this PR then retargets to `main`. No deploy. **H2 (service reachable from outside):** already fixed in #14. The service listens on 127.0.0.1 by default (`RAMPS_HOST`), checked with `ss -ltn` (127.0.0.1 only). This PR adds the 8 KB request cap inside the service itself as well. What changes, in plain words: - **Quota protection (M1):** - One IPv6 network (/64) shares one limit, so rotating addresses doesn't get around it. - One wallet is limited across all IPs (`SCREEN_WALLET_LIMIT`, default 20 per 10 minutes). - Location/VPN lookups stop at **900 a day** (`IPAPI_DAILY_CAP`), below ipapi.is's free 1,000. Chainalysis has its own daily cap (`CHAINALYSIS_DAILY_CAP`, default 5,000). - Over a cap, posting, bidding and withdrawing pause until 00:00 UTC (6 PM CT). The server logs it once. - The limit tables can't grow without bound. - **Timeouts (M2):** - Every provider call gives up after 5 seconds (`PROVIDER_TIMEOUT_MS`) and counts as "unavailable", so the action stays paused. - A failed Tor-list download waits 5 minutes before retrying. - The browser gives up after 10 seconds and shows "Screening is unavailable". - **Occupied regions (M4):** - The Crimea, Sevastopol, Donetsk and Luhansk block now matches whether the provider says Ukraine or Russia. - It also matches common spellings (Krym, Sebastopol, Lugansk, Luhans'k, Donets'k…). - Live ipapi.is lookups today reported Sevastopol as "Sebastopol City", which the old match missed. - It also matches Ukrainian and Russian Cyrillic names, the ISO region codes (UA-43, UA-40, UA-14, UA-09, RU-CR, RU-SEV), "DNR"/"LNR", and the larger towns, in case only a city comes back. These areas are under EO 13685 (Crimea) and EO 14065 (DNR/LNR). - **This is not a complete block.** It only works when the provider returns a region or town for the visitor. Many Crimean provider addresses come back as Moscow, St Petersburg or Krasnodar, and then there's nothing to match. Some lookups return no region at all. What the provider returns for Donetsk and Luhansk is unverified. The code comment above `REGION_ALIASES` lists these gaps. - **Location lookups per network (re-review N2):** - Lookups are cached and shared per IPv6 /64 (IPv4: per address), so many addresses in one /64 cost one lookup. Concurrent requests share one call. - Each /64 or IPv4 address gets 20 new lookups per UTC day (`IPAPI_NETWORK_DAILY_CAP`). Past that, that network's checks are "unavailable" until 00:00 UTC (6 PM CT). - Daily counts (global caps and per-network allowances) are saved to `daily-counters.json` in systemd's `StateDirectory=taskuler-app` (`STATE_DIRECTORY`), so a restart doesn't reset them. With no state directory, they're kept in memory only. - **Provider terms (Legal R6):** - Outside mock previews, the screening answer is only pass/blocked and the reason. Provider details stay on the server. - Chainalysis results are no longer cached. - The ipapi.is key now goes in a POST body instead of the URL. - **Robustness (L1, L2):** - A request error returns 500 instead of stopping the service. - Bodies over 8 KB get 413. - When the server is told to trust a client-IP header, a missing or invalid one gets 400, instead of every visitor sharing the server's address. - Generic check details. Checked: - `npm test` 167/167, both `tsc` passes and `vite build` pass. - A manual run of the service: 413 on a 9 KB body; the live-mode screen returns `{ok:false, reason:'unavailable', checks:[]}` with no keys; it listens on 127.0.0.1 only.
- Rate limit keyed by IPv6 /64 (IPv4 per address); per-wallet limit (SCREEN_WALLET_LIMIT); hard-capped maps.
- Global daily caps on ipapi.is (900, below the 1,000/day free tier) and Chainalysis lookups; over the cap the check is unavailable (fail closed) and the server logs it once.
- 5 s timeout on every provider call (OFAC, Chainalysis, Tor list, ipapi.is); timeouts count as unavailable. Tor list retries back off 5 minutes. 10 s client timeout.
- ipapi.is key sent in a POST body instead of the URL.
- Occupied-region block matches UA or RU with common spellings (Crimea/Krym, Sevastopol/Sebastopol, Donetsk, Luhansk/Lugansk).
- Outside mock mode /screen returns only ok and reason; Chainalysis results are not cached.
- Node wrapper: 8 KB body cap (413), try/catch (500), and a configured client-IP header must be present and valid (400).
Crimea/Sevastopol (EO 13685) and Donetsk/Luhansk (EO 14065): Ukrainian- and Russian-side names,
Cyrillic, ISO 3166-2 codes and larger towns, matched for UA or RU. A code comment lists where the
provider returns no region for these areas, so the match can't block them.
Lookups are cached and deduplicated per ipKey (IPv6 /64, IPv4 address). Each network gets
IPAPI_NETWORK_DAILY_CAP new lookups per UTC day (default 20). Daily counters persist to
$STATE_DIRECTORY/daily-counters.json (systemd StateDirectory=), so a restart doesn't reset them.
george approved these changes 2026-11-30 01:56:07 +00:00
Taskuler-bot changed target branch from feat/support-contact-indexing to main 2026-11-30 02:01:41 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
taskuler/web!16
No description provided.