Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fortify Rails Webinar

Fortify Rails Webinar

In a joint webinar with CTO of FastRuby.io, Ernesto Tagwerker, and Founder of Expedited Security's Mike Buckbee, learn how to build airtight security in your Rails application by exposing vulnerabilities before deployment to production.

What we talked about:

✅ Common issues when writing Rails/ActiveRecord code that could be a potential attack vector
✅ Tools that you can use today to check what code and dependencies in your app could be exploited
✅ How an attacker would exploit one of your endpoints
✅ A case study on common threats and how to alleviate them
✅ Introduction to Wafris, an open source service to prevent attackers and dark traffic to you application
FastRuby.io's Ruby on Rails Security Audit

Ernesto Tagwerker

June 12, 2023
Tweet

More Decks by Ernesto Tagwerker

Other Decks in Technology

Transcript

  1. Fortify Rails Defending Your Ruby on Rails Applications from Bad

    Actors FastRuby.io & Wafris.org Rails Security Webinar, June 2023
  2. 🇦🇷 Hi, I’m from Argentina 🦅 I live in Philadelphia

    👨💻 I love Ruby & Open Source! 🤓 My pronouns are he/him
  3. FastRuby.io 1. Ruby/Rails Upgrade Services 2. Fixed-cost, Monthly Maintenance Services

    3. Ruby/Rails Performance Optimization 4. Ruby/Rails Security Audits
  4. Native Rails Security Countermeasures 1. Cross-Site Scripting (XSS) 2. SQL

    Injection 3. CSRF 4. Content-Security-Policy Header 5. Encrypted Credentials 6. Unsafe Query Generation 7. CSS Injection 8. Session Hijacking 9. ...
  5. Vulnerable Dependencies $ gem install bundler-stats $ bundle-stats .. ..

    .. .. .. .. .. .. .. | pg | 0 | 0 | | spring | 0 | 0 | | stripe | 0 | 0 | | timecop | 0 | 0 | | tzinfo-data | 0 | 0 | +------------------------------------|------------|----------------+ Declared Gems 62 Total Gems 218 Unpinned Versions 39 Github Refs 3
  6. Exploitable Code 1. Poorly scoped queries 2. SQL-injectable code 3.

    Poorly filtered parameters 3. Too many un-rescued exceptions 4. Etc…
  7. Sharp knives: - Ruby (e.g. monkey patches) - ActiveRecord -

    N+1 Performance Issues - Slow queries - SQL-injection, and more…
  8. Brakeman $ gem install brakeman $ brakeman .. .. ..

    .. .. .. .. == Warnings == Confidence: Medium Category: SQL Injection Check: SQL Message: Possible SQL injection Code: current_user.estimates.where("story_id = '#{params[:story_id]}'") File: app/controllers/estimates_controller.rb Line: 64
  9. Brakeman $ gem install brakeman $ brakeman .. .. ..

    .. .. .. .. == Brakeman Report == Application Path: /Users/etagwerker/Projects/fastruby/points Rails Version: 7.0.4.3 Brakeman Version: 6.0.0 Scan Date: 2023-06-09 09:47:32 -0400 Duration: 0.961275 seconds Checks Run: BasicAuth, BasicAuthTimingAttack, CSRFTokenForgeryCVE, ContentTag, CookieSerialization, CreateWith, CrossSiteScripting, DefaultRoutes, Deserialize, DetailedExceptions, DigestDoS, DynamicFinders, EOLRails, EOLRuby, EscapeFunction, Evaluation, Execute, FileAccess, FileDisclosure, FilterSkipping, ForgerySetting, HeaderDoS, I18nXSS, JRubyXML, JSONEncoding, JSONEntityEscape, JSONParsing, LinkTo, LinkToHref, MailTo, MassAssignment, MimeTypeDoS, ModelAttrAccessible, ModelAttributes, ModelSerialize, NestedAttributes, NestedAttributesBypass, NumberToCurrency, PageCachingCVE, Pathname, PermitAttributes, QuoteTableName, Redirect, RegexDoS, Render, RenderDoS, RenderInline, ResponseSplitting, RouteDoS, SQL, SQLCVEs, SSLVerify, SafeBufferManipulation, SanitizeConfigCve, SanitizeMethods, SelectTag, SelectVulnerability, Send, SendFile, SessionManipulation, SessionSettings, SimpleFormat, SingleQuotes, SkipBeforeFilter, SprocketsPathTraversal, StripTags, SymbolDoSCVE, TemplateInjection, TranslateBug, UnsafeReflection, UnsafeReflectionMethods, ValidationRegex, VerbConfusion, WeakRSAKey, WithoutProtection, XMLDoS, YAMLParsing
  10. TL;DR 1. Use `bundler-audit` 2. Use `brakeman` 3. Don’t just

    use them, add them to your development workflow (e.g. CI)
  11. Resources 1. https://guides.rubyonrails.org/security.html 2. https://rubyonrails.org/security 3. https://rubysec.com/ 4. https://brakemanscanner.org/ 5.

    https://www.fastruby.io/newsletter 6. https://www.fastruby.io/blog/rails/security/ruby-security-toolkit.html 7. https://www.fastruby.io/security-audit 8. https://audit.fastruby.io/ 9. https://bundler.io/v2.4/man/bundle-outdated.1.html