AppSec: query string arguments are added to ARGS_GET twice (&ARGS_GET:x is 2 for ?x=1)

Aperta
#4,812 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
60/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, go
Ambito
backend, security

Direzione di ricerca

Start in pkg/acquisition/modules/appsec/appsec_runner.go around lines 206-212, where request.Args is added with AddGetRequestArgument before ProcessURI is called with the same URI. Confirm that ProcessURI already fills ARGS_GET from the query string, then check that removing the loop leaves body arguments unaffected. Done when /?foo=1 gives &ARGS_GET:foo = 1 in a test, the reproduction in the issue returns 200, 403, 200, and the existing appsec tests still pass.

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

Descrizione

kind/bug needs/triage version/1.8.2
What happened?

In AppSec, every argument of the query string appears twice in ARGS_GET, and so also in ARGS, ARGS_GET_NAMES and ARGS_NAMES. For a request to /?foo=1, &ARGS_GET:foo is 2. For /?foo=1&foo=2 it is 4.

This has two consequences:

  • A rule that counts a query argument never matches as written. The CRS WordPress rule-exclusion plugin is one example. Its exclusions for the REST API called as /index.php?rest_route=… are guarded by SecRule &ARGS:rest_route "@eq 1", and that guard never holds under AppSec. On a WordPress site with plain permalinks (WordPress's default), saving a post that contains code is then blocked with a 403, even though the plugin is on. We measured this with CRS 4.25 LTS and the plugin 1.2.0, loaded through seclang_files_rules.
  • A rule that counts how often a parameter name appears sees every query parameter twice. The pattern of CRS rules 921170/921180 (HTTP parameter pollution, paranoia level 3) blocks a request that has a single query parameter. See the reproduction below.

The cause is in pkg/acquisition/modules/appsec/appsec_runner.go, lines 206-212 (v1.8.2, unchanged on master):

  1. The runner adds request.Args with AddGetRequestArgument. NewParsedRequestFromRequest parsed those arguments from the query string.
  2. It then calls ProcessURI with the same URI.
  3. Coraza's ProcessURI extracts the GET arguments from the query string again (tx.ExtractGetArguments(parsedURL.RawQuery)).
for k, v := range request.Args {
    for _, vv := range v {
        state.Tx.AddGetRequestArgument(k, vv)
    }
}

state.Tx.ProcessURI(request.URI, request.Method, request.Proto)
What did you expect to happen?

One query argument counts once, as in ModSecurity and in Coraza used on its own: &ARGS_GET:foo is 1 for /?foo=1.

How can we reproduce it (as minimally and precisely as possible)?

Use the official image crowdsecurity/crowdsec:v1.8.2 with these three files.

/etc/crowdsec/appsec-rules/args-count.yaml:

name: repro/args-count
seclang_rules:
  - SecRule &ARGS_GET:foo "@eq 2" "id:1999001,phase:1,deny,status:403,log,msg:'ARGS_GET:foo counted twice'"
  - SecRule &ARGS_GET:bar "@eq 1" "id:1999002,phase:1,deny,status:403,log,msg:'ARGS_GET:bar counted once'"
  - SecRule ARGS_GET_NAMES "@rx ^baz$" "id:1999003,phase:1,pass,nolog,setvar:'tx.paramcounter_%{MATCHED_VAR_NAME}=+1'"
  - SecRule TX:/paramcounter_.*/ "@gt 1" "id:1999004,phase:1,deny,status:403,log,msg:'parameter seen more than once (%{MATCHED_VAR_NAME})'"

/etc/crowdsec/appsec-configs/args-count.yaml:

name: repro/args-count
default_remediation: ban
inband_rules:
  - repro/args-count

/etc/crowdsec/acquis.d/appsec.yaml:

source: appsec
listen_addr: 0.0.0.0:7422
appsec_configs:
  - repro/args-count
routines: 1
labels:
  type: appsec

Start the container with BOUNCER_KEY_repro=<key> and the three files mounted. For a throwaway container we also set DISABLE_ONLINE_API=true and CROWDSEC_BYPASS_DB_VOLUME_CHECK=true. Then send these requests to AppSec:

ask() {
  curl -s -o /dev/null -w '%{http_code}\n' -H "X-Crowdsec-Appsec-Api-Key: $KEY" -H 'X-Crowdsec-Appsec-Ip: 192.0.2.10' \
    -H "X-Crowdsec-Appsec-Uri: $1" -H 'X-Crowdsec-Appsec-Host: example.test' -H 'X-Crowdsec-Appsec-Verb: GET' http://127.0.0.1:7422/
}
ask '/?foo=1'   # 403: &ARGS_GET:foo is 2
ask '/?bar=1'   # 200: &ARGS_GET:bar "@eq 1" never matches
ask '/?baz=1'   # 403: "parameter seen more than once (TX:paramcounter_args_get_names:baz)"

The log shows WAF block: ARGS_GET:foo counted twice and WAF block: parameter seen more than once (TX:paramcounter_args_get_names:baz). The expected answers are the other way round: 200, 403, 200.

Anything else we need to know?

Removing the AddGetRequestArgument loop should fix it, since ProcessURI already fills ARGS_GET from the same query string.

Arguments in a urlencoded body are not affected: we measured &ARGS_POST:x as 1 for one body argument.

Crowdsec version
version: v1.8.2-3d369d64
Codename: alphaga
BuildDate: 2026-10-29_09:53:07
GoVersion: 1.27.3
Platform: docker

We first saw it with the official 1.8.2 Debian package on Debian 13, with AppSec behind nginx.

OS version

Official Docker image, on a Debian 13 host.

Enabled collections and parsers

The image's defaults. Only the AppSec configuration above takes part in the test.

Acquisition config

See above.

/kind bug

Lingua principale
Go
Stelle
15.1k
Fork
726
Merge medio
4g 23h
PR unite (30g)
27

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 crowdsecurity/crowdsec

Tutte le issue di crowdsecurity/crowdsec

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.