Skip to content

fw: tighten pre-flow hook scopes and apply flow scope to packet drop v1 - #16129

Open
lukashino wants to merge 2 commits into
OISF:mainfrom
lukashino:bug/fw-packet-policy-flow-scope-v1
Open

fw: tighten pre-flow hook scopes and apply flow scope to packet drop v1#16129
lukashino wants to merge 2 commits into
OISF:mainfrom
lukashino:bug/fw-packet-policy-flow-scope-v1

Conversation

@lukashino

Copy link
Copy Markdown
Contributor

The commits cover these Redmine tickets:

Describe changes:

  • flow scope got excluded from pre-flow hook (as flow object is not available when hook is evaluated)
  • flow policy is applied when a packet's default policy is hit

SV_BRANCH=OISF/suricata-verify#3327

Lukas Sismis added 2 commits August 27, 2026 13:39
The packet default policy runtime only applied the action scope for
`accept`. For `drop:flow` and `reject:flow` it dropped the packet and left
the flow untouched, so the flow scope had no eiffect.

Ticket: 8969
Action scopes for packet hook default policies were validated per hook
class, so `flow` was accepted for every packet hook. The pre_flow hook is
a special case as it is evaluated before Suricata obtains a flow record.

This commit adds extra validation to scope parsing for the pre_flow
hook.

Ticket: 8967
Copilot AI lite review requested due to automatic review settings August 27, 2026 12:55

Copilot AI left a comment

Copy link
Copy Markdown

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 refines Suricata’s firewall default-policy handling by (1) tightening which action scopes are allowed for the pre-flow packet hook (since a Flow may not exist yet) and (2) ensuring flow-scoped default packet drops persist by marking the Flow when the default policy is hit.

Changes:

  • Add a dedicated policy-class for packet pre-flow hooks to disallow flow action scope during policy resolution.
  • When the default packet policy is drop:flow and a flow exists, set FLOW_ACTION_DROP | FLOW_ACTION_BY_FIREWALL on the flow so subsequent packets are dropped at flow-level.
  • Route pre-flow packet policy loading through the new policy-class so invalid scopes are rejected with appropriate hints.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/detect.c Applies flow-scoped default packet drops to the flow by setting flow drop flags when applicable.
src/detect-parse.c Introduces a pre-flow packet policy class and scope set; uses it when resolving the pre-flow default policy.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/detect.c
@lukashino lukashino changed the title Tighten pre-flow hook scopes and apply flow scope to packet drop v1 fw: tighten pre-flow hook scopes and apply flow scope to packet drop v1 Aug 27, 2026
@suricata-qa

Copy link
Copy Markdown

Information: QA ran without warnings.

Pipeline = 33414

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.04%. Comparing base (7c66954) to head (12c423d).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16129      +/-   ##
==========================================
- Coverage   83.06%   83.04%   -0.02%     
==========================================
  Files        1004     1004              
  Lines      277376   277421      +45     
==========================================
- Hits       230389   230371      -18     
- Misses      46987    47050      +63     
Flag Coverage Δ
fuzzcorpus 61.49% <0.00%> (-0.01%) ⬇️
livemode 18.40% <0.00%> (-0.02%) ⬇️
netns 22.82% <33.33%> (-0.06%) ⬇️
pcap 45.38% <0.00%> (-0.05%) ⬇️
suricata-verify 67.12% <100.00%> (-0.04%) ⬇️
unittests 58.53% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants