-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement libModsecurity as WASM extension for envoy #17463
Comments
@M4tteoP exciting! As you correctly noted, all the dependencies must be build for the Wasm architecture and linked into the final Wasm module (same as linking static executables on any other platform) in order for ModSecurity to work. See: https://emscripten.org/docs/compiling/Building-Projects.html#using-libraries Because of that, I recommend starting from the minimal ModSecurity build, which depends only on the PCRE:
and once you have it working (you need to build PCRE), keep adding one dependency at a time. Basically, you need to add support for static linking in ModSecurity, and then Emscripten would take care of Wasm. |
And I successfully build the modsecurity wasm library with removing some unsupport system call based on the minimal ModSecurity (only PCRE) You need a WASM PCRE and ModSecurity library when you build your own wasm filter in envoy bazel toolchain. |
@leyao-daily Cool good job. I imagine ModSecurity by default uses C++ exceptions so maybe we have to patch it so it does not expect Envoy to handle emscripten exceptions (See proxy-wasm/proxy-wasm-cpp-host#116). Could you share the list of the system calls which must be supported in Envoy (or even wasi-libc)? |
@mathetake Yes. The system calls I meet until now are list:
And calls may request support:
|
Most of them are needed when ModSecurity process with the file system. |
Your project sounds exiting! Actually, I've done a similar thing and I'd like to point out that proxy-wasm/proxy-wasm-cpp-host#143 has to be resolved in order to make a reliable ModSecurity WAF with proxy-wasm. @PiotrSikora Most security rules, including OWASP core rule set, need to inspect the request body to decide whether to accept or reject the request header. Thus, it needs the ability to pause the request header until it handles the request body. |
@leyao-daily @PiotrSikora, thank you all for your interest in the project and for all the provided valuable information! I succeeded in compiling both PCRE and the minimal ModSecurity.
The minimal version of the extension just includes few Modsec header files
and creates a
Thanks again for the support, even just a .cc example file would be awesome. |
Hi, what is your emscripten toolchain version? You should use 2.0.7 which is used in envoy. @M4tteoP |
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions. |
I'm working on porting the library libModsecurity to WASM architecture to use it as a envoy extension for istio. The idea behind this project is to experiment with a granular and easily configurable security control (a WAF) that can be put in front of any needed pod.
Emconfigure
andemmake
tools from Emscripten seems very promising to accomplish this task, however, I'm stuck on header inclusion errors.Action performed are just:
./build.sh
emconfigure ./configure
emmake make
Resulting in this error:
Based on this and this issues, I'm aware that:
-I/usr/include
-I/usr/include/libxml2
should be removed from the command. But I do not understand deep enough all the build process to figure out the correct fix that I have to make.I provide some details about my environment:
OS: Ubuntu 20.04.2
emsdk: 2.0.25
ModSecurity: v3.0.5-2-g465db29b
I also post the result of
emconfigure ./configure
to show all the dependencies installed:Thanks for any support!
The text was updated successfully, but these errors were encountered: