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. */
| 1686 | * local port — which is the DNS-rebinding / cross-site vector against a |
| 1687 | * localhost-only service. */ |
| 1688 | static 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 | |
| 1697 | static bool route_is_protected(const char *path) { |
| 1698 | return strcmp(path, "/api") == 0 || strncmp(path, "/api/", 5) == 0 || strcmp(path, "/rpc") == 0; |
no outgoing calls
no test coverage detected