Skip to content

Document Lua transformation list fixes in m.getvar()/m.getvars() - #8

Open
airween wants to merge 1 commit into
mainfrom
docs/lua-getvars-transformations
Open

airween wants to merge 1 commit into
mainfrom
docs/lua-getvars-transformations

Conversation

@airween

@airween airween commented Nov 2, 2026

Copy link
Copy Markdown
Member

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.

  • Configuration directives, SecRuleScript: a new note at the end of the Lua section:
    • in libModSecurity 3.0.17 and earlier, m.getvars() ignores its transformations, so the m.getvars() example in the same section doesn't find <script in &LT;SCRIPT; the workaround is to transform in the script or to use m.getvar();
    • in those versions and in ModSecurity 2.9.15 and earlier: a list with more than 20 names can crash the process; a table entry fails the script with "bad argument", and a number is taken as a name;
    • in libModSecurity only: "none" doesn't start the list over, and a name with a colon, such as "lowercase:", aborts the process.

Further comments

AI disclosure

Made with help of Claude Code, Opus 5.5

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
@airween
airween requested a review from fzipi November 2, 2026 14:06

@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 @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 &LT;SCRIPT untransformed. With #3738, lowercase then htmlEntityDecode gives <script, which is what the lua-tfn-getvars-table.lua case 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 check lua_type() != LUA_TSTRING and 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/master continues on "none" instead of clearing the list. "t:lowercase:" makes Action::set_name_and_payload() call at(0) on an empty payload, which throws std::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.

@airween

airween commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

Thanks @fzipi. I'll merge it after #3738 and #3739, and check the version numbers then.

@airween airween added the do not merge DO NOT MERGE!!! label Nov 2, 2026

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

do not merge DO NOT MERGE!!!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants