Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Security, Secrets, and Shenanigans
Search
Richard Schneeman
March 06, 2013
Programming
490
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Security, Secrets, and Shenanigans
Richard Schneeman
March 06, 2013
More Decks by Richard Schneeman
See All by Richard Schneeman
[RubyConf] Beware the Dreaded Dead End
schneems
1
410
[Kaigi] Beware the Dead End
schneems
0
220
Threads Aren't Evil
schneems
0
640
Bayes is BAE
schneems
0
4.1k
Testing the Untestable
schneems
1
950
SLOMO
schneems
2
1.3k
Saving Sprockets
schneems
8
17k
Memory Leaks, Tweaks, and Techniques
schneems
1
260
Speed Science
schneems
20
37k
Other Decks in Programming
See All in Programming
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
640
AI駆動開発を妨げる技術的負債の解消アプローチ / ai-refactoring-approach
minodriven
17
9.1k
Foundation Models frameworkで画像分析
ryodeveloper
1
120
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
220
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
440
フィードバックで育てるAI開発
kotaminato
1
120
初めてのKubernetes 本番運用でハマった話
oku053
0
130
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
360
OSINT for SRE: 学術論文とポストモーテムから探る システム障害の共通パターン / SRE NEXT 2026
tomoyk
1
3.8k
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
490
symfony/aiとlaravel/boost
77web
0
130
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
2
500
Featured
See All Featured
Building the Perfect Custom Keyboard
takai
2
810
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
370
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Prompt Engineering for Job Search
mfonobong
0
380
It's Worth the Effort
3n
188
29k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Ethics towards AI in product and experience design
skipperchong
2
330
HDC tutorial
michielstock
2
740
Mind Mapping
helmedeiros
PRO
1
280
Designing for humans not robots
tammielis
254
26k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Transcript
Security, Secrets, & Shenanigans Richard Schneeman @schneems
@schneems
Schnauser
None
I <3 Ruby
Hans Peter Von Wolfe (the 5th)
Sextant Gem
Wicked ‘ ‘ Gem
Triage Code codetriage.com
None
Adjunct Professor
Good News Everyone! schneems.com/ut-rails
I work for this one
AUS Ruby Conf
None
Hello wroclove
Close your Laptops
Unless you’re commenting on rails/rails issues
Web Security
What does it mean to be secure
I am not a security researcher
You don’t have to be either
Arm yourself with knowledge
Every system has a weakness
Security Bugs are Bugs
420,000 lines 11 versions 17 errors
Bug free software is impossible
Cover Common Exploits
Talk about Mitigation Strategies
Improve our security processes
Availability
Security isn’t just keeping others out
Staying Available to Serve your customers
DDoS
Distributed Denial of Service
None
None
None
Block IP Addresses
Memory Exploits
:symbols aren’t fancy strings
:symbols are never garbage collected
params[:id].to_sym
params[:id].to_sym Don’t Do This
Parser Exploits
A billion Laughs
<?xml version="1.0"?> <!DOCTYPE lolz [ <!ENTITY lol "lol"> <!ENTITY lol1
"&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;"> <!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;"> <!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;"> <!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;"> <!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;"> <!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;"> <!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;"> <!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;"> <!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;"> ]> <lolz>&lol9;</lolz>
10 Entities
Each Reference Previous Entries
Consumes ~3GB of ram to process
Like a Zip Bomb for XML parsers
Ouch
modern XML parsers are not vulnerable to this attack Libxml2
Authentication the act of confirming the truth of an attribute
of a datum or entity
e Armadillos
YAML Parser
YAML Ain’t Markup Language
development: adapter: postgresql encoding: utf8 database: my_development pool: 5 host:
localhost config/database.yml
require 'yaml' db_config = YAML::load_file('config/database.yml') puts db_config["development"] # => {
"adapter" => "postgresql", "encoding" => "utf8", "database" => "example_development", "pool" => 5, "host" => "localhost" }
YAML Ain’t just for basic objects
“--- !ruby/array:Array - jacket - sweater” YAML::load => ???
“--- !ruby/array:Array - jacket - sweater” YAML::load => [“jacket”, “sweater”]
“--- !ruby/hash:User email:
[email protected]
” YAML::load => ???
“--- !ruby/hash:User email:
[email protected]
” YAML::load => #<User id: 1, email:
"
[email protected]
">
“--- !ruby/hash:User email:
[email protected]
” YAML::load user = User.new
“--- !ruby/hash:User email:
[email protected]
” YAML::load user = User.new user[:email] =
“
[email protected]
“--- !ruby/hash:User email:
[email protected]
” YAML::load user = User.new user[:email] =
“
[email protected]
“--- !ruby/hash:User email:
[email protected]
” YAML::load user = User.new user[:email] =
“
[email protected]
puts user => #<User id: 1, email: "
[email protected]
">
Interesting, but is it insecure?
class Foo def []=(name, value) puts value * 3 end
end “--- !ruby/hash:Foo bar: hi” YAML::load foo = Foo.new
class Foo def []=(name, value) puts value * 3 end
end “--- !ruby/hash:Foo bar: hi” YAML::load foo = Foo.new foo[:bar] = “hi” => “hihihi”
class Foo def []=(name, value) puts value * 3 end
end “--- !ruby/hash:Foo bar: hi” YAML::load foo = Foo.new foo[:bar] = “hi” => “hihihi”
Let’s Get Dirty
class Foo def []=(name, value) eval(name) + value end end
class Foo def []=(name, value) eval(name) + value end end
--- !ruby/hash:Foo “puts '=== hello there'.inspect;”: hi YAML::load
class Foo def []=(name, value) eval(name) + value end end
--- !ruby/hash:Foo “puts '=== hello there'.inspect;”: hi YAML::load foo = Foo.new foo["puts '=== hello there'.inspect"] = 'hi' === hello there NoMethodError: undefined method `+' for nil:NilClass
class Foo def []=(name, value) eval(name) + value end end
--- !ruby/hash:Foo “puts '=== hello there'.inspect;”: hi YAML::load foo = Foo.new foo["puts '=== hello there'.inspect"] = 'hi' === hello there NoMethodError: undefined method `+' for nil:NilClass
zOMG arbitrary code execution
But how does an attacker get us to execute arbitrary
YAML?
XML Parser
<?xml version="1.0" encoding="UTF-8"?> <boom type="yaml"><![CDATA[--- !ruby/ object:UnsafeObject attribute1: value1 ]]></boom>
By default will parse arbitrary YAML
I’m in UR Servers Executing My Code
Java/ PHP/ C++/ etc. Secure?
Sanatize Your Inputs
And your Floors
Never Trust your users
Or your dogs
Ro Om Ba Attacks
RoOmBa Attacks
Responsible Disclosure
Create a /security report page
None
Intrusion Detection/ Logging
Papertrail
Stay Informed
Subscribe to Security Lists
Patch Early, Patch often
Secrets Secrets Secrets
CSRF
Cross Site Request Forgery
None
config.security_token
the key to your digital kingdom
Would you give your Car key copies to:
Interns? Your
Contractors? Your
Your Open Source Contributors?
If secrets are in your source, you’ve already given them
your digital kingdom
Protect Your Code
Secure keys in source control aren’t secure
What’s an alternative?
Environment Variables
$ rake db:migrate RAILS_ENV=test
$ rake db:migrate RAILS_ENV=test
In Development
Use a .env file
$ cat .env SECRET_TOKEN=d59c2a439f
Use dotenv gem
$ irb > Dotenv.load > puts ENV[‘SECRET_TOKEN’] > “d59c2a439f”
Use foreman gem
$ foreman run irb > puts ENV[‘SECRET_TOKEN’] > “d59c2a439f”
In Production
$ heroku config:add SECRET_TOKEN=d59c2a439f
VPS • Use Foreman/Dotenv • Add to bashrc • Add
values directly to command $ SECRET_TOKEN=asd123 rails console ruby-1.9.3> puts ENV[‘SECRET_TOKEN’] ruby-1.9.3> “asd123”
What if...
Someone Can read my ENV Variables?
Then they can read your files too
Is your app secure?
Is your app open source- able?
SECRET_TOKEN is just one example of Config
Define: Config
Config • What varies between deploys • resource strings to
databases • credentials to S3, twitter, facebook, etc. • canonical values, hostname • security tokens
Can you deploy your app to change your S3 Bucket?
Do you NEED to deploy your app to change your
S3 bucket?
Environment Variables! Use
Config
But I like storing my credentials in git!
What is Config? Just because it works...
Wishlist: rotate-able security tokens
Security
Nothing is ever 100% secure
Educate yourself
Secrets
Don’t store secrets in Git
Use ENV Variables
Shenanigans
None
Vote @hone02 (Terence Lee) Ruby Hero 2013
Questions? @schneems