Skip to content

Security/sandbox system commands rebased#1667

Merged
rocky merged 5 commits intomasterfrom
security/sandbox-system-commands-rebased
Jan 31, 2026
Merged

Security/sandbox system commands rebased#1667
rocky merged 5 commits intomasterfrom
security/sandbox-system-commands-rebased

Conversation

@rocky
Copy link
Member

@rocky rocky commented Jan 30, 2026

Revise #1660 Disallow various shell escape and OS/environment queries in a sandboxed environment. Rename SANDBOX variable MATHICS3_SANDBOX

@rocky rocky force-pushed the security/sandbox-system-commands-rebased branch from 0ef046d to 34b7dc9 Compare January 30, 2026 17:01
@rocky rocky force-pushed the security/sandbox-system-commands-rebased branch 2 times, most recently from 1698d35 to 0e08430 Compare January 30, 2026 19:07
@rocky rocky force-pushed the security/sandbox-system-commands-rebased branch 2 times, most recently from ba2a673 to 41d42bb Compare January 30, 2026 21:15
@rocky rocky force-pushed the security/sandbox-system-commands-rebased branch from 41d42bb to 795c7ac Compare January 30, 2026 21:19
@rocky rocky requested a review from mmatera January 30, 2026 21:20
@rocky
Copy link
Member Author

rocky commented Jan 30, 2026

@RinZ27 Here's a revised PR. Let me know if this meets your concerns.

In the previous PR, some commands did not report $Failed, but instead returned empty lists or some sort of value of the type that was supposed to be returned. I think it is better to report $Failed, since errors are caught earlier and do not cascade too much beyond the point where things start to go wrong.

@RinZ27
Copy link
Contributor

RinZ27 commented Jan 31, 2026

Thanks for the cleanup, @rocky. The decorator approach is much cleaner and avoids the boilerplate I was adding to each function. I also agree that returning $Failed is more idiomatic for blocked system calls than an empty list—it makes the failure explicit. Everything looks solid on my end.

@rocky
Copy link
Member Author

rocky commented Jan 31, 2026

Thanks for the cleanup, @rocky.

Thanks for noting the problem, working on it, and keeping with it. (Side note: some of the commits and mistakes feel like the kinds of responses I get when I use various AI tools. These things sometimes make these weird, wacky changes tacitly.)

The decorator approach is much cleaner and avoids the boilerplate I was adding to each function. I also agree that returning $Failed is more idiomatic for blocked system calls than an empty list—it makes the failure explicit. Everything looks solid on my end.

Thanks.

We could use help on the Django side to fix this. I'd appreciate it if you would put in PRs for the adjustments. Also, we probably need to alter mathicsscript so that it rejects ! in Sandboxed mode.

Lots to do!

@rocky rocky merged commit 0df365f into master Jan 31, 2026
21 checks passed
@rocky rocky deleted the security/sandbox-system-commands-rebased branch January 31, 2026 11:59
@rocky
Copy link
Member Author

rocky commented Jan 31, 2026

BTW, I suspect this won't be the last of this, and that there's more to do. Expect more iterations.

@RinZ27
Copy link
Contributor

RinZ27 commented Jan 31, 2026

@rocky I'm up for the next steps. I'll dive into mathics-django soon to align the sandbox logic there. Restricting ! in mathicsscript when sandboxed is also a great point—I'll work on a PR for that as well.

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