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

2.6 KiB

MOLO-DAV-001: WebDAV COPY into its own subtree never terminates

Scope: audit · README · AGENTS

In-house finding (not a public CVE). CWE-674 ("Uncontrolled Recursion") plus CWE-400 (uncontrolled resource consumption); RFC 4918 9.8.3 and 9.9.3 require a WebDAV server to reject exactly this COPY/MOVE shape with 403 Forbidden before doing anything.

Where

src/realtime/webdav/server/resource_tree.cpp, ResourceTree::copy:

std::string prefix = src + "/";
for (const auto& [k, v] : entries_) {
  if (k == src || k.compare(0, prefix.size(), prefix) == 0) {
    ...
    entries_[target] = v;   // <-- inserts into the map being iterated
    ...
  }
}

There is no check anywhere that dst is not inside src (only src == dst, line 159, which this shape does not trigger). When dst falls lexically after the iterator's current position in the sorted std::map, the newly inserted entry (dst + the relative suffix) is reached later by the same ongoing iteration, because entries_'s end() sentinel is unaffected by insertion. Copying /dav/a to /dav/a/b inserts /dav/a/b/b, which the loop then visits and inserts /dav/a/b/b/b, and so on, forever, each entry copying the full body bytes of everything under src again. ResourceTree::move (next function) calls copy first, so it inherits the same bug and then also deletes the whole source subtree afterward if copy ever did return.

Relevance

A WebDAV COPY or MOVE with an attacker-chosen Destination header that happens to be a path under the source directory (a single HTTP request, no special privilege) pins a server thread forever and grows its memory without bound, an unauthenticated remote DoS against anything that mounts this ResourceTree behind a COPY/MOVE route.

What the check does

ResourceTree is pure in-memory state with no I/O (confirmed against its header, which never mentions a socket or filesystem call), so the check drives it directly: creates /dav/a with one file, then calls copy("/dav/a", "/dav/a/b", true, created) under a 10-second watchdog. PASS means copy returned within the deadline; FAIL means the watchdog fired, proving the loop does not converge.

Caveats

No COPY/MOVE HTTP route is wired to a live server binary in example/ today (the example's simplified fw::WebdavStore only exposes GET/PUT/DELETE/PROPFIND), so this exercises the real class directly rather than over a socket; the class is the one src/realtime/webdav/server/copy_move_handler.cpp calls for every real COPY/MOVE.

Run: make test in this directory, or make -C audit test from the repo root.