SSRF Defense & Server Hardening
Outbound URL allowlists, SSRF IP blocking, certificate pinning, seccomp, and capability dropping.
When a database speaks over the network to webhooks, object stores, Kafka brokers, cluster peers, or cross-cluster replication links, both outbound network egress and the OS process sandbox become critical security boundaries.
SpydDB ships defense-in-depth protections built directly into the server binary without requiring external sidecar proxies.
1. Outbound Address Policy & SSRF Defense#
Whenever spyd-server opens an outbound TCP or TLS connection for webhooks, synthetic probes, peer links, or connectors, DNS resolution happens once and every resolved IP address is checked against AddressPolicy immediately before dialing—defeating DNS rebinding attacks where an external hostname flips to an internal address after validation.
Automatically Blocked Address Ranges (block_special)#
By default, outbound connections fail closed against cloud metadata services and reserved local ranges (including IPv4-mapped IPv6 forms such as ::ffff:169.254.169.254):
| Blocked Range / Address | Family | Protects Against |
|---|---|---|
0.0.0.0/8 | IPv4 | Unspecified / local host bind hijacking |
169.254.0.0/16 | IPv4 | AWS / GCP / Azure IMDS metadata (169.254.169.254) and link-local hosts |
100.100.100.200/32 | IPv4 | Alibaba Cloud metadata endpoint |
255.255.255.255 & 224.0.0.0/4 | IPv4 | Directed/subnet broadcasts & IPv4 multicast |
:: | IPv6 | Unspecified IPv6 address |
fe80::/10 | IPv6 | IPv6 link-local neighbors |
fd00:ec2::254 | IPv6 | AWS EC2 IPv6 Instance Metadata Service (IMDSv2 over IPv6) |
ff00::/8 | IPv6 | IPv6 multicast addresses |
Explicit CIDR Allowlists#
For cluster links and cross-cluster replication, pair block_special with an explicit CIDR allow list (both IPv4 and IPv6, such as 10.20.0.0/16 or 2001:db8::/32). Even if DNS returns a valid public IP, connections outside the allowlist are refused before opening a socket.
2. Outbound TLS Verification & Leaf Certificate Pinning#
OutboundTls controls certificate trust on every outbound HTTPS/gRPC/cluster dial:
- Default WebPKI roots + private CAs: Combine Mozilla/WebPKI root certificates with internal PEM CA bundles (
ca_pem). - SHA-256 leaf certificate pinning: Supply a 64-character hexadecimal SHA-256 digest (
pin, with optional colon separators). SpydDB compares the peer's DER leaf digest using a constant-time XOR comparison so timing side channels never reveal partial matches. - Strict chain + pin vs. pin-only spokes: Normally a pin is verified in addition to CA chain validation (
pin+ WebPKI/private CA). For air-gapped self-signed spoke nodes,pin_onlytrusts the exact pinned leaf digest explicitly (requiring a valid pin and refusing misconfigured empty pins). - Shared TLS config cache: Built TLS client configs are cached (up to 1,024 distinct peer policies) so repeated webhook deliveries or replication polls avoid re-parsing root certificate stores.
3. Linux Kernel & OS Process Hardening#
On startup, spyd-server hardens its own OS process before serving client traffic:
Pre-Open Memory & Privilege Lock (harden_process_before_open)#
- Disable core dumps (
PR_SET_DUMPABLE = 0&RLIMIT_CORE = 0): Prevents encryption keys, cached row pages, and session tokens in RAM from ever being written to disk or inspected via/proc/<pid>/memafter a crash. - Prevent privilege escalation (
PR_SET_NO_NEW_PRIVS = 1): Ensures neitherspyd-servernor any spawned child can ever gain privileges via setuid binaries or file capabilities. - Scoped Linux capability drop: Drops all Linux bounding-set and process capabilities immediately—temporarily retaining only
CAP_IPC_LOCKso the storage engine can pin sensitive key buffers and zeroizing memory pages in RAM viamlockallagainst swap. - Drop final capability (
drop_remaining_capabilities): Immediately afterDatabase::openfinishes locking memory,CAP_IPC_LOCKis revoked too, leavingeffective = 0,permitted = 0, andinheritable = 0.
x86_64 Seccomp Syscall Filter#
On x86_64 Linux hosts, spyd-server installs a kernel eBPF/seccomp filter returning EPERM on high-risk kernel/process manipulation syscalls:
- Process inspection/injection:
ptrace,process_vm_readv,process_vm_writev - Kernel modification:
bpf,kexec_load - Filesystem & namespace breakout:
mount,umount2,pivot_root,chroot,unshare,setns
Note: The bundled Kubernetes manifests & operator mirror these protections at the container boundary by running non-root with a read-only root filesystem, disabled automounted service-account tokens, dropped container capabilities, and
RuntimeDefaultseccomp profiles.