Skip to content

Add service matching to LayerGuard positioning - #5651

Draft
Elutrixx wants to merge 5 commits into
CactuseSecurity:developfrom
Elutrixx:feature/5629-layerguard-service-matching
Draft

Elutrixx wants to merge 5 commits into
CactuseSecurity:developfrom
Elutrixx:feature/5629-layerguard-service-matching

Conversation

@Elutrixx

@Elutrixx Elutrixx commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • include services when selecting a Check Point LayerGuard for rule positioning
  • require every requested service to be covered by the LayerGuard; Any remains universal
  • distinguish address mismatches from service mismatches in the returned error

Why

LayerGuard selection previously considered only the source/destination zone pair. That works for the customer this positioning algorithm was originally built for because their LayerGuards use Any as the service. Other installations may have multiple address-compatible LayerGuards that are distinguished by service, so ignoring services can select the wrong guard.

The existing importer already identifies LayerGuard rules. This change uses that imported distinction and the services on those rules; it does not introduce a separate importer or marker.

Matching behavior

The effective requested services are resolved after applying ticket changes and expanding service groups. A LayerGuard matches only when it contains all requested services. Service containment uses protocol and destination-port ranges, while Any covers every service. Unresolved or ambiguous service data fails closed instead of producing a potentially unsafe match.

Failures now distinguish between:

  • no LayerGuard matching the requested source and destination
  • an address-compatible LayerGuard exists, but its services do not cover the request

Verification

  • solution build: 0 warnings, 0 errors
  • test suite: 10,843 passed, 30 skipped, 0 failed
  • added focused coverage for service resolution, containment, snapshots, and mismatch reporting

Closes #5629

@Elutrixx
Elutrixx requested a review from tpurschke November 5, 2026 13:41
@tpurschke

This comment has been minimized.

@Elutrixx

This comment has been minimized.

@Elutrixx
Elutrixx marked this pull request as draft November 18, 2026 19:55

Elutrixx commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Review summary

Round 3 of max. 5. Deep review of PR head fbd7a5116b7044149aa008dce766b6dbcc4ea744, using direct diff/source-to-sink inspection plus reduced-tier mechanical scans.

The ~1,221 added/changed production lines are not uniformly overengineered. The containment evaluator, fail-closed imported-data mapping, fixed-import query validation, and typed positioning contracts each carry distinct invariants. The main simplification opportunity is concentrated in the 525-line service resolver, which copies the existing network resolver's ticket/group state machine. That code was already present in the earlier reviewed head, so Round 3 policy does not permit adding a new medium/low finding for it; the requested architecture assessment is recorded separately below.

Primary judgment: OpenAI Codex (GPT-5-based session; reasoning setting not exposed). Delegated on gpt-6.2-sol / low reasoning: GitHub metadata/history/check collection, mechanical coding-guideline/test/localization checks, and reuse/call-graph evidence. Review-token usage could not be measured because this session exposes no direct usage figure, per-request transcript counts, or scoped provider usage API; the 1M deep-review ceiling was enforced through the proxy limits (3 delegated dispatches, changed files plus direct callers/contracts/tests, no repeated diff/history fetch).

Number Criticality Confidence Status Subject
F1 🟠 medium 🟢 high ✅ fixed Missing imported protocol now remains unresolved instead of invalidating the snapshot
F2 🟠 medium 🟡 medium ⏸️ deferred Ticket group expansion lacks a total-work/leaf bound (#5759)
F3 🟡 low 🟢 high ✅ fixed Inline collection arguments were removed

Recommendations

Fix in this PR

  • None from this review round.

Create follow-up issue

  • F2 is already tracked and deferred in #5759.
  • The maintainability follow-up is tracked in #5761: Improve resolver maintainability by sharing ticket group-state handling.

No new reportable findings under the Round 3 rules.

Requested simplification assessment (not a new finding)

Tracked in #5761. The goal is to centralize shared workflow policy so future changes stay consistent and easier to review; reduced duplication is an expected side effect rather than a line-count target.

The new service resolver catalog loading, recursive ticket-group folding, member mutation logic, and identity matching/indexing mirror the corresponding network-resolver regions at lines 99–169, 216–283, 286–340, and 420–487. The Matches implementations are identical.

The duplicated policy includes identity precedence, deterministic task ordering, modify-baseline loading, create/modify/delete folding, ambiguity behavior, recursion/cycle handling, and catalog lookup rules. That is a credible divergence risk, not merely an aesthetic complaint. The useful extraction seam is the domain-neutral projection of ordered workflow group state into an effective member set/lookup identity. Address normalization, service parsing, catalog DTO mapping, and failure translation should remain explicit adapters. A generic resolver base with many callbacks would merely move the overengineering into a more expensive cupboard.

Two small cleanup observations, also unchanged since the earlier reviewed head and therefore not new Round 3 findings:

  • H5195 still describes source/destination-only selection, although service coverage is now part of the match. The developer documentation is correct; localized setting help and the current What's New bullet should eventually be aligned.
  • The guard GraphQL fragment selects svc_uid and svc_name for top-level and flattened services, and ServiceWire deserializes both, but containment never reads either field.

Prior finding verification

  • F1 fixed: both direct and flattened services now route through TryAddServiceLeaf; a missing protocol marks the scope unresolved, while malformed ports still fail closed. The dedicated direct and flattened regression tests passed.
  • F2 deferred: unchanged disposition; tracked in Bound and memoize ticket-group expansion #5759.
  • F3 fixed: the prior inline empty collection argument is now the static kNoCatalogGroups; the current diff scan found no newly added direct inline-array arguments.

Verification

  • git diff --check 16ad25c9...fbd7a511: clean.
  • Focused positioning tests: 279 passed, 0 failed.
  • Full C# unit suite: 11,749 passed, 30 skipped, 0 failed.
  • Current GitHub CodeQL workflow: successful.
  • FWO Test Install is still in progress. The Sonar bot comment reports one new issue/failed quality gate; its dashboard issue was not available in the review evidence and should be checked before merge.

Security coverage

Verified: the new path is internal workflow-triggered positioning rather than a new endpoint. Attacker-controlled/request-controlled workflow elements and imported firewall data were traced through ticket/management scoping, typed GraphQL variables, fixed-import lifetime checks, immutable normalized service values, three-state containment, and category-only failure persistence. Negative tests cover malformed protocol/port data, unexpected association negation, out-of-import rows, missing/ambiguous groups, unresolved terms, cancellation, and fail-closed competing candidates. CodeQL completed successfully.

Not verified / residual risk: no live Hasura test exercised very large nested service-group responses. The graph reader bounds rulebase links, rulebases, and rules, but the guard query's nested service collections are not independently capped; F2 separately tracks the requested-side expansion bound. The installer workflow had not completed at review time.

Not applicable to this diff: authentication/session handling, role/owner permission changes, browser rendering/HTML encoding, CSRF/CORS, file/archive parsing, command execution, remote URL fetching, secrets/cryptography, dependency changes, schema migrations, installer defaults, and state-transition authorization.

@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants