Skip to content

fix: run user-supplied Lua in a sandboxed state - #545

Merged
gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:fix/lua-sandboxed-state
Nov 21, 2026
Merged

gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:fix/lua-sandboxed-state

Conversation

@gianlucam76

Copy link
Copy Markdown
Member

Lua scripts coming from Sveltos CRs ran in a state with the io and os libraries fully open, so a script could read files or environment variables of the pod. Use libsveltos NewSandboxedState, which only keeps the base, package, table, string, math and coroutine libraries and the time related functions of os (time, date, clock, difftime).

Add tests running scripts that call io.open and os.getenv through the real code paths and expect them to fail.

Lua scripts coming from Sveltos CRs ran in a state with the io and os
libraries fully open, so a script could read files or environment variables
of the pod. Use libsveltos NewSandboxedState, which only keeps the base,
package, table, string, math and coroutine libraries and the time related
functions of os (time, date, clock, difftime).

Add tests running scripts that call io.open and os.getenv through the real
code paths and expect them to fail.
@gianlucam76
gianlucam76 force-pushed the fix/lua-sandboxed-state branch from a6d9397 to 9bc5f7e Compare November 21, 2026 17:36
@gianlucam76
gianlucam76 merged commit 577578a into projectsveltos:main Nov 21, 2026
10 checks passed
@gianlucam76
gianlucam76 deleted the fix/lua-sandboxed-state branch November 21, 2026 17:56
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