Skip to content

Various non-security fixes#4512

Open
buixor wants to merge 6 commits into
waf-challenge-modefrom
waf-challenge-mode_oob+concurrent-access
Open

Various non-security fixes#4512
buixor wants to merge 6 commits into
waf-challenge-modefrom
waf-challenge-mode_oob+concurrent-access

Conversation

@buixor

@buixor buixor commented Jun 12, 2026

Copy link
Copy Markdown
Contributor
  • Deepcopy of appsectempresponse to avoid concurrent map access
  • Ensure RequestChallenge can only be called from the relevant phases (inband.post_eval and on_challenge - which is inband too)

Copilot AI review requested due to automatic review settings June 12, 2026 12:45
@github-actions

Copy link
Copy Markdown

@buixor: There are no 'kind' label on this PR. You need a 'kind' label to generate the release automatically.

  • /kind feature
  • /kind enhancement
  • /kind refactoring
  • /kind fix
  • /kind chore
  • /kind dependencies
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

@github-actions

Copy link
Copy Markdown

@buixor: There are no area labels on this PR. You can add as many areas as you see fit.

  • /area agent
  • /area local-api
  • /area cscli
  • /area appsec
  • /area security
  • /area configuration
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses two correctness issues in the AppSec pipeline: (1) avoiding concurrent map access by ensuring the HTTP handler receives an isolated copy of the in-band response, and (2) constraining challenge issuance so SendChallenge() can only be used from the intended in-band hook stages.

Changes:

  • Added AppsecTempResponse.Clone() and updated the appsec runner to send a cloned response to the handler to prevent in-band/out-of-band races.
  • Removed SendChallenge() from the pre_eval expr environment and added a runtime guard to reject out-of-band SendChallenge() calls.
  • Extended/adjusted tests to validate cloning behavior, hook exposure restrictions, and challenge flow behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/appsec/waf_helpers.go Removes SendChallenge from pre_eval expr env (compile-time restriction).
pkg/appsec/response_clone_test.go Adds tests validating deep clone behavior and race prevention.
pkg/appsec/patcher.go Updates comment around challenge runtime callee detection.
pkg/appsec/patcher_test.go Adjusts test to reference SendChallenge() from post_eval (where it is exposed).
pkg/appsec/challenge/challenge_test.go Fixes malformed-ticket test input to pass missing-field validation.
pkg/appsec/appsec.go Adds AppsecTempResponse.Clone() and enforces in-band-only SendChallenge() at runtime.
pkg/acquisition/modules/appsec/appsec_test.go Treats hook compilation/build failures as expected when expected_load_ok is false.
pkg/acquisition/modules/appsec/appsec_runner.go Sends cloned in-band response to handler; skips OOB evaluation when a challenge is served.
pkg/acquisition/modules/appsec/appsec_hooks_test.go Updates hook tests from pre_eval to post_eval and adds coverage for new restrictions/flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/appsec/response_clone_test.go Outdated
Comment on lines +71 to +74
for range 1000 {
_, body := rt.GenerateResponse(sent, rt.Logger)
_, _ = json.Marshal(body)
}
Comment thread pkg/appsec/response_clone_test.go Outdated
Comment on lines +80 to +82
for i := range 1000 {
_ = rt.SetChallengeHeader(state, "X-Oob", string(rune('a'+i%26)))
}
Comment on lines +520 to +523
// A challenge was served, so the request never reaches the backend;
if state.RequireChallenge {
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants