Coder Social home page Coder Social logo

tsengwen / moxiebox Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sysprog21/moxiebox

0.0 1.0 0.0 67 KB

A secure, sandboxed execution mechanism that enables deterministic input, processing and output

License: MIT License

Makefile 2.01% Assembly 1.15% C 46.28% Shell 8.20% C++ 42.36%

moxiebox's Introduction

moxiebox

Motivation

The goal of moxiebox is to provide a secure, sandboxed execution mechanism that enables deterministic input, processing and output. Execution is separated out into distinct phases:

  1. Prepare and load hash-sealed program executables, data.
  2. Execute program as a black box, with no I/O capability. Runs until exit or CPU budget exhausted (or CPU exception).
  3. Gather processed data, if any.

A single thread of execution pre-loads necessary data, then simulates a 32-bit little endian Moxie CPU, running the loaded code.

This program is built using the "moxiebox" target in upstream binutils and gcc. A reduced (C-only) gcc toolchain is therefore available for immediate use by developers.

From the Moxie program's point of view, it is a single thread running as root and is essentially the entire operating system kernel + application, all in a single wrapper.

From the sandbox's point of view, the application is running as an unpriv'd application with only the ability to access data within the hand-built memory map.

Check sandbox execution environment for details.

More info about the Moxie architecture may be found as following:

Prerequisites

You will need to build and install moxie binutils+gcc cross-compiler toolchain first. It is suggested using derived crosstool-ng:

git clone https://github.com/jserv/crosstool-ng
./bootstrap
./configure
make
make install
mkdir -p ~/build-toolchain
cd ~/build-toolchain
ct-ng moxie-none-moxiebox
ct-ng build

After crosstool-NG builds everything from scratch, you will get GNU toolchain for Moxiebox in directory $HOME/x-tools/moxie-none-moxiebox. You can update $PATH via:

source envsetup

Build and verify sandbox

Once Moxiebox toolchain is properly installed, simply build with GNU make:

make

And verify:

make check

Usage

Example usage of sandbox:

$ src/sandbox \
      -e runtime/test1 \
      -d mydata.json \
      -d mydata2.dat \
      -o file.out

If you specify the -g option, then sandbox will wait for a GDB connection on the given port. For example, run sandbox like so:

$ src/sandbox -e tests/rtlib -g 9999
ep 00001000
ro 00000f8c-00001540 elf0
rw 00001640-00001aa8 elf1
rw 00002aa8-00012aa8 stack
ro 00013aa8-00013b48 mapdesc

And, in a separate console, run GDB to connect to sandbox using the target remote command like so:

$ moxie-none-moxiebox-gdb -q tests/rtlib
Reading symbols from basic...done.
(gdb) target remote :9999
Remote debugging using :9999
0x00001000 in __start ()
(gdb) b main
Breakpoint 1 at 0x13da: file rtlib.c, line 73.
(gdb) c
Continuing.

Breakpoint 1, main (argc=0, argv=0x2) at rtlib.c:73
73	{
(gdb) x/4i $pc
=> 0x13da <main>:	push	$sp, $r6
   0x13dc <main+2>:	push	$sp, $r7
   0x13de <main+4>:	dec	$sp, 0x38
   0x13e0 <main+6>:	ldi.l	$r2, 0x11
(gdb)

Licensing

moxiebox is freely redistributable under MIT X License. Use of this source code is governed by the license that can be found in the LICENSE file.

moxiebox's People

Contributors

jserv avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.