85
AppSensor ~real-time event detection and response

AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

Embed Size (px)

Citation preview

Page 1: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

AppSensor~real-time event detection and response

Page 2: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

me• appsensor dev lead (OWASP)

• dev / security

!

• twitter: @_jtmelton

• email: jtmelton at gmail.com

• github: jtmelton

Page 3: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

agenda

• history (recent)

• motivations / problems

• solution / tech

• future / wrap-up

Page 4: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

thesis: !

modern secure applications protect themselves against

attackers

Page 5: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
Page 6: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

history

Page 7: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

~5 yrs ago dev

• mostly web apps [RoR, PHP, .NET, Java)

• ajax (jquery) use growing

• mobile just getting started

• deployment to VMs

• hadoop picking up

• BI tools

• AWS starting

• cloud hype cycle (NIST defines)

Page 8: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

~now dev• JS everywhere

• functional / rx programming

• cloud everything

• ci/cd

• nosql / CAP light

• containers

• big data

• stream processing

• config management

• iot

• beacons [usage, ads, errors, performance]

• actors/csp

• microservices

• cqrs / event sourcing

• mobile

Page 9: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

~now dev• JS everywhere

• functional / rx programming

• cloud everything

• ci/cd

• nosql / CAP light

• containers

• big data

• stream processing

• config management

• iot

• beacons [usage, ads, errors, performance]

• actors/csp

• microservices

• cqrs / event sourcing

• mobile 1 .. * of [scale, speed, cloud, lack of environmental access]

Page 10: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

(brief) history

Page 11: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
Page 12: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

- LinkedIn, March 2015

“the Kafka ecosystem at LinkedIn is sent over 800 billion* messages per day..

At the busiest times of day, we are receiving over 13 million messages per second.”

* Update (Sept 2015) : 1.1 Trillion messages per day

Page 13: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

last ~5 yrs security

• 3rd party libs (dep-check)

• bug bounties

• sast / dast evolve (ZAP)

• iast / rasp

• http security headers

• automatic encoding (JXT)

• *-monkey -NetflixOSS

• bdd-security/gauntlt

• ci/cd plugins

• 2fa

• osquery

1 .. * of [scale, speed, cloud, lack of environmental access]

Page 14: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

dev vs. security

• dev is exploiting fundamental architectural and deployment changes to add business value

!

• security is iterating on existing solutions - and - trying to close gaps (known problems)

Page 15: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

security ~5 yrs ago vs today

?

Page 16: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

motivations

Page 17: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

“security”

• confidentiality and integrity important

• availability often ignored by security (informs the whole industry- eg. tooling)

• if availability important, runtime important

Page 18: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

http://i.imgur.com/TdtgvtW.png

Page 19: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

your environment

• how many concurrent users do you have right now?

• what are your users doing in the app?

Page 20: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

https://github.com/aphyr/jepsen-talks/blob/master/2015/goto/goto.pdf

Page 21: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

Security defects are a subset of all defects

Page 22: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
Page 23: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
Page 24: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

catching defects

• what do dev/qa do for functionality?

• test [unit, integration, system, manual, tools]

• what do attackers do for security?

• test [automated tools, manual]

Page 25: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
Page 26: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

observations

• attackers do bad things

• bad things often easily recognizable (to you)

• attacker success often* requires > 1 attempt

* If not, you lose

Page 27: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

robbing a bankPhysical Controls

Electronic Monitoring

Human Monitoring

Instant Detection and Response

Controlled Access

Multi Factor Auth

Transaction Verification

Page 28: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

would you bank here?

Alternate Admin Access

Partial External Controls

Ineffective Monitoring

No Real Time Analysis

Unnecessary Partner Trust No Response

Capability

Single Factor Auth

Limited Security Training

Page 29: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

http://worth1000.s3.amazonaws.com/submissions/414000/414200_9830_1024x2000.jpg

Page 30: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

defender’s dilemma

• attacker needs ONE successful attack

• defender must defend ALL attacks

!

• NOTE: you are defenders

Page 31: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

on people

• 18.2 million devs

• 200K security (all, not appsec only)

• ~ 1.1 sec : 100 dev

!

• 1.75 sec : 100 dev (bsimm)

Page 32: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

security modern dev

• polyglot static and dynamic languages

• microservices / soa

• json, thrift, protobuf, etc. endpoints

• WebAssembly ???

• a single mature, static language

• monolith

• http (really html) endpoints

Page 33: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

in summary …• “traditional” security, dev, ops doesn’t know what’s going

on in the app at runtime

• security defects exist

• attackers don’t magically know what’s vulnerable

• existing “monitoring” usually terrible

• there will never be enough “security” people

• “traditional” security tooling doesn’t fit modern dev

• actual defense is _really_ hard

Page 34: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

the pitch !

(a humble proposal)

Page 35: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

having to deal with [scale, speed, cloud, lack of

environmental access].. !

..this as of now incomplete transition..

!

..represents an enormous opportunity for security

Page 36: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

the pitch• in addition to a secure SDLC … (ie. > 1 request/attack)

!

• figure out what’s happening at runtime

• make intrusion detection primitives available in app

• exploit automated response > manual response

• stop attacker before success

• get self-protecting applications and valuable intel

X successAppSensor

Page 37: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

X

Page 38: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

prior work

• Network IDS (Denning, * others, NIST SP800-94)

• Intrusion prevention

• Fraud detection

• Rules engines, Risk analysis/reduction, HIDS

Page 39: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

terminology

• event - suspicious

• attack - malicious (1 .. * events)

• response - take action (1 .. 1 attack)

• detection point - activity category (e.g. cookie modification)

Page 40: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

the tech

Page 41: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

Architecture

Page 42: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

• picture 1

Page 43: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
Page 44: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

Correlation

Page 45: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
Page 46: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
Page 47: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
Page 48: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

Adding Detection Points

Page 49: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

adding detection points

• manually

• reverse proxy

• owasp aside

Page 50: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

manualPOST /account/transfer HTTP/1.1 !Host: 127.0.0.1 User-Agent: Mozilla/5.0 (Win…) Accept: text/html,application/xhtml+xml Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: http://127.0.0.1/account.php Cookie: PHPSESSID=l9…lgt5 Connection: keep-alive Content-Type: application/x-www-form-urlencoded Content-Length: 30 from_acct=xxx1234&to_acct=xxx9876&amt=20.00

Page 51: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

manualPOST /account/transfer HTTP/1.1 !Host: 127.0.0.1 User-Agent: Mozilla/5.0 (Win…) Accept: text/html,application/xhtml+xml Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: http://127.0.0.1/account.php Cookie: PHPSESSID=l9…lgt5 Connection: keep-alive Content-Type: application/x-www-form-urlencoded Content-Length: 30 from_acct=xxx1234&to_acct=xxx9876&amt=20.00

Page 52: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

manualPOST /account/transfer HTTP/1.1 !Host: 127.0.0.1 User-Agent: Mozilla/5.0 (Win…) Accept: text/html,application/xhtml+xml Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: http://127.0.0.1/account.php Cookie: PHPSESSID=l9…lgt5 Connection: keep-alive Content-Type: application/x-www-form-urlencoded Content-Length: 30 from_acct=xxx1234&to_acct=xxx9876&amt=20.00

Page 53: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

manual@POST public Response transfer( String from, String to, String amount) { ! transfer(from, to, amount); ! return Response.ok(); }

Page 54: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

manual@POST public Response transfer( String from, String to, String amount) { ! if ( currentUser.owns(from) ) { transfer(from, to, amount); } ! return Response.ok(); }

Page 55: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

manual@POST public Response transfer( String from, String to, String amount) { ! if ( currentUser.owns(from) ) { transfer(from, to, amount); } else {! showErrorPage();! // normal error handling! }!! return Response.ok(); }

Page 56: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

manual@POST public Response transfer( String from, String to, String amount) { ! if ( currentUser.owns(from) ) { transfer(from, to, amount); } else {!! appsensor.addEvent( new Event(currentUser, "ACE2") );! showErrorPage(); // normal error handling! }!! return Response.ok(); }

Page 57: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

appsensor-reverse-proxy

Page 58: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

appsensor-reverse-proxy

• written in go

• blocks requests

• canned detection points (toggle-able)

• easily extendable

• https://github.com/jtmelton/appsensor-reverse-proxy

Page 59: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

OWASP ASIDE

• UNCC SIS project

• secure programming IDE plugin

• educational component

• https://www.owasp.org/index.php/OWASP_ASIDE_Project

Page 60: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

OWASP ASIDE

• eclipse IDE

• reminder icon or highlight

• drop down list of applicable sensors

• auto-insertion of ASIDE sensor APIs and code refactoring

Page 61: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

OWASP ASIDE

Page 62: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

OWASP ASIDEBased  on  ESAPI  code  (length  checked),  ASIDE  infers  that  this  may  be  a  point  to  insert  an  app  sensor;  whether  a  sensor  is  placed  relies  on  developer’s  decision.  

Page 63: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

OWASP ASIDE

It  not  only  captures  the  context  informaFon  (e.g.  the  sensor  event  is  from  username  field),  but  also  records  that  the  sensor  event  is  due  to  an  exceedingly  lengthy  input.  

Page 64: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

Detec%on(Point(Type( Detec%on(Points(Covered(

Authen'ca'onExcep'on. AE4:.Unexpected.Quan'ty.of.Characters.in.Username.AE5:.Unexpected.Quan'ty.of.Characters.in.Password.AE6:.Unexpected.Type.of.Character.in.Username.AE7:.Unexpected.Type.of.Character.in.Password.

InputExcep'on. IE1:.Cross.Site.Scrip'ng.AEempt.

EncodingExcep'on. EE1:.Double.Encoded.Character.EE2:.Unexpected.Encoding.Used.

CommandInjec'onExcep'on.

CIE1:.Blacklist.Inspec'on.for.Common.SQL.Injec'on.Values.

Detec%on(Points(Picked( Corresponding(ASIDE(APIs(

AE4:%Unexpected%Quan1ty%of%Characters%in%Username%AE5:%Unexpected%Quan1ty%of%Characters%in%Password%

Java.lang.String%ASIDE.Quan%tyExcep%onSensor(Java.lang.String%parameter)%

AE6:%Unexpected%Type%of%Character%in%Username%AE7:%Unexpected%Type%of%Character%in%Password%

Java.lang.String%ASIDE.TypeExcep%onSensor(Java.lang.String%parameter)%

IE1:%Cross%Site%Scrip1ng%AKempt%

Java.lang.String%ASIDE.XSSSensor(Java.lang.String%parameter)%

EE1:%Double%Encoded%Character%EE2:%Unexpected%Encoding%Used%

Java.lang.String%ASIDE.EncodingExcep%onSensor(Java.lang.String%parameter)%

CIE1:%Blacklist%Inspec1on%for%Common%SQL%Injec1on%Values%

Java.lang.String%ASIDE.SQLInjec%onSensor(Java.lang.String%parameter)%

Page 65: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

Viewing Data

Page 66: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

owasp SoC sprint

• Sumanth Damarla

• appsensor -> ELK stack

• appsensor -> influxdb -> grafana

Page 67: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

owasp SoC sprint

Page 68: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

owasp SoC sprint

Page 69: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

machine learning

• very simple analysis

• generated demo dataset for 1-week

• build base model

• look for “anomalies”

Page 70: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
Page 71: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

appsensor-ui

• spring boot + reactjs

• simple dashboards / trends

Page 72: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
Page 73: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
Page 74: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
Page 75: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
Page 76: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016
Page 77: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

future plans

Page 78: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

future• reverse proxy

• appsensor-ui

• framework integration for detection points (spring security exists, add others)

• analysis engines - 2 grad students (David Scrobonia, Kelvin Brown Bomah) doing projects here (rules and ML)

• ???

Page 79: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

you• help wanted!

• plenty of places to contribute and improve

• friendly, helpful community

• https://github.com/jtmelton/appsensor/issues

• https://www.owasp.org/index.php/OWASP_AppSensor_Project#tab=Road_Map_and_Getting_Involved

Page 80: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

wrap-up

Page 81: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

related projects

• repsheet

• ensnare

• fido

• riemann

• elastalert

Page 82: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

pick a tool (or 2) … !

but use the idea

Page 83: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

contributors• https://www.owasp.org/index.php/

OWASP_AppSensor_Project#tab=Acknowledgements

Page 84: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

links

• https://www.owasp.org/index.php/OWASP_AppSensor_Project

• http://appsensor.org/

• https://github.com/jtmelton/appsensor

Page 85: AppSensor Near Real-Time Event Detection and Response - DevNexus 2016

?