MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / host_is_this_server

Function host_is_this_server

src/ui/http_server.c:1688–1695  ·  view source on GitHub ↗

True when the Host header names the loopback interface and exact port the * server binds to. Anything else means the request reached us under a * name that is not loopback — a rebinding DNS host or a proxy pointed at the * local port — which is the DNS-rebinding / cross-site vector against a * localhost-only service. */

Source from the content-addressed store, hash-verified

1686 * local port — which is the DNS-rebinding / cross-site vector against a
1687 * localhost-only service. */
1688static bool host_is_this_server(const char *host, int port) {
1689 char expected[128];
1690 int length = snprintf(expected, sizeof(expected), "127.0.0.1:%d", port);
1691 if (length > 0 && (size_t)length < sizeof(expected) && strcmp(host, expected) == 0)
1692 return true;
1693 length = snprintf(expected, sizeof(expected), "localhost:%d", port);
1694 return length > 0 && (size_t)length < sizeof(expected) && strcmp(host, expected) == 0;
1695}
1696
1697static bool route_is_protected(const char *path) {
1698 return strcmp(path, "/api") == 0 || strncmp(path, "/api/", 5) == 0 || strcmp(path, "/rpc") == 0;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected