An authfile with no users turns off authentication and ACLs

Aperta
#631 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go

Direzione di ricerca

Start with authUser in server/server.go and the permissions and ACL handling in server/server_handler.go; trace how --authfile and --auth affect authentication when the loaded user list is empty. Reproduce the reload case with the provided script and check how empty authfiles should behave. Done means an empty configured authfile rejects logins and does not grant tunnels, including after a live reload.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

When chisel server runs with --authfile and no --auth, and the authfile lists no
users ({}), the server accepts any username and password. The session also has no
ACL, so the client can open tunnels to any destination, including the server's own
loopback services, use SOCKS, and bind reverse ports.

The authfile is reloaded on change, so this also happens at runtime: an operator who
removes the last user from a running server's authfile opens the server to everyone,
with no warning.

In server/server.go authUser, if s.users.Len() == 0 { return nil, nil } lets
every login through. In server/server_handler.go, a nil sshConn.Permissions leaves
user == nil, so no remote is checked at config time and tunnelConfig.ACL is never
set. Auth-disabled is decided by how many users are loaded right now, not by whether an
authfile was configured.

Reproduction

#!/bin/sh
# usage: repro.sh <chisel binary>
BIN=$1; d=$(mktemp -d)
printf '%s\n' '{"alice:secret": ["^127.0.0.1:1$"]}' > $d/users.json
$BIN server --port 18080 --authfile $d/users.json >$d/server.log 2>&1 &
pid=$!; sleep 1
try() { timeout 3 $BIN client --auth "$1" --max-retry-count 0 http://127.0.0.1:18080 \
  127.0.0.1:18081:127.0.0.1:18080 2>&1 | grep -q Connected && echo "$2: $1 ACCEPTED" || echo "$2: $1 refused"; }
try mallory:wrong "alice in authfile"
echo '{}' > $d/users.json; sleep 1
try mallory:wrong "empty authfile   "
kill $pid; cat $d/server.log

Output:

alice in authfile: mallory:wrong refused
empty authfile   : mallory:wrong ACCEPTED
... server: session#2: Open (user=- addr=127.0.0.1:34410 remotes=127.0.0.1:18081:127.0.0.1:18080)

Notes

  • Found at 5ee6c74 with an Antithesis test that rewrites the authfile under a running server while clients log in and open tunnels.
  • Related: TASKS.md notes that Len()==0 means allow-all (the "Panic race" entry), and a
    similar silent disable for --auth without a colon, but not a reload to an empty authfile.
    #171 and #549 cover removed users, not an empty file.
  • A possible fix: decide "auth enabled" from whether --authfile or --auth was given,
    not from the current user count, so an empty authfile refuses every login.
Lingua principale
Go
Stelle
16.8k
Fork
1.6k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di jpillora/chisel

Tutte le issue di jpillora/chisel

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.