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

  • SEARCH
  • Home
  • 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 1034993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:28:41+00:00 2026-05-16T14:28:41+00:00

From this article http://www.stuartellis.eu/articles/erb referring to thread safety levels: At this level, the specified

  • 0

From this article http://www.stuartellis.eu/articles/erb referring to thread safety levels:

“At this level, the specified binding must be marked as trusted for ERB to use it.”

I’ve searched high and low and haven’t found a way to “mark” a Binding as “trusted”.

Will somebody please enlighten me?

  • 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-16T14:28:42+00:00Added an answer on May 16, 2026 at 2:28 pm

    You should taint the binding by calling the taint method.

    The $SAFE levels are a feature of Ruby that denies certain actions depending on the current level and whether an object is tainted. Tainted strings are assumed to originate from an untrusted source, such as a file, a database, a HTTP client, etc.

    At $SAFE level 1, for example, Ruby will not allow you to require files if the argument is a tainted string.

    $SAFE level 4 is the most extreme. Ruby will effectively disallow you to modify any nontained object. The idea is that you can use a lower $SAFE level in your application, and instantiate a thread or proc with $SAFE level 4. Within this sandbox, you can modify tainted objects only.

    ERB uses this mechanism to allow you to run a template within a sandbox. If you try to get the result of a rendered template from a certain binding, this is what happens:

    class TemplateContext
      def name; "Teflon Ted"; end
    end
    
    template_binding = TemplateContext.new.send(:binding)
    ERB.new("Hi, <%= name %>!", 4).result(template_binding)
    
    #=> SecurityError: Insecure: can't modify trusted binding
    

    Blam! This is Ruby telling you that it is not okay to modify a nontainted object at $SAFE level 4. It will not allow you to call eval with the given binding (which is exactly what ERB attempts).

    Instead, you should provide the sandbox with a tainted binding. You are explicitly telling Ruby that it is okay to use this binding in a sandbox, and that it should not be trusted outside the sandbox.

    class TemplateContext
      def name; "Teflon Ted"; end
    end
    
    # Binding must be tainted!
    template_binding = TemplateContext.new.send(:binding).taint
    ERB.new("Hi, <%= name %>!", 4).result(template_binding)
    
    #=> "Hi, Teflon Ted!"
    

    For more information about Ruby’s $SAFE level, see the excellent description in the Pickaxe book.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just read about @Resource annotation from this article ( http://www.infoq.com/articles/spring-2.5-part-1 ) and wish
I researched about validation tehniques on net and found this article http://www.codeproject.com/Articles/97564/Attributes-based-Validation-in-a-WPF-MVVM-Applicat Does anyone
Hi I was using this article http://www.codeproject.com/Articles/152280/Online-Credit-Card-Transaction-in-ASP-NET-Using-Pa?msg=3753796#xx3753796xx to understand the PayFlow Transaction Process and
I have jokes.db database. This database file imported from using this article., http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/ .
I'm using code examples from this article by Rick Strahl: http://www.west-wind.com/weblog/posts/324917.aspx to make async
I have read from this article http://codahale.com/how-to-safely-store-a-password/ and it says using a salt isn't
I was reading about data driven testing using mbunit from this article. http://blog.benhall.me.uk/2007/04/mbunit-datafixture-data-driven-unit.html I
I've managed to setup jboss as windows service found this article http://www.jboss.org/jbossweb/install/service.html When I
I'm new with cmake ,just installed it and following this article: http://www.cs.swarthmore.edu/~adanner/tips/cmake.php D:\Works\c\cmake\build>cmake ..
From this Wikipedia article: http://en.wikipedia.org/wiki/Hamiltonian_path_problem A randomized algorithm for Hamiltonian path that is fast

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.