About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your...

28

Transcript of About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your...

Page 1: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js
Page 2: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

About me

o What I am not?

• Formally Educated

• Developer

• Hacker

o What I am?

• Interested

Page 3: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

How I am about to spend your time?

o What is GoH?

o What's behind it?

o Not so wet T-Shirt contest

o Node.js potential risks

o Takeaways

Page 4: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

Game of Hacks – An idea is born

using System; using System.Security.Cryptography; class Program { static void Main() { using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider()) { // Buffer storage. byte[] data = new byte[4]; // Ten iterations. for (int i = 0; i < 10; i++) { // Fill buffer. rng.GetBytes(data); // Convert to int 32. int value = BitConverter.ToInt32(data, 0); Console.WriteLine(value); } // other Random Generation method Random otherRandomGenerator = new Random(); double otherRandomNumber = otherRandomGenerator.NextDouble();

Spot The Vulnerability

Page 6: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

1+1=?

Launched on August

More than 100,000 games were played since

Page 7: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

What was behind GoH?

Page 8: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

Honeypot

o We assumed the game would be attacked o We might as well learn from it o Vulnerabilities were left exposed and patched along the

way

Page 9: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

Let’s take a look at the game

Page 10: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

GoH Architecture

Server

Client

Page 11: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

Single Thread Events handler

Code.DanYork.Com

Event Driven

Page 12: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

12

Question

Answers

Code Snippet

60-Second Timer

Question # Score

Difficulty Level

Page 13: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

Game Entities

o Quiz questions

o Answers

o Score

o Timer

Page 14: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

Get your Browsers ready!

Checkmarx@Defcon 23 Turn your mobile devices ON!

Go to: www.kahoot.it

Page 15: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

Answered Question

o Initially users initiated app.sendAnswers multiple times, until they got “Correct answer” response.

o This allowed malicious users to systematically locate the correct answer – and to gain points over and over for the same question.

o Solutions

• “Question Already Answered” flag added

Page 16: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

Timer

o GoH Version 1

• Timer handled by client

• User forced to go to next question when time ends

• Client sends to server Answer + Time spent

o GoH 2

• Time is now computed at the server with minor traffic influence

o So what?

• Players stopped timer by modifying JS code

Page 17: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

Timer

o What else?

Page 18: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

More Node.js points to remember

Page 19: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

Architecture and MongoDB

db.products.insert( { item: "card", qty : 15 } ) db.products.insert( { name: “elephant", size: 1700 } )

db.products.insert

db.products.find

db.products.find() - Find all of them db.products.find( { qty: 15 }) - Find based on equality db.products.find( { qty: { $gt: 25 } } ) - Find based on criteria

Data is inserted and stored as JSON

Queries as described using JSON

var obj; obj.qty=15; db.products.find(obj)

Page 20: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

name = req.query.username; pass = req.query.password; db.users.find({username: name, password: pass}); … If exists ….

Security – User Supplied Data

o Can you spot the vulnerabilities in the code?

o Fix:

20

WRONG!

Page 21: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

name = req.query.username; pass = req.query.password; db.users.find({username: name, password: pass});

Security – User Supplied Data

21

o What if we use the following query:

db.users.find({username: {$gt, “a”}, password : {$gt, “a”}});

Page 24: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

JSON Based SQL Injection

o You can use the following:

o Then

db.users.find({username: username});

bcrypt.compare(candidatePassword, password, cb);

WRONG!

Page 25: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

JSON Based SQLi

o This can lead to Regular Expression Denial of Service through the {“username”: {“$regex”: “……..}}

db.users.find({username: username});

Page 26: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

Re-Dos Demo

http://localhost:49090/?user=admin&pass[$regex]=^(a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|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Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

Some Key Takeaways

Gamification of education

• Knowledge is key to deliver secure code

• Students (of all ages) absorb and retain information better

• Anytime you have a chance to make learning a fun experience you should do it

Using code

• Always validate the input length, structure and permitted characters

• Each coding language has its own pitfalls

• Research and learn a language before you use it publicly.

• Remember - Node.js is highly sensitive to CPU-intensive tasks

Page 28: About me CON 23/DEF CON 23 presentations/DEF CON 23 - Amit-Ashbel...How I am about to spend your time? o. What is GoH? o. What's behind it? o. Not so wet T-Shirt contest . o. Node.js

Thank You

Questions?

[email protected]

@aashbel

Amit Ashbel