Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Safe-ish By Default
Search
Philip James
December 10, 2015
Technology
90
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Safe-ish By Default
The Django Security Model and How to Make it Better
Philip James
December 10, 2015
More Decks by Philip James
See All by Philip James
Frog and Toad Learn about Django Security - NBT6
phildini
0
39
The Elephant and the Serpent (PyLatam 2019)
phildini
0
78
Account Security for the Fashionable App Developer
phildini
1
79
All in the Timing: Side-Channel Attacks
phildini
0
92
Giving Thanks
phildini
0
54
All in the Timing: Side-Channel Attacks in Python
phildini
0
440
API-Driven Django
phildini
1
460
Type uWSGI; Press Enter; What Happens?
phildini
0
120
Type uWSGI; Press Enter; What Happens?
phildini
1
100
Other Decks in Technology
See All in Technology
形式手法を使って仕様をコーディングしよう
mikanichinose
0
190
分析の民主化を支えるメタデータ整備の実践
kakehashi
PRO
2
960
ログラスのマルチプロダクトを 支える認証基盤 〜テナントごとに異なる統制とどう向き合うか〜
dada4386
3
410
AI駆動開発の時代になったのでトヨタ生産方式から見直す
terurou
3
4.7k
【データ横丁主催】AI Agentがコンテキストを使って仕事をした後、何が残るのか― 組織の経験を次の判断に引き継ぐ「Agent Memory」
shisyu_gaku
2
340
ミイダス株式会社 テックチームのご紹介 / MIIDAS Tech Team
miidas
0
170
契約書画像からの情報抽出に特化した視覚接地モデルを育てる話
sansantech
PRO
1
150
Datadog の学び方 - あるいは、オブザーバビリティを学ぶとは何か
mananyuki
1
500
スキルを作る、その前に!複数人で使われるスキルを 作るためのプロセス
junkifurukawa
2
350
Essential architectural thinking (revised edition)
ufried
0
100
初対面のメンバーがチームを組み、Claude Codeでゼロからサービスをリリース
mkdev10
0
110
BedrockとLambdaで作る リアルタイム進行型推理ゲーム
kawametho
0
200
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
174
15k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
450
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
590
The World Runs on Bad Software
bkeepers
PRO
72
12k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
530
BBQ
matthewcrist
90
10k
Git: the NoSQL Database
bkeepers
PRO
433
67k
Ruling the World: When Life Gets Gamed
codingconduct
0
390
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
570
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
530
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Evolving SEO for Evolving Search Engines
ryanjones
0
310
Transcript
#safedjango @phildini Safe-ish by Default The Django Security Model and
How to Make it Better Philip James
#safedjango @phildini Who’s this guy?
#safedjango @phildini How We Use Django at Eventbrite
#safedjango @phildini Safe-ish? #safedjango @phildini
#safedjango @phildini XSS
#safedjango @phildini <script>alert(‘hello’)</script> <script>alert('hello')</script>
#safedjango @phildini return mark_safe( force_text(text).replace('&', '&').replace('<', ‘<').replace( '>', '>').replace('"', '"').replace("'",
‘'') )
#safedjango @phildini mark_safe(), | n, | safe
#safedjango @phildini CSRF
#safedjango @phildini CsrfViewMiddleware
#safedjango @phildini if request is a POST: get csrf_token from
cookie get csrfmiddlewaretoken from request.POST if both match: accept else: reject
#safedjango @phildini def csrf_exempt(view_func): def wrapped_view(*args, **kwargs): return view_func(*args, **kwargs)
wrapped_view.csrf_exempt = True return wraps( view_func, assigned=available_attrs(view_func) )(wrapped_view)
#safedjango @phildini if request is a POST and not view.csrf_exempt:
get csrf_token from cookie get csrfmiddlewaretoken from request.POST if both match: accept else: reject
#safedjango @phildini Sidenote: Cookies
#safedjango @phildini SQLi
#safedjango @phildini Don't ever confuse code and data, it's the
key to happiness - Alex Gaynor
#safedjango @phildini .extra(), RawSQL()
#safedjango @phildini Clickjacking
#safedjango @phildini XFrameOptionsMiddleware
#safedjango @phildini Internet Explorer 8+ Firefox 3.6.9+ Opera 10.5+ Safari
4+ Chrome 4.1+
#safedjango @phildini Host Header Validation
#safedjango @phildini get_host()
#safedjango @phildini if domain and in ALLOWED_HOSTS: proceed else: raise
error
#safedjango @phildini Sessions
#safedjango @phildini Passwords
#safedjango @phildini How Can We Make This Safer?
#safedjango @phildini Constant Vigilance!
#safedjango @phildini HTTPS
#safedjango @phildini What Does EB Do?
#safedjango @phildini CSP Reporting
#safedjango @phildini EBSecure
#safedjango @phildini crypter = Crypter.Read("/path/to/your/keys") ciphertext = crypter.Encrypt("Secret message")
#safedjango @phildini crypter = EBSecure(keyname) secret = crypter.encrypt(value.encode('utf8')
#safedjango @phildini django_encrypted_fields https://github.com/defrex/django-encrypted-fields
#safedjango @phildini Other Resources
#safedjango @phildini django-secure http://django-secure.readthedocs.org/en/v0.1.2/
#safedjango @phildini Pony Checkup https://www.ponycheckup.com/
#safedjango @phildini Making Django Ridiculously Secure http://nerd.kelseyinnis.com/blog/2015/09/08/making-django-really-really-ridiculously-secure/
#safedjango @phildini Thanks! Questions?