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. */
| 3075 | * local port — which is the DNS-rebinding / cross-site vector against a |
| 3076 | * localhost-only service. */ |
| 3077 | static bool host_is_this_server(const char *host, int port) { |
| 3078 | char expected[128]; |
| 3079 | int length = snprintf(expected, sizeof(expected), "127.0.0.1:%d", port); |
| 3080 | if (length > 0 && (size_t)length < sizeof(expected) && strcmp(host, expected) == 0) |
| 3081 | return true; |
| 3082 | length = snprintf(expected, sizeof(expected), "localhost:%d", port); |
| 3083 | return length > 0 && (size_t)length < sizeof(expected) && strcmp(host, expected) == 0; |
| 3084 | } |
| 3085 | |
| 3086 | static bool route_is_protected(const char *path) { |
| 3087 | return strcmp(path, "/api") == 0 || strncmp(path, "/api/", 5) == 0 || strcmp(path, "/rpc") == 0; |
no outgoing calls
no test coverage detected