[0] Application
From the weborf README (codeberg.org/ltworf/weborf):
« User friendly webserver. »
weborf is a small webserver written in C, meant to let a user share a directory
over HTTP with no configuration. It has limited WebDAV support (used by the GNOME
and KDE file managers) and optional CGI. WebDAV is compiled in unconditionally
(options.h.in:123, no configure switch). It ships with a graphical front end,
qweborf, which drives the same binary and can turn on writing, WebDAV and
authentication.
Authentication is delegated to an external provider over a unix socket: weborf
sends the request fields to the provider and reads back a decision. The project
ships three example providers (auth.py, weborf_auth.c, weborf_auth_dav.c)
and qweborf carries its own (whelper.py).
The default uid is 0 (ROOTUID, options.h.in:32, configuration.c:53), and
set_new_uid() drops privileges only when a uid other than 0 is requested, with
no log and no warning otherwise (listener.c:239-241). The man page presents the
-u option as a convenience for binding low ports, not as a requirement
(weborf.1).
On Debian, two packages matter and they behave differently:
- the
weborfpackage (whatapt install weborfinstalls) ships only the binary, the man page, the documentation and the example providers. It carries no systemd unit, no/etc/weborf.confand no launcher (verified withdpkg -Land on the package contents of 1.5-1 and 1.7-3). An administrator following the documentation starts it by hand, and without-uit runs as root. - the separate
weborf-daemonpackage ships a launcher (weborf_launcher) that refuses to start as root and runs the server aswww-datafrom/etc/weborf.conf, together with the systemd units. It is not pulled in by installingweborfalone.
The findings below were verified on the official 1.7 release tarball and on the
Debian trixie weborf package (1.5-1), from the position of an unauthenticated
remote host, and the full chain was run end to end against both builds on a
Debian trixie staging host. The vulnerable functions (copy_move, file_copy,
decode64, auth_check_request) are byte-for-byte identical in 1.5 and 1.7, so
the line numbers below are from 1.7. The relevant code is unchanged on current
upstream.
[I] Unauthenticated file copy and move outside the share (COPY/MOVE)
A) Overview
COPY and MOVE are the only state-changing methods weborf accepts without an
authentication provider, and the Destination header they act on is concatenated
onto the share root with no decoding, no ../ filtering and no containment check.
An anonymous client copies or moves any file of the share to any path the server
uid can write, including outside the share, and overwrites existing files head
first.
B) Required data
Nothing beyond network access to a weborf instance with its default
build. No credentials, no provider, no prior knowledge of the share. This finding
is present on every build, including a bare weborf -b /some/dir.
C) Explanation
Every other state-changing verb refuses to run without a provider: PUT
(instance.c:375), DELETE (instance.c:452), MKCOL (webdav.c:425) and PROPFIND
(webdav.c:309) all test weborf_conf.authsock. copy_move() (webdav.c:461)
does not. It reads the Destination header verbatim (webdav.c:477) and builds
the local path by raw concatenation (webdav.c:508):
snprintf(destination, PATH_LEN, "%s%s", connection_prop->basedir, dest);
The ../ scrub (strReplace(url,"../",'\0'), instance.c:109) runs on the
request URI only, never on the Destination header, so Destination carries
../ out of the share freely. file_copy() then opens the destination
O_WRONLY|O_CREAT without O_TRUNC (myio.c:161), so copying a shorter source
over a longer existing file replaces the head and leaves the tail in place.
The Overwrite header is handled with the polarity reversed from RFC 4918
(webdav.c:485-494): Overwrite: T against an existing target is refused (412),
Overwrite: F overwrites. Only the header-absent case behaves as the RFC
default (overwrite).
D) Exploitation
== 1. control: PUT without a provider is refused ==
GET / -> 303
PUT /x.txt -> 403
== 2. COPY out of the share ==
COPY /index.html
Destination: /../../../../../../etc/weborf-escaped
-> 201
== 3. COPY over an existing file (no O_TRUNC) ==
COPY /index.html
Destination: /admin-notes.txt
-> 204
GET /admin-notes.txt:
(head replaced by index.html, original tail still present)
Run against the Debian weborf binary launched as documented: PUT is refused,
COPY is not. The copied file lands outside the share, owned by the server uid,
with no credentials.
E) Consequences
On its own this is an unauthenticated primitive to copy any existing file of the
share to any path the server uid can write, and to corrupt existing files head
first (any configuration file, key or script writable by that uid). The source
stays inside the share (the request-URI scrub holds), so it does not by itself
place attacker-chosen content. One exception for reading: the source path follows
symbolic links, and the man page documents links as a supported way out of the
share (weborf.1), so on a share that contains a symlink pointing outside, COPY
pulls the target back into the share for any client to read. This was confirmed
in the audit (/etc/passwd copied into the share through a single symlink). On a
symlink-free share the primitive does not read arbitrary files. Placing
attacker-chosen content is the job of finding [II], and the two together give
code execution (see [III]).
[II] Forged authorisation via the provider protocol (CRLF injection)
A) Overview
The request URI is percent-decoded before it is written as the first field of the
CRLF-delimited frame sent to the authentication provider. A %0D%0A in the URI
injects field separators, so the client forges the method, client IP, username
and password fields the provider reads, while weborf dispatches the real request.
Every provider the project ships is defeated by this, or is broken on its own,
and the provider protocol treats a silent connection close as “allow”.
B) Required data
A weborf instance with an authentication provider configured (-a socket).
This is the documented way to enable writing without the GUI, and it is
automatic when sharing with qweborf. No credentials are needed.
C) Explanation
set_connection_props() percent-decodes the URI in place (instance.c:104-109,
modURL to replaceEscape: %0D to CR, %0A to LF) before
auth_check_request() writes it as field 1 of the frame (auth.c:135):
snprintf(auth_str, ..., "%s\r\n%s\r\n%s\r\n%s\r\n%s\r\n%s\r\n",
page, ip_addr, method, username, password, http_param);
A %0D%0A in the URI therefore closes field 1 early and lets the client supply
the remaining fields. The providers parse this frame positionally and decide on
exactly those fields.
The protocol itself grants access on silence: weborf considers the request
authorised when it has written the frame and the provider closes without a reply
(auth.c:136: write()==len && read()==0). There is no peer check on the socket,
and the shipped C examples bind it under /tmp (weborf_auth.c,
weborf_auth_dav.c), so a local user who takes the socket path becomes the
authenticator, captures every client’s decoded credentials and grants everything
by accepting and closing.
The shipped providers:
auth.pytrusts an internal network by client IP (auth.py:66,::ffff:10.0.), which the forged IP field supplies directly. It also carries a logic bug (auth.py:72:andwhereoris required) that lets the right username with any password through on its protected paths, and it fails open on a malformed header (a header line without:raises aValueError, the transport closes, and weborf reads the close as allow).weborf_auth_dav.chas a missing==0on its method comparison (weborf_auth_dav.c:92), so its allow branch is true for every method but OPTIONS itself, and the documented deny of DELETE/MOVE/COPY is dead code.weborf_auth.conly ever restricts URIs under/film, so any other request, including PUT, is accepted and closed, which weborf reads as allowed.- qweborf’s
whelper.pyallows everyone when the authentication box is unchecked (its default), leaving a method allowlist as the only gate, which the same forgery defeats by replacing the method field. qweborf always passes-ato the binary, so the C-side gates never engage.
D) Exploitation
== 1. control: PUT, no credentials ==
HTTP/1.1 401 Authorization Required
== 2. PUT with CRLF-injected fields in the URI ==
URI: /poc.txt%0D%0A::ffff:10.0.0.1%0D%0AGET%0D%0A%0D%0A
body: WE-CONTROL-THE-SOURCE
HTTP/1.1 201 OK
== 3. read it back ==
HTTP/1.1 200 OK
body: WE-CONTROL-THE-SOURCE
The administrator’s provider is in place and the control PUT is refused. The forged PUT is not: the injected separators shift the frame, the real method lands in the slice the provider parses as headers, its parser raises on a line with no separator, the socket closes, and weborf reads the close as allow. No password was consulted and weborf ran the real PUT. The attacker now controls the content of the share.
E) Consequences
An unauthenticated client defeats the authentication layer and gains the write methods it protects, PUT in particular. The flaw is in the protocol and the decode order: every shipped provider and the silence-means-allow contract fall to the same field forgery.
[III] The chain: unauthenticated remote code execution
Findings [I] and [II] combine. [II] gives a forged PUT, so the attacker places content of its choosing in the share. [I] moves that file out of the share into an execution hook. The result is code execution with no credentials, using only the project’s own documented deployment.
== 1. forged PUT: plant the payload (CRLF-injected URI) ==
body: * * * * * root <command>
HTTP/1.1 201 OK
== 2. forged COPY: move it to an execution hook ==
Destination: /../../../../../../etc/cron.d/weborf-poc
HTTP/1.1 201 OK
== 3. cron runs it within the minute ==
Run end to end on a Debian trixie staging host: the file lands root-owned in
/etc/cron.d/, cron executes it (confirmed in the system journal), and a shell
connects back as uid=0(root).
Why root is the main case. On the minimal deployment (the weborf package,
no weborf-daemon), the administrator starts the server by hand. The default uid
is 0 (options.h.in:32, configuration.c:53), set_new_uid() is a no-op for
uid 0 (listener.c:239-241), and the man page presents -u as optional, so
weborf -b /srv/share -p 80 runs as root with no warning. The cron hook above is
then a root shell.
This is the worst case of that deployment. The separate
weborf-daemon package ships a launcher (weborf_launcher) that refuses to start
as root and runs the server as www-data from /etc/weborf.conf. On that path
the chain still executes, with the serving uid instead of root (see the variants
below). The documented minimal install, run by hand, gives root.
The non-root path is also broken as shipped for any serving uid other than the
provider’s. auth.py creates its socket with the process umask (srwxr-xr-x
under the shipped unit, no umask or chmod in the script), and connecting to
a unix socket requires write permission on it. A weborf started with -u on a
uid that differs from the socket owner’s gets EACCES on connect()
(auth.c:124), auth_check_request() returns -1, and the server answers 401 to
every request, valid credentials included. Root bypasses the permission check,
and so does a weborf running under the provider’s own uid, which is what the
weborf-daemon pairing does (www-data on both sides) once its configuration
names the auth socket. Any other serving uid, the one an administrator picks
when following the man page, is locked out entirely.
The rule is the kernel’s (unix_find_bsd() checks MAY_WRITE on the socket,
net/unix/af_unix.c), and the failure was observed on the staging host: EACCES
on connect() under strace.
Variants.
- Non-root uid (
-u,weborf-daemon, qweborf). The same chain runs with the server’s uid. Only the hook changes: an unprivileged uid cannot write/etc/cron.d, but the serving user’s own files are as effective (~/.bashrc,~/.profile,~/.ssh/authorized_keys,~/.config/autostart). One precondition differs: the attacker must know which user to target. In the deployment this models (a desktop user sharing a folder with qweborf), that user is the operator and is visible on the share. - qweborf. The GUI always passes an auth socket to the binary, so the C-side gates never engage, and with the authentication box unchecked (its default) the provider allows everyone behind a method allowlist that the CRLF forgery defeats. The chain is identical and yields code execution as the desktop user.
[IV] Out-of-bounds read in the base64 decoder (pre-authentication)
A) Overview
decode64(), the hand-rolled base64 decoder used for Basic credentials, consumes
its input four characters at a time without checking the remaining length, on the
pre-authentication path.
B) Explanation
decode64() loops on while (encoded[0] != 0) and advances four bytes per
iteration (base64.c:77-86), with no len % 4 guard. The only bound
(auth.c:88) limits the encoded length, not its remainder modulo four. For a
Authorization: Basic payload whose length is not a multiple of four, the loop’s
next-group test reads past the end of the 600-byte stack buffer (PWDLIMIT*2,
options.h.in:67) in auth_check_request(), reached from send_page() before
any authentication (instance.c:505):
AddressSanitizer: stack-buffer-overflow
READ of size 1 in decode64 (base64.c:80)
auth_check_request (auth.c:98)
send_page (instance.c:505) <- pre-authentication path
C) Consequences
On an AddressSanitizer build the server dies on the first such request. On current optimised builds, including the Debian package, the byte past the buffer is zero padding on the present compiler layout, so the read is silent and the server answers normally. On that layout the write side stays in bounds, so no data leak is claimed. This is a latent memory-safety defect on the authentication path, present in every build (confirmed in 1.5 and 1.7), to be fixed. The advisory makes no further claim.
[V] Mitigation
- Gate COPY and MOVE like every other state-changing verb (refuse when
weborf_conf.authsock == NULL,webdav.c). - Validate the
Destinationheader: percent-decode it, then apply arealpath()containment check that keeps both the request path and the destination under the share, instead of raw concatenation. Open destinations withO_TRUNCwhen replacing (myio.c:161), and restore RFC 4918 polarity onOverwrite(webdav.c:485-494). - Make the provider frame non-injectable: reject any byte below 0x20 in every field before building the frame, or move to length-prefixed framing. Send the real method and client IP out of band so the provider can cross-check them.
- Fix the provider protocol: an explicit allow byte instead of
silence-means-allow (
auth.c:136), peer verification (SO_PEERCRED), and a service-owned runtime directory for the socket rather than/tmp. - Fix the shipped examples, which deployers copy:
auth.py:72(andtoor),weborf_auth_dav.c:92(the missing==0), andauth.pyheader parsing (fail closed). - Warn or refuse on root: print a warning (or refuse to start) when the uid
would stay 0, and make the
-udeployment work with the shipped provider: haveauth.pycreate its socket with a mode that lets the serving uid connect (umask orchmodafter bind, or a group-writable socket with that uid in the group). - Replace
decode64with a length- and size-aware decoder (reject anylen % 4 != 0, strict alphabet), which closes finding [IV] and the credential handling at its root.
[VI] Timeline
2026/10/11: Advisory drafted 2026/10/12: Maintainer notified by email
[VII] Author
John JEAN is a French security researcher, CTO at Wargan (https://www.wargan.com).
Follow me on X @johnjean
[VIII] PGP
My current PGP key is 0xDC3CB82BF0967AF0, you can get it on the Work with me page.