PHP 8.3.31
Preview: cxs Size: 4.40 KB
//proc/self/root/proc/self/root/proc/thread-self/root/proc/thread-self/root/proc/self/root/sbin/cxs

#!/bin/bash
##CageFS proxyexec wrapper - ver 18

if [[ $EUID -eq 0 ]]; then
    echo 'Cannot be run as root'
    exit 1
fi

USR=`/usr/bin/whoami`
USER_TOKEN_PATH="/var/.cagefs/.cagefs.token"
WEBSITE_ISOLATION_FLAG="/opt/cloudlinux/flags/enabled-flags.d/website-isolation.flag"
# Trust boundary for the website-isolation token path: it must point
# directly at the regular file that create_website_token_directory()
# creates inside its root-owned per-user storage area. That area is
# /var/cagefs/<prefix>/<user>/.cagefs/website/... on the host and is
# bind-mounted into the cage at /var/.cagefs/website/... — both views
# are accepted because libenter.enter_site() picks one or the other
# depending on whether it runs inside or outside the cage. The file
# itself is never a symlink, so we reject symlinks outright rather
# than canonicalizing with realpath. Without this gate the attacker
# controls both the env var WEBSITE_TOKEN_PATH and the file contents
# at that path; the file contents land in $TOKEN, which is embedded
# into the ssh remote command argv below and re-parsed by the remote
# shell — so shell metacharacters in the file would execute on the
# origin host. (Slite #7 / CLOS-4490)
if [[ -f "$WEBSITE_ISOLATION_FLAG" && -n "$WEBSITE_TOKEN_PATH" ]]; then
    if [[ -L "$WEBSITE_TOKEN_PATH" ]]; then
        echo "cagefs.proxy: WEBSITE_TOKEN_PATH '$WEBSITE_TOKEN_PATH' must not be a symlink" >&2
        exit 1
    fi
    if [[ ! -f "$WEBSITE_TOKEN_PATH" ]]; then
        echo "cagefs.proxy: WEBSITE_TOKEN_PATH '$WEBSITE_TOKEN_PATH' is not an existing regular file" >&2
        exit 1
    fi
    # Reject `..` as a path component so the prefix check below cannot
    # be bypassed via traversal (e.g. /var/cagefs/../etc/passwd matches
    # the /var/cagefs/* glob but resolves outside the trusted area).
    case "$WEBSITE_TOKEN_PATH" in
        */../*|*/..)
            echo "cagefs.proxy: WEBSITE_TOKEN_PATH '$WEBSITE_TOKEN_PATH' must not contain '..' path components" >&2
            exit 1
            ;;
    esac
    case "$WEBSITE_TOKEN_PATH" in
        /var/cagefs/*|/var/.cagefs/*) ;;
        *)
            echo "cagefs.proxy: WEBSITE_TOKEN_PATH must be under /var/cagefs/ or /var/.cagefs/ (got '$WEBSITE_TOKEN_PATH')" >&2
            exit 1
            ;;
    esac
    USER_TOKEN_PATH="$WEBSITE_TOKEN_PATH"
fi
# The -L/-f/prefix gate above is defense-in-depth, TOCTOU is not exploitable because the
# forwarded $TOKEN must still equal the legit on-disk bytes that the
# origin's cagefs.server reads with open(..., O_NOFOLLOW) from a
# uid-derived path (see find_website_by_token() in
# proxyexec/cagefs.server.c) — a swapped symlink redirects what we
# cat, never what the server reads, so a TOCTOU substitution can only
# replace the forwarded bytes with something that fails the server's
# constant-time comparison.
TOKEN=`/bin/cat ${USER_TOKEN_PATH}`
# Tokens are generated as fixed-length alphanumerics by
# _generate_password() in py/clcagefslib/webisolation/jail_utils.py and
# by the corresponding C helper. Any non-alphanumeric byte means the
# token file was tampered with — refuse to forward it into the ssh
# remote command, where the remote shell would re-parse metacharacters.
# Use POSIX `case` rather than `[[ =~ ]]` because the wrapper is also
# invoked through `sh` (e.g. jenkins_tests/rpm_tests/p_cagefs/
# 939-environment_var-check.sh), and dash treats `[[` as a missing
# command — the regex form would falsely trip and exit the script.
case "$TOKEN" in
    "" | *[!A-Za-z0-9]*)
        echo "cagefs.proxy: refusing to forward malformed token from $USER_TOKEN_PATH" >&2
        exit 1
        ;;
esac
# It's user's tmp directory and write to it is secure procedure
# because this script is running only under usual user
PIDFILE="/tmp/.cagefs.proxy.$$"
USER_INTERRUPT=13
CWD=`pwd`

ctrl_c_handler() {
    if [[ -f "$PIDFILE" ]]; then
        pid=`/bin/cat $PIDFILE`
        /bin/rm -f $PIDFILE > /dev/null 2>&1
        /bin/kill -s SIGINT "$pid" > /dev/null 2>&1
    fi
    exit $USER_INTERRUPT
}

if [[ -e /var/.cagefs/origin ]]; then
    ORIGIN=`/bin/cat /var/.cagefs/origin`
    REMOTE="/usr/bin/ssh -F /etc/ssh/cagefs-rexec_config $USR@$ORIGIN"
    $REMOTE CAGEFS_TOKEN="$TOKEN" /usr/sbin/proxyexec -c cagefs.sock "$USR" "$CWD" CXS $$ "$@"
    RETVAL=$?
else
    trap 'ctrl_c_handler' 2
    CAGEFS_TOKEN="$TOKEN" /usr/sbin/proxyexec -c cagefs.sock "$USR" "$CWD" CXS $$ "$@"
    RETVAL=$?
    /bin/rm -f $PIDFILE > /dev/null 2>&1
fi

exit $RETVAL

Directory Contents

Dirs: 0 × Files: 49

Name Size Perms Modified Actions
14.41 KB lrwxr-xr-x 2026-05-29 09:37:55
Edit Download
1.83 KB lrwxr-xr-x 2026-05-29 09:37:55
Edit Download
41.45 KB lrwxr-xr-x 2026-03-24 13:05:31
Edit Download
654 B lrwxr-xr-x 2026-06-03 13:51:46
Edit Download
11.88 KB lrwxr-xr-x 2025-11-10 10:42:43
Edit Download
13.05 KB lrwxr-xr-x 2019-10-12 00:47:15
Edit Download
251 B lrwxr-xr-x 2019-10-12 00:47:14
Edit Download
13.05 KB lrwxr-xr-x 2019-10-12 00:47:15
Edit Download
9.03 KB lrwxr-xr-x 2019-10-12 00:47:15
Edit Download
990 B lrwxr-xr-x 2019-10-12 00:47:14
Edit Download
4.40 KB lrwxr-xr-x 2025-07-31 08:24:16
Edit Download
20.46 KB lrwxr-xr-x 2026-06-08 03:38:10
Edit Download
936 B lrwxr-xr-x 2026-06-08 03:38:03
Edit Download
938 B lrwxr-xr-x 2026-06-08 03:38:03
Edit Download
60.84 KB lrwxr-xr-x 2026-06-08 03:38:10
Edit Download
60.84 KB lrwxr-xr-x 2026-06-08 03:38:10
Edit Download
64.75 KB lrwxr-xr-x 2026-06-08 03:38:10
Edit Download
72.84 KB lrwxr-xr-x 2026-06-08 03:38:10
Edit Download
934 B lrwxr-xr-x 2026-06-08 03:38:03
Edit Download
56.74 KB lrwxr-xr-x 2026-06-08 03:38:10
Edit Download
60.84 KB lrwxr-xr-x 2026-06-08 03:38:10
Edit Download
117.20 KB lrwxr-xr-x 2026-06-08 03:38:10
Edit Download
52.84 KB lrwxr-xr-x 2026-06-08 03:38:10
Edit Download
4.41 KB lrwxr-xr-x 2026-05-29 19:00:38
Edit Download
20.52 KB lrwxr-xr-x 2025-12-17 18:54:08
Edit Download
12.38 KB lrwxr-xr-x 2026-06-08 03:38:10
Edit Download
693.30 KB lrwxr-xr-x 2024-05-23 08:36:03
Edit Download
11.85 KB lrwxr-xr-x 2026-06-08 03:38:10
Edit Download
9.06 KB lrwxr-xr-x 2026-06-03 10:46:51
Edit Download
986.13 KB lrwxr-xr-x 2026-05-26 09:39:13
Edit Download
683 B lrwxr-xr-x 2026-06-03 10:46:51
Edit Download
24.44 KB lrwxr-xr-x 2025-12-17 18:54:08
Edit Download
36.63 KB lrwxr-xr-x 2026-06-08 03:38:10
Edit Download
36.63 KB lrwxr-xr-x 2026-06-08 03:38:10
Edit Download
12.29 KB lrwxr-xr-x 2026-06-08 03:38:10
Edit Download
45.20 KB lrwxr-xr-x 2025-12-17 18:54:08
Edit Download
11.87 KB lrwxr-xr-x 2025-12-17 18:54:08
Edit Download
20.57 KB lrwxr-xr-x 2022-02-23 20:13:56
Edit Download
21.17 KB lr-xr-xr-x 2020-09-02 07:49:11
Edit Download
20.44 KB lrwxr-xr-x 2025-12-17 18:54:08
Edit Download
94.42 KB lrwxr-xr-x 2022-02-23 20:13:56
Edit Download
20.77 KB lrwxr-xr-x 2022-02-23 20:13:56
Edit Download
16.42 KB lrwxr-xr-x 2022-02-23 20:13:56
Edit Download
4.41 KB lrwxr-xr-x 2026-05-29 19:00:38
Edit Download
16.66 KB lrwxr-xr-x 2022-02-23 20:13:56
Edit Download
35.47 KB lrwxr-xr-x 2019-10-12 11:32:29
Edit Download
20.46 KB lrwxr-xr-x 2026-06-08 03:38:10
Edit Download
36.86 KB lrwxr-xr-x 2025-12-17 18:54:08
Edit Download
36.86 KB lrwx------ 2025-12-17 18:54:08
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).