Skip to content

ci: statically link MinGW runtime into x86 fuzzy.dll and add 32-bit pool test - #3611

Open
A13501350 wants to merge 2 commits into
owasp-modsecurity:v2/masterfrom
A13501350:ci/x86-test
Open

A13501350 wants to merge 2 commits into
owasp-modsecurity:v2/masterfrom
A13501350:ci/x86-test

Conversation

@A13501350

Copy link
Copy Markdown

Summary

Fixes #3599

The CI-produced x86 IIS module (fuzzy.dll, ssdeep) was built with MinGW gcc and imported the MinGW runtime DLLs (libgcc_s_dw2-1.dll -> libwinpthread-1.dll). These were not packaged in the MSI, so the x86 module failed to load in 32-bit application pools with error 126 (ERROR_MOD_NOT_FOUND), while the x64 module worked fine.

Fix

In .github/workflows/test-ci-windows.yml, build ssdeep with -static-libgcc so the MinGW runtime is statically linked into fuzzy.dll. The resulting x86 DLL is self-contained and loads cleanly in 32-bit application pools without needing the external MinGW runtime DLLs.

Regression test

Added a new Test IIS Module in 32-bit Application Pool step that:

  1. Verifies the globally-registered ModSecurity IIS (32bits) native module exists.
  2. Creates a dedicated 32-bit application pool and site, then confirms a request returns HTTP 200.
  3. Checks the Application event log for dll failed to load / error 126 entries.

The test was validated against the previous (broken) build: with the old dynamic-link build the 32-bit pool returned HTTP 503 (module failed to load) and the step correctly failed; with this fix it returns HTTP 200 and passes.

Validation

  • Fixed build: all jobs green, including the new 32-bit pool test (HTTP 200, no load errors).
  • Old build (temporary revert): the new 32-bit pool test correctly failed with unexpected status 503, confirming it reproduces and catches the x86 load issue.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 457ebcd5-5d4e-4692-bc17-de773f906051

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@airween airween added 2.x Related to ModSecurity version 2.x windows labels Sep 17, 2026

@fzipi fzipi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @A13501350, this is a nice, focused fix!

What I checked: I downloaded the x86 fuzzy.dll from the latest v2/master IIS run and from this PR's run and compared their import tables. On v2/master it imports libgcc_s_dw2-1.dll. With -static-libgcc it only imports KERNEL32.dll and msvcrt.dll. Across all DLLs in the x86 artifact, the only remaining imports are Windows system DLLs and the MSVC runtime, so no MinGW runtime is left in the chain. The x64 DLL is unaffected (UCRT api-ms-win-crt-* only). The new step logs PASS: 32-bit pool returned 200 in the test job.

A few comments, none blocking:

  1. (non-blocking) In the 32-bit pool step, $ErrorActionPreference = 'Stop' doesn't apply to native commands, and the appcmd calls go to Out-Null without a $LASTEXITCODE check. If add apppool or set app failed, the site's root app would stay on DefaultAppPool (64-bit), and the request on :8081 would still return 200, so the step would pass without touching the x86 module. Could you check $LASTEXITCODE after each appcmd call, and maybe assert that appcmd list wp shows a worker for ModSec32Test after the request?
  2. (non-blocking) A 200 proves the module loads, but not that it inspects traffic in the 32-bit pool. One detectable request against :8081, with the same expectation as the 64-bit step, would close that gap. Keep in mind that #3613 changes those expectations.
  3. (non-blocking, optional) A build-time guard in the ssdeep step would catch this class of regression earlier and more directly, e.g. objdump -p fuzzy.dll | grep -iE 'libgcc_s|libwinpthread' && exit 1.
  4. (non-blocking) The hunk also drops --build=i686-pc-mingw32 and CXXFLAGS="-O3". Both are fine (MINGW32 already targets i686 and fuzzy.dll is C only), but a line about it in the commit message would help future readers.
  5. FYI: this conflicts textually with #3613 in test-ci-windows.yml, since both add steps after Test IIS Module. I'm fine with landing this one first and rebasing #3613 on top.
  6. (non-blocking) The last CI run is from mid-August. Could you rebase onto current v2/master so we get a fresh IIS run before merging?

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

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

Labels

2.x Related to ModSecurity version 2.x windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants