Skip to content

Fix issue when more than 65536 are delivered by RC - #4122

Closed
estringana wants to merge 9 commits into
masterfrom
estringana/allow-more-than-65536-ips
Closed

Fix issue when more than 65536 are delivered by RC#4122
estringana wants to merge 9 commits into
masterfrom
estringana/allow-more-than-65536-ips

Conversation

@estringana

@estringana estringana commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Description

Fix: prevent crash when ASM_DATA IP denylist exceeds 65,535 entries

libddwaf v2.x uses uint16_t for WafArray capacity, which hard-caps any single array at 65,535 entries. When Remote Config delivers an ASM_DATA payload whose rules_data[*].data array exceeds this limit (e.g. the system-test scenario APPSEC_BLOCKING_FULL_DENYLIST with 65,536 IPs), the helper process panics trying to convert the array length to u16

Since the WAF cannot enforce more than 65,535 IP entries regardless, the correct fix is to truncate the array to the limit rather than attempt to register entries the WAF cannot use.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Aug 20, 2026

Copy link
Copy Markdown

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

🚦 6 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-php | test_extension_ci: [8.2] — 🔧 Needs a code fix, caused by this PR

View in Datadog · View in GitLab

DataDog/apm-reliability/dd-trace-php | test_extension_ci: [8.5] — 🔧 Needs a code fix, caused by this PR

View in Datadog · View in GitLab

DataDog/apm-reliability/dd-trace-php | merge-gate

View in Datadog · View in GitLab

View all 6 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 94.12%
Overall Coverage: 60.72% (+0.04%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 382523e | Docs | View more details | Give us feedback!

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 failures when Remote Config delivers an ASM rules_data array that exceeds libddwaf’s per-array entry limit (u16), by splitting large ASM_DATA payloads into multiple smaller WAF configs and tracking/removing the extra chunk configs across updates.

Changes:

  • Add per-RC-path tracking (extra_chunk_paths) so extra WAF chunk configs are removed when the original RC config is removed or replaced.
  • Split large rules_data[*].data arrays into chunked JSON payloads and apply them as multiple WAF configs under derived config paths.
  • Add unit tests covering “no split”, “split required”, and “no rules_data passthrough” behaviors.

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

Comment thread appsec/helper-rust/src/service.rs Outdated
Comment thread appsec/helper-rust/src/service.rs Outdated
Comment thread appsec/helper-rust/src/service.rs Outdated
Comment on lines 646 to 650
if i == 0 {
all_diagnostics.push((rc_path.clone(), diagnostics));
last_result = upd_result;
}
*waf_changed = true;
}
Comment thread appsec/helper-rust/src/service.rs Outdated
estringana and others added 3 commits August 21, 2026 11:42
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

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

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

Suppressed comments (2)

appsec/helper-rust/src/service.rs:634

  • Errors from add_or_update_config are only captured/returned for the first chunk (i == 0). If any later chunk fails to apply, the error is silently ignored and the RC update still reports success, leaving the WAF in a partially-updated state.
                    let upd_result = self.waf.add_or_update_config(
                        &chunk_path,
                        &waf_obj,
                        Some(&mut diagnostics),
                    );

appsec/helper-rust/src/service.rs:607

  • This branch handles products "ASM_DD", "ASM", and "ASM_DATA", but the added context says "Failed to split ASM_DATA". When a non-ASM_DATA config fails to parse/split, the error message will be misleading; include the product name (or use a product-agnostic message).
                let chunks = split_asm_data_if_needed(data)
                    .with_context(|| format!("Failed to split ASM_DATA for {:?}", rc_path))?;

Comment thread appsec/helper-rust/src/service.rs Outdated
estringana and others added 2 commits August 21, 2026 11:51
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@estringana
estringana marked this pull request as ready for review August 21, 2026 13:05
@estringana
estringana requested a review from a team as a code owner August 21, 2026 13:05

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0be5d37cb8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread appsec/helper-rust/src/service.rs Outdated
Comment thread appsec/helper-rust/src/service.rs Outdated
Comment thread appsec/helper-rust/src/service.rs Outdated
@estringana estringana closed this Aug 24, 2026
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.

2 participants