Stateful guard misreads curl flags: `curl -f` GET is refused, `--json` / `-d@file` / `-T` POSTs skip the lease
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 30/100
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
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"}' URLcurl --json '{...}' URL,curl --data-ascii a=1 URLcurl -T shell.php URL,curl --upload-file shell.php URLwget --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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di BaaRai/ARTEX
-
Task retarget keeps the old host in task scope and adds the new host in a form that matches nothingForse già presa @chaitanya0305 l’ha presa oggi. Apertabug P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
BaaRai/ARTEX#652 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
A finding reported with severity "High" is stored as-is, so it is missing from severity counts and min_severity channels drop itForse già presa @chaitanya0305 l’ha presa oggi. Apertabug P2
Difficoltà 3/5 1-2 giorni Idoneità per principianti 22/100
BaaRai/ARTEX#650 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
feature
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
BaaRai/ARTEX#648 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
question
Difficoltà 4/5 1-2 giorni Idoneità per principianti 20/100
BaaRai/ARTEX#620 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
TrojanApertaquestion
Difficoltà 2/5 1-3 ore Idoneità per principianti 38/100
BaaRai/ARTEX#614 · 1 commento · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di BaaRai/ARTEX
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
compiler-explorer/compiler-explorer#9710 ·
I maintainer di solito rispondono entro 1 giorno
-
Add govulncheck workflowApertaenhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
losisin/helm-values-schema-json#437 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
kubernetes-sigs/controller-runtime#3704 ·
I maintainer di solito rispondono entro 1 giorno