Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 815719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:43:43+00:00 2026-05-15T01:43:43+00:00

I’d like to run user supplied ruby code in server, what are the potentially

  • 0

I’d like to run user supplied ruby code in server, what are the potentially nasty things that can happen? I mean things like deleting files etc. Can you give me more examples?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:43:44+00:00Added an answer on May 15, 2026 at 1:43 am

    Ruby allows you to set a $SAFE global variable that will determine exactly what tainted code is allowed to do. Read up more about this in Locking Ruby in the Safe.

    To paraphrase, here’s the table on the effects of $SAFE:

    $SAFE Constraints

    0 No checking of the use of externally supplied (tainted) data is performed. This is Ruby’s default mode.

    >= 1 Ruby disallows the use of tainted data by potentially dangerous operations.

    >= 2 Ruby prohibits the loading of program files from globally writable locations.

    >= 3 All newly created objects are considered tainted.

    >= 4 Ruby effectively partitions the running program in two. Nontainted objects may not be modified. Typically, this will be used to create a sandbox: the program sets up an environment using a lower $SAFE level, then resets $SAFE to 4 to prevent subsequent changes to that environment.

    This is the content from the table at the bottom of the linked page, which explains what tainted objects are allowed to do at each $SAFE level. From this, you can easily infer what bad things Ruby code would be able to do.

    Definition of the safe levels

    $SAFE >= 1

    • The environment variables RUBYLIB and RUBYOPT are not processed, and the current directory is not added to the path.
    • The command-line options -e, -i, -I, -r, -s, -S, and -x are not allowed.
    • Can’t start processes from $PATH if any directory in it is world-writable.
    • Can’t manipulate or chroot to a directory whose name is a tainted string.
    • Can’t glob tainted strings.
    • Can’t eval tainted strings.
    • Can’t load or require a file whose name is a tainted string.
    • Can’t manipulate or query the status of a file or pipe whose name is a tainted string.
    • Can’t execute a system command or exec a program from a tainted string.
    • Can’t pass trap a tainted string.

    $SAFE >= 2

    • Can’t change, make, or remove directories, or use chroot.
    • Can’t load a file from a world-writable directory.
    • Can’t load a file from a tainted filename starting with ~.
    • Can’t use File#chmod , File#chown , File#lstat , File.stat , File#truncate , File.umask , File#flock , IO#ioctl , IO#stat , Kernel#fork , Kernel#syscall , Kernel#trap . Process::setpgid , Process::setsid , Process::setpriority , or Process::egid= .
    • Can’t handle signals using trap.

    $SAFE >= 3

    • All objects are created tainted.
    • Can’t untaint objects.

    $SAFE >= 4

    • Can’t modify a nontainted array, hash, or string.
    • Can’t modify a global variable.
    • Can’t access instance variables of nontainted objects.
    • Can’t change an environment variable.
    • Can’t close or reopen nontainted files.
    • Can’t freeze nontainted objects.
    • Can’t change visibility of methods (private/public/protected).
    • Can’t make an alias in a nontainted class or module.
    • Can’t get meta information (such as method or variable lists).
    • Can’t define, redefine, remove, or undef a method in a nontainted class or module.
    • Can’t modify Object.
    • Can’t remove instance variables or constants from nontainted objects.
    • Can’t manipulate threads, terminate a thread other than the current, or set abort_on_exception.
    • Can’t have thread local variables.
    • Can’t raise an exception in a thread with a lower $SAFE value.
    • Can’t move threads between ThreadGroups.
    • Can’t invoke exit, exit!, or abort.
    • Can load only wrapped files, and can’t include modules in nontainted classes and modules.
    • Can’t convert symbol identifiers to object references.
    • Can’t write to files or pipes.
    • Can’t use autoload.
    • Can’t taint objects.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 415k
  • Answers 415k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This answer is outdated, you can add form elements using… May 15, 2026 at 9:03 am
  • Editorial Team
    Editorial Team added an answer I use Google Code as a svn repository and for… May 15, 2026 at 9:03 am
  • Editorial Team
    Editorial Team added an answer Yes, set both flags: they present the information in different… May 15, 2026 at 9:03 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.