Repository navigation
Conversation
Up to libModSecurity 3.0.17, m.getvars() ignores its transformation parameter, so the m.getvars() example in SecRuleScript doesn't work as written (owasp-modsecurity/ModSecurity#3737). Add a note to the Lua section of SecRuleScript that says so and gives the workaround, and that lists the other differences in how 3.0.17 and 2.9.15 and earlier handle the list of transformation names: a long list can crash the process, a table entry fails the script and a number entry is taken as a name, and, in libModSecurity, "none" doesn't start the list over and a name with a colon aborts the process. Refs owasp-modsecurity/ModSecurity#3737
fzipi
approved these changes
Nov 2, 2026
fzipi
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @airween. I checked each statement against v3/master, v2/master and the two fix PRs, and the note matches. LGTM.
m.getvars()ignores its transformations in v3. On v3/master,Lua::getvars()never reads argument 2, so the example above gets<SCRIPTuntransformed. With #3738,lowercasethenhtmlEntityDecodegives<script, which is what thelua-tfn-getvars-table.luacase checks.- Long lists. Neither engine pops the entry from
lua_rawgeti()before the fixes. "More than 20 names can crash" is the right wording, since the crash in the tests came only at 100 (v3) and 1000 (v2). - Tables and numbers. Before the fixes,
luaL_checkstring()raises "bad argument" for a table and converts a number to a name. Both fixes checklua_type() != LUA_TSTRINGand log at level 8, so "skip both and write a debug log message" holds in both engines. "none"and names with a colon (v3 only). v3/mastercontinues on"none"instead of clearing the list."t:lowercase:"makesAction::set_name_and_payload()callat(0)on an empty payload, which throwsstd::out_of_range. #3738 clears the list and logs "Invalid transformation function" for a name with:.
Approving on the same condition as the description: merge only after #3738 and #3739, and check that "3.0.17 and earlier" and "2.9.15 and earlier" still match the releases they land in.
Member
Author
|
Thanks @fzipi. I'll merge it after #3738 and #3739, and check the version numbers then. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Document the Lua transformation list fixes in owasp-modsecurity/ModSecurity#3738 (libModSecurity) and owasp-modsecurity/ModSecurity#3739 (ModSecurity v2), for owasp-modsecurity/ModSecurity#3737.
m.getvars()ignores its transformations, so them.getvars()example in the same section doesn't find<scriptin<SCRIPT; the workaround is to transform in the script or to usem.getvar();"none"doesn't start the list over, and a name with a colon, such as"lowercase:", aborts the process.Further comments
m.getvars()example, so that it doesn't conflict with docs: RULE can't be read from Lua in libModSecurity v3 #6 and docs: document where Lua m.log() messages goes #7, which add notes in the same section.LUA_MINSTACK, the number of free stack slots a C function gets. The crash isn't certain just above it: in the regression tests, libModSecurity crashed with 100 entries and the ModSecurity v2 Apache child with 1000.AI disclosure
Made with help of Claude Code, Opus 5.5