▲ | killerstorm 6 hours ago | |||||||
Object-capability model / capability-based security. Do not let code to have access to things it's not supposed to access. It's actually that simple. If you implemented a function which formats a string, it should not have access to `readFile`, for example. Retrofitting it into JS isn't possible, though, as language is way too dynamic - self-modifying code, reflection, etc, means there's no isolation between modules. In a language which is less dynamic it might be as easy as making a white-list for imports. | ||||||||
▲ | pjc50 5 hours ago | parent [-] | |||||||
People have tried this, but in practice it's quite hard to do because then you have to start treating individual functions as security boundaries - if you can't readFile, just find a function which does it for you. The situation gets better in monadic environments (can't readFile without the IO monad, and you cant' call anything which would read it). | ||||||||
|