🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.bugs.dist
Article #3386

Bug#1153131: shellinabox: directory traversal regression in --static-file handler (externalfile.c)

#3386
From: Andrew Bower
Date: Fri, 06 Nov 2026 00:00
85 lines
5196 bytes
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
Technical Details
Message-ID: <NWfx7-a4Vm-3@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!2.eu.feeder.erje.net!feeder.erje.net!news.szaf.org!news.datentrampelpfad.de!news.imp.ch!news.corradoroberto.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod
References: <NWfx7-a4Vm-5@gated-at.bofh.it> <NWfx7-a4Vm-5@gated-at.bofh.it>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!2.eu.feeder.erje.net!feeder.erje.net!news.szaf.org!news.datentrampelpfad.de!news.imp.ch!news.corradoroberto.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod
From: Andrew Bower <andrew@bower.uk>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1153131: shellinabox: directory traversal regression in --static-file handler (externalfile.c)
Date: Fri, 06 Nov 2026 01:00:01 +0100
Message-ID: <NWfx7-a4Vm-3@gated-at.bofh.it>
References: <NWfx7-a4Vm-5@gated-at.bofh.it> <NWfx7-a4Vm-5@gated-at.bofh.it>
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org  Thu Nov  5 23:57:08 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -1.45
Reply-To: Andrew Bower <andrew@bower.uk>, 1153131@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: team+salvage@tracker.debian.org
X-Debian-Pr-Message: followup 1153131
X-Debian-Pr-Package: shellinabox
X-Debian-Pr-Keywords: security
X-Debian-Pr-Source: shellinabox
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/2.4.1 (2026-07-04)
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2000892
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 85
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Thu, 5 Nov 2026 23:55:15 +0000
X-Original-Message-ID: <au0XY9jeUaZkUrGE@arden.ab8.net>
X-Original-References: <CAPrcYpig+gMVAKWX6FxRQkBQWt=VKZcyuwo9ZnRb5iejWAXT8Q@mail.gmail.com> <CAPrcYpig+gMVAKWX6FxRQkBQWt=VKZcyuwo9ZnRb5iejWAXT8Q@mail.gmail.com>