r/opencode • u/atx05 • 3h ago
Network Security — DNS Pinning On OCX (OpenCode eXtended).
One subtle security problem I worked on in OCX was the gap between validating a network destination and actually connecting to it.
A hostname can resolve to an address that passes a security check. But if the HTTP client resolves that hostname again when opening the connection, the destination could be different from the one that was originally validated.
This creates a DNS rebinding risk.
I wanted OCX's network request path to avoid that gap.
I implemented a pinned-network approach in "safeFetch":
- Resolve and validate the destination address.
- Use that validated address for the actual HTTP or HTTPS connection.
- Preserve the original hostname for the HTTP Host header and TLS SNI.
- Add controlled-server tests to verify the connection behavior.
The important detail is that validating an address is not enough. The connection itself must use the address that was validated.
The current implementation covers direct connections. Proxy-aware pinning is not implemented yet, so this is not a complete solution for every network configuration.
It's a relatively small part of OCX, but security often depends on getting these details right rather than relying on checks that happen too early in the request lifecycle.
OCX is still undergoing internal validation, and there is more work ahead.
#OCX #CyberSecurity #NetworkSecurity #SoftwareEngineering #ApplicationSecurity #DeveloperTools