Fix lua tostring exposing heap addresses space by skaslev · Pull Request #16031 · redis/redis · GitHub
Skip to content

Fix lua tostring exposing heap addresses space - #16031

Open
skaslev wants to merge 1 commit into
redis:unstablefrom
skaslev:lua-tostring-fix-port
Open

skaslev wants to merge 1 commit into
redis:unstablefrom
skaslev:lua-tostring-fix-port

Conversation

@skaslev

@skaslev skaslev commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Prevent Lua’s default tostring from exposing process memory addresses. Object values now return strings such as table: <opaque> and function: <opaque>.

Behavior

  • Covers tables, functions, threads, and userdata in EVAL and Redis Functions.
  • Preserves scalar conversions and custom __tostring behavior.
  • Leaves debugger address output unchanged.
  • Different objects of the same type now produce identical default strings.

Testing

  • Added regression coverage for address suppression, scalar conversions, and custom metamethods.
  • Server build succeeded.
  • All 12 targeted scripting and debugger checks passed.

(cherry picked from commit 3d18eb1b71daa112918a312fc7a4b9b36677dce0)


Note

Medium Risk
Changes observable Lua tostring output in the scripting sandbox (security hardening); behavior is narrow and covered by new tests but may affect scripts that relied on pointer strings.

Overview
Hardens the embedded Lua sandbox by changing default tostring for non-scalar values (tables, functions, threads, userdata, etc.) from type: 0x… to type: <opaque>, so EVAL/Redis Functions scripts cannot read process heap addresses.

Scalar tostring behavior and custom __tostring metamethods are unchanged. Regression tests in scripting.tcl cover opaque output for common object types, scalar conversions, metamethod success/errors, and newproxy userdata when lua-enable-deprecated-api is enabled.

Reviewed by Cursor Bugbot for commit 29dd0da. Bugbot is set up for automated code reviews on this repo. Configure here.

@skaslev
skaslev requested a review from YaacovHazan October 21, 2026 12:38
@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants