Sovereign Network API Client - QUIC Architecture Analysis
Date: December 5, 2025 Status: CRITICAL ARCHITECTURE ISSUE IDENTIFIED
The API client library CANNOT connect to the ZHTP backend as currently designed.
- Backend: QUIC/UDP (port 9334) - NO HTTP server
- Client: JavaScript fetch() → HTTP/TCP
- Result: Connection failure - incompatible protocols
Fix Required: Deploy HTTP-to-QUIC gateway OR implement native QUIC clients.
What You Think Happens:
┌─────────────────┐
│ API Client │
│ fetch('http:') │ ──────X──────> Backend rejects TCP
└─────────────────┘ (no TCP listener)
What Actually Exists:
Backend is UDP-only (QUIC protocol)
No HTTP server on any TCP port
HttpCompatibilityLayer only works with HTTP-over-QUIC (HTTP/3)
- JavaScript
fetch()uses TCP - cannot connect to UDP endpoints - ZHTP backend is QUIC/UDP only - port 9334, no TCP listener
- Default URL is wrong -
http://localhost:8000(wrong protocol + wrong port) - No browser support for QUIC - JavaScript has no native QUIC API
Backend (Rust):
// zhtp/src/unified_server.rs line 86-87
// QUIC is ONLY ENTRY POINT
quic_mesh: Arc<QuicMeshProtocol>,
quic_handler: Arc<QuicHandler>,
// Line 16: TCP/UDP no longer used - QUIC-only architectureClient (TypeScript):
// src/core/zhtp-api-core.ts line 28
this.fetchAdapter = fetchAdapter || ((url, options) => fetch(url, options));
// ❌ Standard fetch() cannot connect to UDP| Issue | Impact | Severity |
|---|---|---|
| P0-1: fetch() incompatible with QUIC | Library is non-functional | CRITICAL |
| P0-2: Wrong default URL/port | All connections fail | CRITICAL |
| Issue | Impact | Severity |
|---|---|---|
| P1-1: Tokens in localStorage | XSS can steal session tokens | HIGH |
| P1-2: Credentials in request body | Logging/XSS exposure | HIGH |
| P1-6: QUIC connection hijacking | Session takeover via IP spoofing | HIGH |
| P1-7: Protocol confusion | Security bypass attacks | HIGH |
| P1-8: UDP amplification | DDoS vector | HIGH |
Browser → Gateway (HTTP/TCP, port 8000) → ZHTP Backend (QUIC/UDP, port 9334)
HTTP/1.1 HTTP/3 over QUIC
Deploy gateway service to bridge protocols:
// gateway.js - Simple Node.js bridge
const http = require('http');
const { Http3Client } = require('@fails-components/webtransport');
const server = http.createServer(async (req, res) => {
const quicClient = new Http3Client('https://localhost:9334');
const response = await quicClient.fetch(req.url, {
method: req.method,
headers: req.headers,
body: req.body
});
res.writeHead(response.status, response.headers);
res.end(await response.text());
});
server.listen(8000);Update API client configuration:
const config = new BrowserConfigProvider({
zhtpNodeUrl: 'http://localhost:8000', // Gateway, not backend
networkType: 'testnet'
});React Native → Native Bridge (Swift/Kotlin) → ZHTP Backend (QUIC/UDP)
Network.framework/Cronet Direct QUIC connection
Requires platform-specific QUIC implementation (see QUIC-TRANSPORT.md).
| ID | Original Issue | New Status |
|---|---|---|
| P1-5 | Unencrypted HTTP | NOT APPLICABLE - QUIC mandates TLS 1.3 |
| P2-3 | SSRF attacks | REDUCED RISK - QUIC uses UDP, different attack surface |
| ID | Issue | Status |
|---|---|---|
| P1-1 | Session tokens in localStorage | STILL CRITICAL - XSS risk |
| P1-2 | Credentials in request body | STILL CRITICAL - XSS/logging risk |
| P2-1 | No input validation | STILL HIGH - Injection risk |
| P2-2 | Verbose error messages | STILL HIGH - Information disclosure |
| P2-5 | No CSRF protection | STILL RELEVANT - If browser-based |
| P2-6 | No rate limiting | STILL HIGH - Brute force risk |
Attack: Exploit connection migration to hijack sessions
- QUIC allows connections to survive IP changes
- Attacker could inject packets with same Connection ID from different IP
- Requires cryptographic validation to prevent
Mitigation: Backend uses post-quantum cryptography (Kyber512 + Dilithium2)
Attack: Manipulate protocol detection to bypass security
- Backend detects protocol by first bytes of stream
- Attacker sends:
ZHTP\x01GET /admin HTTP/1.1(mixed protocols) - Could confuse router into accepting malicious payloads
Mitigation: Strict protocol validation, separate peer/client ports
Attack: Use QUIC for DDoS amplification
- Spoof victim's IP address
- Send small QUIC request
- Backend sends large response to victim
Mitigation: QUIC RFC 9000 protections (address validation, 3x amplification limit)
Attack: Open hundreds of streams per connection
- Exhausts backend memory and file descriptors
- Partial requests never completed
Mitigation: Configure quinn max_concurrent_bidi_streams limit
-
Deploy HTTP-to-QUIC Gateway
- Bridges HTTP/TCP (port 8000) to QUIC/UDP (port 9334)
- Required for browser compatibility
- Can be Node.js, Go, or Nginx with QUIC module
-
Update Default Configuration
- Change URL from
http://localhost:8000to gateway address - Add connection validation with clear error messages
- Change URL from
-
Add Connection Testing
async testConnection(): Promise<{ connected: boolean; error?: string }> { try { await this.getProtocolInfo(); return { connected: true }; } catch (error) { return { connected: false, error: `Cannot connect to ZHTP backend. Ensure HTTP-to-QUIC gateway is running on port 8000.` }; } }
-
Fix Session Token Storage (P1-1)
- Move from localStorage to httpOnly cookies
- Or use memory-only storage with session expiration
-
Secure Credential Handling (P1-2)
- Use Credential Management API
- Or implement request body encryption
-
Add Input Validation (P2-1)
- Use Zod or Yup for all request parameters
- Validate on client before sending
-
Generic Error Messages (P2-2)
- Never expose internal errors to users
- Log detailed errors server-side only
-
Implement Rate Limiting (P2-6)
- Client-side request throttling
- Exponential backoff on failures
Browser Applications:
↓ HTTP/1.1 over TCP
Gateway Service (port 8000)
↓ HTTP/3 over QUIC
ZHTP Backend (port 9334)
React Native Applications:
↓ Direct QUIC connection
ZHTP Backend (port 9334)
Benefits:
- Browser compatibility (via gateway)
- Native performance (direct QUIC for mobile)
- Post-quantum cryptography for native clients
- Gradual migration path
Tradeoffs:
- Gateway is single point of failure
- TLS termination at gateway (no end-to-end encryption for browsers)
- More complex deployment
✅ QUIC-only architecture - Mandatory TLS 1.3 encryption ✅ Post-quantum cryptography - Kyber512 + Dilithium2 ✅ Rate limiting - 10 handshakes per IP per 60 seconds ✅ Connection limits - Max 10,000 PQC connections ✅ Protocol detection - Validates incoming protocol on each stream ✅ Idle timeouts - 60s client, 300s peer connections ✅ Amplification protection - QUIC RFC 9000 compliant
INCORRECT (line 159):
- **HTTP Fallback**: 9333/TCP (if QUIC unavailable)CORRECT:
There is NO HTTP fallback. QUIC/UDP is mandatory.
For browser compatibility:
1. Deploy HTTP-to-QUIC gateway
2. Gateway accepts HTTP/TCP on port 8000
3. Gateway forwards via HTTP/3 (QUIC) to backend port 9334## ⚠️ CRITICAL: Architecture Requirements
**This library cannot connect directly to the ZHTP backend from browsers.**
The ZHTP backend uses QUIC (UDP) protocol, but JavaScript fetch() uses HTTP (TCP).
You MUST deploy an HTTP-to-QUIC gateway for browser clients:
1. Start gateway: `node gateway.js` (listens on port 8000/TCP)
2. Gateway bridges to backend (port 9334/UDP)
3. API client connects to gateway, not backend directly
For React Native: Implement native QUIC client (see QUIC-TRANSPORT.md)- Gateway service deployed and running
- API client can connect via gateway
- Authentication flow works (signup/login)
- All 52 API methods functional
- Error handling (no stack traces exposed)
- Rate limiting enforced
- Token storage reviewed
- Connection establishment (HTTP → Gateway → QUIC)
- Protocol detection accuracy
- HTTP-over-QUIC compatibility
- Connection migration behavior
- Amplification attack resistance
- Stream limit enforcement
- Idle timeout handling
- Protocol confusion tests
- Protocol confusion:
ZHTP\x01GET / HTTP/1.1 - Connection hijacking via IP spoofing
- Stream exhaustion (open 1000+ streams)
- Amplification attack simulation
- PQC handshake manipulation
- Certificate validation bypass attempts
| Issue | Status | Notes |
|---|---|---|
| A01: Broken Access Control | Session management | |
| A02: Cryptographic Failures | ❌ Vulnerable | Tokens in localStorage |
| A03: Injection | ❌ Vulnerable | No input validation |
| A04: Insecure Design | ❌ Critical | Architecture mismatch |
| A05: Security Misconfiguration | ❌ Vulnerable | Wrong defaults |
| A06: Vulnerable Components | ✅ Good | Dependencies current |
| A07: Authentication Failures | Credentials in body | |
| A08: Software/Data Integrity | ✅ Good | TypeScript safety |
| A09: Logging Failures | Client-side limited | |
| A10: SSRF | QUIC architecture |
Overall Score: 3/10 Good, 4/10 Vulnerable, 3/10 At Risk
Effort: 1-2 weeks Cost: Low (simple Node.js service) Benefits:
- Browser compatibility immediately
- No client changes required
- Easy to deploy
Tradeoffs:
- Gateway is SPOF
- No end-to-end encryption
- Limited QUIC benefits
Effort: 2-4 weeks per platform Cost: Medium (Swift + Kotlin development) Benefits:
- Full QUIC benefits (0-RTT, multiplexing)
- Post-quantum cryptography
- Best performance
Tradeoffs:
- Complex native code
- Platform-specific bugs
- Maintenance overhead
- Deploy gateway for browsers (quick win)
- Implement native clients for React Native (better UX)
- Deprecate gateway when WebTransport is widely supported
Timeline: 2-3 weeks total Cost: Low-Medium ROI: High (functional library + security improvements)
The Sovereign Network API Client has a fundamental architecture incompatibility that prevents it from functioning.
Quick Fix (1 week): Deploy HTTP-to-QUIC gateway Proper Fix (2-4 weeks): Implement native QUIC clients for React Native Security Fixes (1-2 weeks): Address P1/P2 issues (tokens, credentials, validation)
Total Estimated Effort: 4-7 weeks for complete solution
Priority Order:
- Gateway deployment (BLOCKING)
- Security fixes P1-1, P1-2 (CRITICAL)
- Input validation P2-1 (HIGH)
- Native QUIC clients (IMPROVEMENT)
- Remaining P2 issues (HARDENING)
For technical questions about this assessment:
- Review full report:
SECURITY-ASSESSMENT-REVISED.md - Check backend code:
The-Sovereign-Network/zhtp/src/unified_server.rs - Check client code:
sovereign-network-api-client/src/core/zhtp-api-core.ts
Next Steps: Deploy gateway and address P0/P1 issues before ANY production use.