Skip to content

πŸ›‘οΈ Sentinel: [CRITICAL] Fix prefix-matching path traversal bypass in Lua sandbox#20

Open
mleem97 wants to merge 1 commit into
mainfrom
sentinel-fix-lua-path-traversal-11667858838311463278
Open

πŸ›‘οΈ Sentinel: [CRITICAL] Fix prefix-matching path traversal bypass in Lua sandbox#20
mleem97 wants to merge 1 commit into
mainfrom
sentinel-fix-lua-path-traversal-11667858838311463278

Conversation

@mleem97

@mleem97 mleem97 commented May 4, 2026

Copy link
Copy Markdown
Owner

🚨 Severity: CRITICAL

πŸ’‘ Vulnerability:
The Lua sandbox (GregIoLuaModule, LuaModuleLoader, LuaHotReload) relied on String.StartsWith to validate sandboxed file paths. Because the base paths (e.g., /mod/data) did not have a guaranteed trailing directory separator, an attacker could supply a path that begins with the exact string but maps to a different directory (e.g., /mod/data-secret). Since /mod/data-secret starts with /mod/data, the StartsWith check would incorrectly pass, granting the sandbox access to restricted files.

🎯 Impact:
A malicious or compromised Lua script could escape its designated sandbox (data folder or mod directory) to read, modify, or delete sensitive files in adjacent directories that shared the same string prefix, leading to arbitrary file read/write issues.

πŸ”§ Fix:
Updated the validation logic in the Lua layer:

  1. GregIoLuaModule.cs: Ensured dataDirFull appends a trailing directory separator before prefix matching, while still permitting an exact path match.
  2. LuaModuleLoader.cs: Ensured both the _modRoot and _sharedRoot directories use a trailing separator before calling StartsWith().
  3. LuaHotReload.cs: Ensured the _watchRoot directory appends a trailing separator before prefix matching.

βœ… Verification:

  • Ran the core test projects.
  • Compiled the project using dotnet build gregCore.csproj -c Release.
  • Verified the learning was appended to the sentinel.md journal.

PR created automatically by Jules for task 11667858838311463278 started by @mleem97

…Lua sandbox

Fixes a critical path traversal vulnerability in the Lua sandbox where `String.StartsWith` was used for path validation without ensuring the base directory ended with a directory separator. This allowed prefix-matching bypasses (e.g., `/mod/data-secret` validating against `/mod/data`).

Updated `GregIoLuaModule.cs`, `LuaModuleLoader.cs`, and `LuaHotReload.cs` to ensure directory separators are appended before path matching, and also permitted exact path equality where appropriate.

Added the corresponding learning to `.jules/sentinel.md`.
@google-labs-jules

Copy link
Copy Markdown

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

1 participant