{"uuid": "957e4287-2b66-4d01-a97a-9c9478f0bd26", "vulnerability_lookup_origin": "1a89b78e-f703-45f3-bb86-59eb712668bd", "author": "9f56dd64-161d-43a6-b9c3-555944290a09", "vulnerability": "CVE-2025-59528", "type": "seen", "source": "https://gist.github.com/OurTeamSpace/5a5c7de87558041e64ed8bc43fb2c20f", "content": "# Research: Iran-proof server + sanctions-bypass architecture (Issue #3)\n\nDate: 2026-10-02 | Branch: `research/iran-server` | Scope: single-server-first spec for Morph Mag agentic pipeline\n\n## TL;DR recommendation\n\n- **1\u00d7 VPS first, not multi-server.** Start: **4 vCPU / 8 GB RAM / 100\u2013160 GB NVMe, ~\u20ac6\u201315/mo**, in **Frankfurt/Amsterdam (primary) or Istanbul (lowest latency to Iran)**. Scale vertically to 16 GB before ever adding a second box.\n- **Host: Moldova/offshore provider with crypto + no US-KYC friction** \u2014 shortlist **AlexHost (Moldova, since 2008)** or **PQ.Hosting / THE.Hosting (Moldova, since 2019)**. Avoid Hetzner/US hosts as the *account holder* path for an Iran-linked team.\n- **OS: Ubuntu 24.04 LTS**. Stack: **Docker Engine + Docker Compose, Caddy (reverse proxy + auto-HTTPS), Coolify (ops UI), n8n (queue mode: main + worker + Postgres 16 + Redis 7), Beszel + Uptime Kuma (monitoring), MinIO (S3 file store), Qdrant/pgvector (embeddings, only when RAG lands)**.\n- **Sanctions bypass is two-sided:** (a) Iran DPI blocks/fingerprints VPNs + throttles foreign IPs \u2192 need **VLESS-Reality / Hysteria2 / TUIC-v5 on port 443** with clean exit; (b) US providers (OpenAI/Anthropic/Google) block Iranian IPs/accounts per OFAC \u2192 **server calls APIs from non-sanctioned exit IP + non-Iranian account/payment; Iranian editors never touch upstream directly** \u2014 they use the VPS-hosted dashboard/API gateway.\n- **Dashboards beyond n8n:** keep n8n for automation, add **Coolify (deploy dashboard), Beszel (docker/host metrics), Uptime Kuma (uptime + public status), Flowise or Langflow (LLM/RAG visual builder), Open WebUI (model chat playground)**. Grafana only later.\n- **If restrictions lift:** keep same Compose files, split to 2\u20133 nodes (apps / workers+GPU / data), move secrets to managed vault, add managed DB/object storage, swap proxy gateway for direct API keys + billing.\n\n## 1. Problem framing: two block directions\n\n1. **Iran \u2192 world (filternet + DPI).** Deep packet inspection fingerprints OpenVPN/WireGuard/L2TP and throttles; only traffic mimicking real HTTPS (VLESS-Reality, Hysteria2 over QUIC, TUIC v5, Shadowsocks-2022 + WS/TLS plugin) reliably passes in 2026. Port 443 + valid TLS fingerprint + CDN masking are load-bearing.\n2. **World \u2192 Iran (OFAC + vendor ToS).** OpenAI blocks Russia/Iran/Cuba/Syria/NK; Anthropic bars Iran/Syria/Cuba/NK/Russia (~158 supported regions only) and **checks source IP on every request** (not just login); Google binds account country. Iranian phone numbers/cards fail signup/billing. Separately, US hosting ToS (e.g. Database Mart: \"cannot provide hosting services to customers in Iran, North Korea, Sudan, Cuba, Venezuela, Russia\") shows why a US account/host is fragile.\n3. **Consequence for architecture:** the VPS must live in a *supported* country, owned via a *non-sanctioned identity/payment*, and Iranian clients reach *the VPS* (via obfuscated tunnel), while *the VPS* reaches *model APIs*. Never expose Iranian IPs to upstream.\n\nExisting Iran pattern proving this works: gateways like `1xai.ir` present one OpenAI-compatible base URL (`api.openai.com` \u2192 `1xai.ir/v1`), route by model name to OpenAI/Anthropic/Gemini, bill in Toman via Zarinpal, and hide client IP/UA from upstream. We self-host the same pattern (LiteLLM / Open WebUI + API gateway) rather than depending on a third-party reseller.\n\n## 2. Hosting company decision\n\n### Avoid as primary (documented risk)\n\n- **Hetzner (DE/FI):** cheap (CX23 ~\u20ac5.49/mo ex-VAT post-June-2026: 2 shared vCPU/4 GB/40 GB/20 TB) but (a) strict KYC/verification, (b) ~10% of German Hetzner IPs reported blocked by GCP/AWS/Azure because prior tenants used them for Iran sanction-busting traffic redirection (Cloud66 report, 2024-06-03), causing collateral IP-reputation damage, (c) RU/IR-targeted throttling waves observed mid-2025 on Hetzner/OVH/Cloudflare ranges. Good hardware, wrong risk profile for this ticket.\n- **Any US-only host / US hyperscaler account:** ToS explicitly refuses sanctioned-country customers; account + payment must be non-Iranian and stay that way.\n\n### Shortlist (sanctions-neutral + crypto)\n\n| Provider | Base / since | Why it fits | Caveats | Entry price |\n|---|---|---|---|---|\n| **AlexHost** | Moldova / 2008, DCs in MD + NL/SE/BG/FR/CH/UK/RO/US | Offshore, DMCA-ignore, **anonymous-friendly / no-KYC positioning**, 50+ cryptos via Cryptomus/CoinGate (BTC, USDT, XMR, etc.), KVM + NVMe, own ISO support | Cheapest tiers are E5-class shared cores; Ryzen tiers cost more; verify current plan before order | ~\u20ac6/mo Linux 1-core/1.5 GB/10 GB NVMe; Ryzen 2-core/30 GB ~\u20ac15/mo |\n| **PQ.Hosting (THE.Hosting)** | Moldova / 2019, 37\u201342 countries, 150k+ clients | **Crypto accepted**, NVMe KVM, 1 Gbps unlimited on many tiers, Linux-literate support, wide location choice (DE/NL/TR-adjacent) | No formal uptime SLA (~99.99% observed); dated panel, strict refund/KYC complaints \u2014 start on monthly, test first | ~\u20ac6/mo Aluminium (1 vCore/1 GB/25 GB NVMe) |\n| Fallbacks: Zomro (NL/DE, from \u20ac5.95), EDIS Global (Equinix AM6 Amsterdam, from \u20ac4.99), VerticHost (25+ DCs) | EU | Useful if AlexHost/PQ capacity is constrained; re-check crypto + KYC at order time | Not specifically offshore-anonymous | varies |\n\n**Location order:** **Frankfurt or Amsterdam first** (best peering, model-API latency, clean-IP pools; MonoVM 2026 latency map shows Frankfurt 0\u20132 ms to Exness-Frankfurt, Amsterdam 1\u20132 ms to FXTM-Amsterdam as proxies for EU interconnect quality), **Istanbul second** if editor-to-server latency dominates (\u224833\u201336 ms Frankfurt\u2192Istanbul reference; Istanbul is geographically closest to Iran). Avoid US/Asia exits for model calls (higher latency, stricter scrutiny). Order monthly, snapshot before any upgrade, test IP reputation on arrival (see \u00a77).\n\n## 3. Single-server-first spec\n\nRule from Coolify/multi-app sizing guides: platform overhead ~0.75\u20131.2 GB (Coolify + Traefik/Caddy + Docker + OS) before workloads; n8n idle ~150 MB, production ~512 MB; Postgres/Redis/MinIO each 128 MB\u20131 GB depending on load. Queue-mode n8n template caps total ~7.3 GB across 4 containers, so **4 GB RAM without swap cannot run the full template + anything else**.\n\n| Tier | Spec | Fits | Price band |\n|---|---|---|---|\n| **Start (recommended)** | **4 vCPU / 8 GB RAM / 100\u2013160 GB NVMe / 1 IPv4 + IPv6, \u226520 TB or unlimited, 1 Gbps** | Coolify + Caddy + n8n queue-mode + Postgres + Redis + Beszel + Uptime Kuma + MinIO + 1 Next.js/Ghost site | ~\u20ac8\u201320/mo offshore |\n| Floor (only if cash-constrained) | 2 vCPU / 4 GB RAM + 4 GB swap / 80 GB NVMe | n8n queue-mode alone, no co-located Next.js/SSR; swap is mandatory, expect pressure on image-heavy workflows | ~\u20ac6/mo |\n| Next vertical step | 6\u20138 vCPU / 16 GB / 200\u2013400 GB NVMe | Adds Flowise/Langflow + Qdrant + staging | ~\u20ac20\u201340/mo |\n\nDisk floor: 40 GB small stack / 80 GB medium / 160 GB+ full production (per MassiveGRID 2026 sizing). Always enable provider snapshots/backups + off-box S3 copy.\n\n**Single vs multi verdict: single.** Multi-server (control-plane + app + data nodes) only pays off past ~32 GB / 8\u201316 vCPU, or when staging + prod + GPU inference must be isolated. Single box = one firewall, one backup, same-LAN latency between app\u2194DB, lowest ops cost for Phase 1 (content pipeline per CONTEXT.md: research + content + archiving + distribution). Coolify natively supports promoting to multi-server later without re-platforming.\n\n## 4. OS + software stack\n\n- **OS: Ubuntu 24.04 LTS (Noble).** Required by Coolify install docs (LTS 20.04/22.04/24.04; non-LTS needs manual install), widest Docker/Caddy support, cloud images current as of Sept 2026. Use `amd64`, ext4 or ZFS, unattended-upgrades on.\n- **Container runtime: Docker Engine (official APT repo, not Snap) + Docker Compose v2.** Coolify installs/manages this; Snap-Docker is explicitly unsupported.\n- **Reverse proxy + TLS: Caddy 2 (caddy:2-alpine container or Ubuntu `caddy` package 2.6.2).** Automatic Let's Encrypt/ZeroSSL, HTTP/1.1+2 (+experimental 3), simple Caddyfile. Alternative Traefik comes inside Coolify \u2014 either is fine, but standardize on one (Caddy recommended for readability).\n- **Ops UI: Coolify (needs 2 cores / 2 GB / 30 GB minimum; comfortable at the 8 GB tier).** One-click n8n/Postgres/Redis templates, Git deploy for site, env management, built-in reverse proxy. Debian/Ubuntu/RedHat/SUSE/Arch/Alpine supported.\n- **Automation: n8n in queue mode** \u2014 `n8n main + n8n-worker + postgres:16-alpine + redis:7-alpine`, `EXECUTIONS_MODE=queue`, `EXECUTIONS_DATA_PRUNE` 14-day/10k cap, memory caps (main 2.5\u20133 GB, worker 3.5\u20134 GB, pg 700 MB, redis 500\u2013800 MB) + `NODE_OPTIONS --max-old-space-size` matched. SQLite only for throwaway tests.\n- **File store: MinIO (S3-compatible) or Coolify volumes + S3 backup.** System of record stays Markdown/XML files per CONTEXT.md \"Local file store\" \u2014 MinIO is the S3 skin over that, not a database mandate.\n- **Data: Postgres 16 for n8n/Coolify metadata; Qdrant or pgvector only when RAG ships.** No DB in Phase 1 unless research proves otherwise (per CONTEXT.md) \u2014 Postgres here is infra metadata, not content store.\n- **Tunnels: X-UI / Marzban + VLESS-Reality (port 443, Chrome/Firefox JA3/h2 fingerprint, real SNI front like microsoft.com/cdn.cloudflare.com), plus Hysteria2 fallback.** sing-box clients for editors; route `openai.com/chatgpt.com/oaistatic.com`, `claude.ai/anthropic.com`, model API hosts through tunnel; keep one stable exit country per session (critical for Claude per-request IP checks).\n- **Model gateway (self-hosted 1xai-pattern): LiteLLM or OpenRouter-style proxy on the VPS** \u2014 one key + one base URL for editors/agents, server-side fan-out to OpenAI/Anthropic/Gemini/DeepSeek with Toman/internal accounting. SDK-compatible (`base_url=https://llm./v1`).\n- **Secrets: env files + Coolify encrypted envs now; Vault/SOPS later.** `N8N_ENCRYPTION_KEY`, API keys, tunnel UUIDs never in git.\n- **Firewall: UFW 22/80/443 only; close 8000/3000-series dashboards to Tailscale/tunnel; SSH key-only, root-password off; automatic security updates.**\n\n## 5. Visual dashboards beyond n8n (recommended combo)\n\nn8n stays (400+ integrations, best self-host Docker story) but it is **automation**, not monitoring or LLM-playground. Add:\n\n| Need | Pick | Why / cost |\n|---|---|---|\n| Deploy + service dashboard | **Coolify** | Already required; replaces hand-rolled Compose/Traefik UI |\n| Host + Docker metrics | **Beszel** (hub + agent, MIT, PocketBase-based) | Lighter than Netdata/Grafana; per-container CPU/mem/net history, alerts, S3 backups; ~tens of MB |\n| Uptime + status page | **Uptime Kuma** (MIT, louislam) | HTTP/TCP/DNS/Ping + 90+ notifiers (Telegram/Discord/Slack), public status page; SQLite default; ~60\u2013128 MB |\n| LLM/RAG visual builder | **Flowise** (Apache-2.0, Node/LangChain.js, AgentFlow V2 + human-in-the-loop) for fast chatbot/RAG demos; or **Langflow** (MIT, Python/FastAPI, MCP-server export) if team is Python-first | Both MIT/Apache \u2014 embeddable commercially, unlike n8n Sustainable Use License which needs a commercial agreement for SaaS resale / external-user-triggered workflows |\n| Chat playground | **Open WebUI + Ollama** | Humanize/translate editors test prompts without touching vendor consoles |\n| Later / optional | Grafana + Prometheus, Langfuse/LangSmith (LLM tracing), Plausible (analytics), Gitea (git), Sim Studio (Apache-2.0 visual agent builder, K8s-ready) | Only when Phase 2 (growth/ops) demands it |\n\nSecurity note: every visual builder is a remote-code-execution surface by design \u2014 Langflow CVE-2025-3248 (CVSS 9.8, Flodrix botnet), Flowise CVE-2025-59528 (CVSS 10.0) + second import-RCE. Keep all builders behind login + private network, never public-anon.\n\n## 6. Sanctions-bypass runbook (minimal, Phase 1)\n\n1. Provision offshore VPS (monthly, Frankfurt/Amsterdam) with crypto; harden Ubuntu 24.04; install Caddy + Docker + Coolify.\n2. Deploy n8n queue-mode + Postgres + Redis via Coolify template with memory caps + pruning.\n3. Deploy VLESS-Reality + Hysteria2 on 443; issue per-editor configs (sing-box); pin one exit country; verify `openai.com/claude.ai` reachability from Iran-side client.\n4. Create non-Iranian provider accounts + foreign billing **once, outside Iran**, store keys only on VPS; all model traffic originates from VPS exit IP. Enforce: editors use `https://llm./v1` gateway, never vendor keys.\n5. Keep Iranian client IPs hidden from upstream (gateway strips IP/cookies/UA \u2014 same privacy claim as 1xai.ir).\n6. Backups: provider snapshot + nightly Postgres dump + MinIO mirror to second S3/off-box.\n7. IP hygiene: on delivery, check ASN (avoid AS16509/AS8075/AS24940/AS16276/AS14061-flagged ranges for model calls), MaxMind/IPQS score, and a test `GET /v1/models` via gateway; rotate/rebuild if CAPTCHA-looped or 403 on clean account.\n\n## 7. If restrictions lift (next steps)\n\n- Keep Compose files portable \u2014 lift means **billing/identity simplification, not re-architecture**: switch gateway to direct vendor keys, add per-seat billing, drop reseller margin.\n- Split vertically first (8 GB \u2192 16 GB), then horizontally: Node-1 control-plane + dashboards, Node-2 app/workers, Node-3 data (Postgres/MINIO/Qdrant on dedicated IOPS). Coolify multi-server mode supports this.\n- Adopt managed Postgres/object storage + CDN (Cloudflare) for the public magazine site; keep origin offshore until traffic analysis says otherwise.\n- Add SSO/SAML, audit logs, Kubernetes/queue autoscale (n8n enterprise features), SOC2-minded logging (Langfuse + Grafana) \u2014 only then.\n- Re-evaluate Hetzner/OVH/US clouds on price once KYC/ToS friction is gone; current offshore box becomes staging/fallback.\n\n## Sources (primary-first)\n\n- Coolify self-host requirements + supported OS (2 cores/2 GB/10\u201330 GB; Ubuntu LTS): `coolify.io/docs/start-with-self-hosted`\n- n8n sizing (idle ~100 MB, workflows drive RAM; 320 MB\u20132 GB range): `docs.n8n.io/deploy/host-n8n/.../prerequisites`\n- Production n8n queue-mode memory budgets (4 GB + swap floor, 8 GB comfortable; container/heap caps): `nextgrowth.ai/n8n-queue-mode-coolify/` (2026-01-02)\n- Coolify single-VPS install + Hetzner CX23 spec drift (2 vCPU/4 GB/40 GB/20 TB; \u20ac5.49 ex-VAT post-2026-06-15): `kirako.ai/en/blog/self-hosted-stack-hetzner-coolify-n8n` (2026-02-11)\n- Multi-app RAM math (overhead ~1 GB; Next.js/Postgres/Redis/n8n table; 4 GB min / 8 GB comfortable): `massivegrid.com/blog/coolify-resource-planning-multiple-apps/` (2026-02-26)\n- Hetzner sanction-busting IP collateral (~10% DE IPs blocked by GCP/AWS/Azure): `blog.cloud66.com/hetzner-connectivity-issues-due-to-sanction-busting-activities` (2024-06-03)\n- US host refusal for sanctioned countries (IR/KP/SD/CU/VE/RU): `databasemart.com/faq/general-questions`\n- OFAC Iran sanctions program: `state.gov/iran-sanctions`; Federal Register OFAC actions 2025-2026\n- RKN throttling wave on Hetzner/OVH/Cloudflare (June\u2013July 2025, 16 KB stall): `pxsl.ru/blog/...hetzner-i-ovh...`\n- OpenAI geo/OFAC blocks + proxy guidance: `ltesocks.io/blog/proxies-and-openai...` (2026-02-10); AnonymFlow VPN/ChatGPT 2026 (ASN + reputation + behavior layers)\n- Claude per-request IP checks + Iran unsupported (~158 regions): `univista.me/guide/claude-access-iran/` (2026-07-06); ChatGPT Iran shared-IP risk: `univista.me/guide/chatgpt-access-iran/` (2026-06-09); Fexyn Stealth/VLESS guidance for IR/RU/CN\n- Iran DPI + VLESS-Reality/Hysteria2/TUIC-v5/Shadowsocks-2022 guidance: `valebyte.com/en/blog/vps-for-bypassing-blocks-in-iran-what-works-in-2026/` (2026-07-04)\n- 1xai.ir gateway pattern (one key/base-URL, Toman/Zarinpal, IP hidden): `1xai.ir/` + `pypi.org/project/1xai-sdk/`\n- AlexHost offshore/crypto/no-KYC positioning: `btc-vps.com/bitcoin-vps/alexhost`, `websiteplanet.com/web-hosting/alexhost`, `hostservio.com/review/alexhost-user-review`\n- PQ.Hosting profile (Moldova 2019, 37+ countries, ~\u20ac6/mo, crypto, no SLA): `top30forexbrokers.com/product/pq-hosting-review` (2026-05-15)\n- EU latency references: `monovm.com/forex-vps/` (Geekbench + broker latency map, re-tested 2026-07-14); EDIS Amsterdam Equinix AM6 looking glass\n- n8n vs Flowise vs Langflow roles/licenses (n8n Sustainable Use fair-code; Flowise Apache-2.0; Langflow MIT; Flowise\u2192Workday 2025-08; Langflow/DataStax\u2192IBM May 2025; Langflow Cloud shutdown 2026-04-09): `blckalpaca.at/.../langflow-vs-flowise-vs-n8n` (2026-06-09), `huggingface.co/blog/daya-shankar/n8n-vs-flowise-vs-langflow-enterprises` (2026-04-27), `dreaming.press/posts/2026-06-21...`, `madappgang.com/blog/...` (2026-05-17), `altaitools.com/n8n-vs-flowise-vs-langflow/` (2026-08-13), `meetrix.io/blogs/flowise-vs-langflow-vs-n8n/` (2026-07-22)\n- Beszel (MIT, hub+agent, Docker stats, alerts): `beszel.dev/` + `github.com/henrygd/beszel`; Uptime Kuma (HTTP/TCP/DNS, 90+ notifiers, status pages): `github.com/louislam/uptime-kuma`, `uptimekuma.co/`; Beszel-vs-Kuma complementary roles: `instapods.com/apps/beszel/vs/uptime-kuma`\n- Ubuntu 24.04 LTS Noble + Caddy 2.6.2 packaging: `cloud-images.ubuntu.com/.../noble/release`, `packages.ubuntu.com/noble/caddy`, `launchpad.net/ubuntu/noble/+source/caddy`\n", "creation_timestamp": "2026-10-02T19:16:05.000000Z"}