Files
moloapp/audit/MOLO-EXPOSE-001/README.md
T

54 lines
2.4 KiB
Markdown

# MOLO-EXPOSE-001: expose upstream allow-list bypass via hostname prefix
**Scope:** [audit](../README.md) · [README](../../README.md) · [AGENTS](../../AGENTS.md)
In-house finding (not a public CVE). CWE-184 ("Incomplete List of Disallowed Inputs"),
the same bug shape behind many documented SSRF / allow-list-bypass CVEs that trust a
string-prefix or substring test to stand in for a real IP-range check.
## Where
`src/realtime/expose/upstream.cpp`, `UpstreamHostAllowed`:
```cpp
if(h.rfind("10.",0)==0)return true;
if(h.rfind("192.168.",0)==0)return true;
...
if(h.rfind("169.254.",0)==0||h.rfind("fe80",0)==0||h.rfind("FE80",0)==0)return true;
```
`reverse.md` documents the policy as "upstream host must be loopback / RFC1918 /
link-local unless `allow_public` is set" (section 7), i.e. this function is meant to
be a strict allow-list that keeps `molo expose` upstreams pointed at the local
machine or its private network. `rfind(prefix, 0) == 0` only checks that `host`
*starts with* the literal text `"10."`, `"192.168."` etc; it is not an IP-address
parse. A DNS name like `10.evil.com` or `127.evil.com` starts with that text too, and
resolves to whatever public IP its owner points it at.
## Relevance
This is the one guard standing between "an exposer may only tunnel to something on
its own machine or LAN" and "an exposer can tunnel to any host on the internet it can
name," for any deployment that has not explicitly opted into `allow_public`. A caller
that relies on this function to keep `molo expose` from being turned into an open
proxy gets a false sense of enforcement.
## What the check does
Compiles a tiny harness directly against the real `upstream.cpp` (a pure function,
no I/O, no server needed) and calls `UpstreamHostAllowed` with five public hostnames
chosen to share a prefix with a private-range literal, plus two real private
literals as sanity controls. PASS requires every public hostname to be rejected and
every private literal to be accepted; FAIL means at least one public hostname was
misclassified as private.
## Caveats
This checks the string-matching logic in isolation; it does not drive a live
`molo expose` registration end to end, because doing so would require resolving a
real external DNS name to prove the end effect, which this audit's own ground rules
avoid making the check depend on (network access). The misclassification itself is
provable with no network.
Run: `make test` in this directory, or `make -C audit test` from the repo root.