3. שינוי המגבלות
מדיניות ארגז החול מונעת מה-Sandboxee לקרוא ל-syscalls ספציפיים, וכך מצמצמת את שטח הפנים של המתקפה. עם זאת, תוקף עדיין יכול לגרום להשפעות לא רצויות על ידי הפעלת תהליך ללא הגבלת זמן או על ידי ניצול מלא של ה-RAM ומשאבים אחרים.
כדי להתמודד עם האיום הזה, Sandboxee פועל כברירת מחדל במסגרת מגבלות ביצוע מחמירות. אם מגבלות ברירת המחדל האלה גורמות לבעיות בהרצה הלגיטימית של התוכנית, אפשר לשנות אותן באמצעות המחלקה sandbox2::Limits
על ידי קריאה ל-limits()
באובייקט של מנהל ההרצה.
בקטע הקוד הבא מוצגות כמה דוגמאות לשינויים במגבלות. כל האפשרויות הזמינות מתועדות בקובץ הכותרת limits.h.
// Restrict the address space size of the sandboxee to 4 GiB.
executor->limits()->set_rlimit_as(4ULL << 30);
// Kill sandboxee with SIGXFSZ if it writes more than 1 GiB to the filesystem.
executor->limits()->set_rlimit_fsize(1ULL << 30);
// Number of file descriptors which can be used by the sandboxee.
executor->limits()->set_rlimit_nofile(1ULL << 10);
// The sandboxee is not allowed to create core files.
executor->limits()->set_rlimit_core(0);
// Maximum 300s of real CPU time.
executor->limits()->set_rlimit_cpu(300);
// Maximum 120s of wall time.
executor->limits()->set_walltime_limit(absl::Seconds(120));
דוגמה לשימוש במחלקה sandbox2::Limits
מופיעה בדוגמה tool.