The pcap Approach and Firewall Bypass
Why Standard Firewalls Don’t Work
A normal application uses the OS’s TCP/IP stack. When a packet arrives, it travels up the stack wherenetfilter (the backend for ufw/firewalld) inspects it. If a firewall rule blocks the port, the packet is dropped and never reaches the application.
Normal Application Stack
ufw deny 9999 work because netfilter can intercept and drop packets before they reach the application.
How paqet Bypasses Firewalls
paqet usespcap to hook in at a much lower level. It requests a copy of every packet directly from the network driver, before the main OS TCP/IP stack and firewall process it.
paqet’s Bypassed Stack
Critical Implication
Firewall bypass is bidirectional:- Inbound: paqet can receive packets on ports that are “blocked” by the firewall
- Outbound: paqet can send packets that appear to come from “blocked” ports
- Cloud provider security groups still matter - they operate at the hypervisor/network level, before packets reach your instance
- Physical network firewalls still work - they inspect packets before they reach the host
- Application-level authentication is critical - you cannot rely on firewall rules to restrict access
Encryption Capabilities
paqet uses KCP’s built-in encryption to secure the transport layer. Encryption is configured via thetransport.kcp.block parameter.
Supported Encryption Modes
| Mode | Security | Performance | Authentication |
|---|---|---|---|
aes | High | Good | Yes |
chacha20 | High | Better (on some platforms) | Yes |
3des | Medium | Lower | Yes |
tea | Low | Good | Yes |
xor | None (obfuscation only) | Best | Yes |
none | None | Best | NO |
null | None | Best | NO |
Recommended Configuration
Production environments:Use the
paqet secret command to generate cryptographically secure keys:Security Considerations
1. No Authentication in Some Modes
From the README (line 234-237):2. Kernel Interference Requires iptables Rules
Although paqet bypasses the normal TCP/IP stack, the OS kernel can still see incoming packets and generate TCP RST packets since it has no knowledge of the connection. These kernel-generated resets can:- Corrupt connection state in NAT devices
- Cause packet drops in stateful firewalls
- Lead to premature connection termination
- Create instability in the tunnel
3. Avoid Standard Ports
From the README (lines 143-146):4. Cloud Provider Firewalls
While paqet bypasses OS-level firewalls, cloud provider security groups still apply because they operate at the hypervisor/network level. You must configure your cloud provider’s firewall to allow:- Inbound TCP traffic on your server’s listen port
- Outbound TCP traffic from your server (for responses)
Common cloud provider firewall locations:
- AWS: Security Groups in EC2 console
- GCP: Firewall Rules in VPC console
- Azure: Network Security Groups
- DigitalOcean: Cloud Firewalls
5. Key Management
Critical security practices:- Generate strong keys using
paqet secretcommand - Use different keys for different deployments (dev/staging/prod)
- Rotate keys periodically (requires coordinated client/server updates)
- Never commit keys to version control
- Ensure client and server keys match exactly - even a single character difference will cause connection failure
6. Exposure Risks
Because paqet provides a proxy to your server’s network: Without proper security:- Anyone can use your server as an exit node
- Your server’s IP can be used for malicious activity
- Internal network resources may be exposed
- You may face legal liability for proxied traffic
- Always use authenticated encryption modes (
aes,chacha20) - Monitor server logs for unusual activity
- Implement rate limiting if needed
- Consider IP-based restrictions at the cloud provider level
- Use strong, unique keys
Security Best Practices Summary
- ✅ Always use
aesorchacha20encryption in production - ✅ Generate keys with
paqet secretcommand - ✅ Apply all required iptables rules on the server
- ✅ Use non-standard ports (9999, 8888, etc.)
- ✅ Configure cloud provider security groups correctly
- ✅ Monitor logs for unauthorized access attempts
- ✅ Rotate keys periodically
- ❌ Never use
noneornullmodes outside testing - ❌ Never use standard ports (80, 443)
- ❌ Never rely on OS firewall rules for access control