Stateful guard misreads curl flags: `curl -f` GET is refused, `--json` / `-d@file` / `-T` POSTs skip the lease

Aperta
#644 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@chaitanya0305 ci sta già lavorando.

Dal 28/11/2026.

  • #645 di @chaitanya0305 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go, shell
Ambito
security

Direzione di ricerca

The two regexes mutatingMethodFlagRe and mutatingBodyFlagRe are in intercept/stateful_guard.go around lines 479-480, and ClassifyHTTPAction is the entry point the reproduction calls. Read intercept/risk.go for how it already treats --data*, -T and --upload-file. Done means the six reproduction commands return false, false, true, true, true, true. Note that PR #645 is already open against this issue, so check it before starting.

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

Descrizione

bug P1

The stateful target guard (intercept/stateful_guard.go, #623/#627) decides whether a Bash or custom-tool call is mutating with two regexes. Both are wrong in ordinary usage.

Read-only calls treated as mutating. The regexes use (?i), so -d also matches curl's -D (dump headers) and -F also matches -f (fail on HTTP error). A first curl -f https://target/health on a host is refused with pre-mutation baseline required, and it is not recorded as the baseline.

Mutating calls treated as read-only. A short flag must be followed by a space or =, and only a few long flags are listed. These all send a body and are classified as read-only:

  • curl [email protected] URL, curl -d'{"role":"admin"}' URL
  • curl --json '{...}' URL, curl --data-ascii a=1 URL
  • curl -T shell.php URL, curl --upload-file shell.php URL
  • wget --post-data 'a=1' URL, wget --method=DELETE URL

So they skip the baseline gate and the per-host mutation lease (two intents can mutate the same host at once), and RecordStatefulReadOnly records the mutation as the host's read-only baseline. intercept/risk.go already treats --data*, -T and --upload-file as uploads.

Reproduce
// in package intercept
for _, c := range []string{
	`curl -f https://t.example/health`,
	`curl -s -D - https://t.example/`,
	`curl --json '{"role":"admin"}' https://t.example/api/users`,
	`curl [email protected] https://t.example/api/users`,
	`curl -T shell.php https://t.example/upload/`,
	`wget --post-data 'a=1' https://t.example/api`,
} {
	in, _ := json.Marshal(map[string]string{"command": c})
	_, m := ClassifyHTTPAction("Bash", in, "", "")
	fmt.Println(m, c)
}

Output on main (e9659c8):

true  curl -f https://t.example/health
true  curl -s -D - https://t.example/
false curl --json '{"role":"admin"}' https://t.example/api/users
false curl [email protected] https://t.example/api/users
false curl -T shell.php https://t.example/upload/
false wget --post-data 'a=1' https://t.example/api

Expected: false, false, true, true, true, true.

Cause

intercept/stateful_guard.go:479-480:

mutatingMethodFlagRe = regexp.MustCompile(`(?i)(?:^|\s)(?:-X|--request)\s*=*\s*["']?(POST|PUT|PATCH|DELETE)\b`)
mutatingBodyFlagRe   = regexp.MustCompile(`(?i)(?:^|\s)(?:-d|--data|--data-raw|--data-binary|--data-urlencode|-F|--form)(?:\s|=)`)

(?i) covers the flag names, not only the method value, and the trailing (?:\s|=) rejects attached values.

Version: main at e9659c8.

A tested fix is ready on branch chaitanya0305:fix/stateful-guard-curl-flags.

Lingua principale
Go
Stelle
18.7k
Fork
7k
Merge medio
10h 41m
PR unite (30g)
342

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 BaaRai/ARTEX

Tutte le issue di BaaRai/ARTEX

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.