Control: tags -1 + pending upstream

Hi,

Thanks for the report!

On Thu, Nov 05, 2026 at 11:22:25PM +0200, Alexandru-Ionut Jipa wrote:
 
> shellinabox/externalfile.c's externalFileHttpHandler() (registered for
> the admin-opt-in --static-file <url-path>:<local-dir> command-line
> option) is supposed to block path traversal by rejecting any path
> component starting with ".". This is the guard added after the
> project's historical directory-traversal advisory, CVE-2012-4871. The
> guard loop has a pointer-advance bug that makes it ineffective for
> every path component after the first.

Sorry I didn't follow the reference to the prior CVE - seems to be for a
different package. However, the remainder of the report seems to stand.

> Root cause (externalfile.c):
[..]
>     // Any files/directories starting with a dot are inaccessible to us
>     do {
>         if (*ptr == '.') {
>             deleteURL(url);
>             free(fn);
>             httpSendReply(http, 404, "File not found", NO_MSG);
>             return HTTP_DONE;
>         }
>         ptr = strchr(ptr + 1, '/');
>     } while (ptr);
> }
> 
> strchr(ptr + 1, '/') returns a pointer AT the '/' character it finds,
> not past it. The loop then re-tests *ptr == '.', but ptr now points at
> '/', so the comparison is always false, and the loop repeats forever
> matching only slash characters. The only character of pathInfo ever
> actually checked against '.' is the very first one (before the loop
> starts). Every subsequent path-component boundary - including the
> character right after an internal '/' that would be '.' for a ".."
> component - is never inspected.
> 
> No URL-decoding happens anywhere before this handler runs, so literal
> ../ sequences in the raw HTTP request line work directly with no
> encoding needed.
> 
> Impact: any deployment using the documented --static-file option
> (serving custom CSS/branding assets - a supported, non-default
> feature) exposes an unauthenticated directory-traversal file-read
> primitive to any network client able to reach the HTTP(S) listener,
> reading arbitrary files readable by the shellinaboxd process user.
> This is a regression that reintroduces exactly the vulnerability class
> and feature area of CVE-2012-4871.

I agree, if an admin uses this feature they may expose filesystem
content outside the intended subtree.

I have reproduced this failure with the packaged version of this
application end to end (not with a contrived harness) and pushed my fix
to this as a patch in the 'salsa' packaging repository. The failure does
not reproduce with my fix:

https://salsa.debian.org/salvage-team/shellinabox/-/commit/e2f5383afd19e6a0199cbc8e71565b6cb97878a3

> Suggested fix, in externalfile.c:
> 
> do {
>     if (*ptr == '.') {
>         ...
>     }
>     ptr = strchr(ptr, '/');
>     if (ptr) { ptr++; }
> } while (ptr && *ptr);

Agreed this ought to work, too.

> No CVE has been requested yet for this - happy to coordinate on
> disclosure timing/CVE assignment.

I see no reason to delay a Debian upload for this as the bug is public,
reproduced and we have a fix. As you are keen to co-ordinate wider
activity, would you mind sending a report to the upstream project's
forge?

Andrew

Reply via email to