IronLanguages / IronLanguages/ironpython3
Feature Request: Implement a restricted mode
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.8k
- Forks
- 316
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 1
Description
I'm interested in using IronPython as a scripting language for my app, as I've done benchmarks on many popular .net scripting solutions and IronPython comes on top - and speed is important for this app. However security is also important. I would like to create a platform where users can share their scripts, but not if I cannot lock down the scripts from being able to make any system changes.
The biggest hurdle I'm up against is that IronPython is completely unrestricted. I have resorted to doing the following to sand box the app, without forking this code base.
- Modified the sys module to provide only a handful of its members
- Created a string list of built in modules to be restricted - based off what I found from IronPython.Modules. Modules like winreg, _thread i have restricted, where modules like time I've kept.
- Created my own import function of which is a copy-paste from source code with modifications to enforce the restricted modules.
- Removed some built-in methods. Such as open
I'm hoping this is enough, but I can't be sure. I'm also hoping that by restricting the builtins, i can use the standard library, and modules from the standard library that use the restricted functionality will just not work.
This issue is a request to implement such a mode in this project.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing sys module, builtins, import, and IronPython.Modules behavior described in the issue, then determine which operations a restricted mode must prevent. Define the security boundary and supported restrictions before implementation; done means user scripts cannot make the specified system changes while permitted standard-library functionality remains usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, python
- Domain
- security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100