with { Poking Servers whoami | head WebAppSec - - PowerPoint PPT Presentation

with
SMART_READER_LITE
LIVE PREVIEW

with { Poking Servers whoami | head WebAppSec - - PowerPoint PPT Presentation

with { Poking Servers whoami | head WebAppSec Consultant, Penetra:on Tester, Bug Bounty Hunter for Google, Facebook, Paypal, Mozilla and other bounty


slide-1
SLIDE 1

Poking ¡ Servers ¡ with ¡ {

slide-2
SLIDE 2

whoami ¡| ¡head ¡

  • WebAppSec ¡Consultant, ¡Penetra:on ¡Tester, ¡

Bug ¡Bounty ¡Hunter ¡for ¡Google, ¡Facebook, ¡ Paypal, ¡Mozilla ¡and ¡other ¡bounty ¡programs ¡

  • Null ¡Security ¡Community ¡Bangalore ¡Chapter ¡

Lead ¡

  • Work ¡at ¡a ¡Big4 ¡and ¡have ¡conducted ¡several ¡

Penetra:on ¡Tests ¡all ¡over ¡the ¡world. ¡

slide-3
SLIDE 3

history ¡| ¡less ¡

Started ¡hun:ng ¡for ¡bugs ¡on ¡several ¡bug ¡bounty ¡programs ¡for ¡ ¡

slide-4
SLIDE 4

history ¡| ¡less ¡

slide-5
SLIDE 5

dpkg ¡-­‑i ¡inves:gate.deb ¡

Found ¡a ¡facebook.com ¡URL ¡which ¡fetched ¡the ¡ <:tle> ¡from ¡a ¡URL ¡I ¡could ¡control ¡ Tested ¡for ¡XSS, ¡SQLi ¡and ¡LFI/RFI ¡ Setup ¡a ¡HTTP ¡server ¡with ¡port ¡8080 ¡exposed ¡to ¡the ¡Internet ¡ Used ¡hWp://myserver:8080 ¡as ¡an ¡argument, ¡mistyped ¡the ¡port ¡ number ¡as ¡808 ¡ Facebook ¡displayed ¡an ¡error ¡that ¡hinted ¡on ¡the ¡port ¡being ¡closed, ¡ tested ¡with ¡other ¡open ¡and ¡closed ¡ports ¡

slide-6
SLIDE 6

up:me ¡| ¡cut ¡–d ¡" ¡" ¡–f2 ¡

Realized ¡I ¡could ¡port ¡scan ¡Internet ¡facing ¡servers ¡using ¡verbose ¡ dis:nct ¡errors ¡from ¡facebook ¡

slide-7
SLIDE 7

cat ¡/etc/issue ¡

Facebook ¡was ¡using ¡underlying ¡server ¡side ¡code ¡to ¡open ¡socket ¡ connec:ons ¡to ¡remote ¡servers ¡to ¡download ¡content ¡ Friendly ¡error ¡messages ¡were ¡being ¡sent ¡to ¡the ¡client ¡for ¡failed ¡ socket ¡connec:ons ¡at ¡the ¡web ¡applica:on ¡level ¡ There ¡was ¡no ¡proper ¡data ¡handling ¡for ¡non ¡HTTP ¡streams, ¡ which ¡was ¡causing ¡the ¡applica:on ¡to ¡behave ¡unexpectedly ¡

slide-8
SLIDE 8

Reported ¡the ¡issue ¡to ¡Facebook ¡who ¡responded ¡saying ¡that ¡ they ¡did ¡not ¡see ¡how ¡this ¡was ¡a ¡problem ¡

mail ¡-­‑s ¡'Bug!' ¡sec@_.com ¡< ¡/dev/null ¡ ¡

slide-9
SLIDE 9

mail ¡-­‑s ¡'Bug!' ¡sec@_.com ¡< ¡/dev/null ¡ ¡

Sent ¡facebook ¡a ¡Proof ¡of ¡Concept ¡python ¡port ¡scanner ¡ Scanned ¡some ¡random ¡servers ¡on ¡the ¡Internet ¡using ¡the ¡script ¡ Facebook ¡replied ¡and ¡acknowledged ¡that ¡this ¡was ¡a ¡problem ¡

slide-10
SLIDE 10
slide-11
SLIDE 11
slide-12
SLIDE 12

which ¡category ¡

Searched ¡for ¡any ¡references ¡to ¡port ¡scanning ¡using ¡web ¡apps ¡on ¡ the ¡server ¡side ¡ Searched ¡for ¡other ¡aWacks ¡using ¡this ¡same ¡technique ¡ Being ¡the ¡foremost ¡knowledgebase ¡for ¡everything ¡WebAppSec, ¡ searched ¡the ¡OWASP ¡website ¡as ¡well ¡

slide-13
SLIDE 13

export ¡vulnerability='XSPA' ¡

XSPA ¡– ¡Cross ¡Site ¡Port ¡AWacks ¡

XSPA ¡occur ¡when ¡a ¡web ¡applica:on ¡aWempts ¡to ¡connect ¡to ¡user ¡ supplied ¡URLs ¡and ¡does ¡not ¡validate ¡backend ¡responses ¡ received ¡from ¡the ¡remote ¡server ¡ XSPA ¡allows ¡an ¡aWacker ¡to ¡port ¡scan ¡servers ¡and ¡aWack ¡services ¡ (Internet ¡facing ¡as ¡well ¡as ¡internal ¡devices) ¡while ¡proxying ¡the ¡ aWack ¡from ¡another ¡web ¡applica:on ¡

slide-14
SLIDE 14

export ¡vulnerability='XSPA' ¡

XSPA ¡– ¡Cross ¡Site ¡Port ¡AWacks ¡

slide-15
SLIDE 15

export ¡vulnerability='XSPA' ¡

XSPA ¡– ¡Cross ¡Site ¡Port ¡AWacks ¡

Consider ¡an ¡applica:on ¡that ¡allows ¡users ¡to ¡specify ¡an ¡external ¡ image ¡URL. ¡ ¡

Image ¡File ¡URL ¡ Server ¡Status ¡& ¡Body ¡Response ¡ hWp://remote_server.com/image.png ¡ ¡ 200 ¡OK ¡– ¡Image ¡retrieved ¡ hWp://remote_server.com:22/image.png ¡ 200 ¡OK ¡– ¡“Invalid ¡Image” ¡ hWp://remote_server.com:3306/image.png ¡ ¡ 200 ¡OK ¡– ¡“Invalid ¡Image” ¡ hWp://remote_server.com:8081 ¡ 200 ¡OK ¡– ¡“Connec:on ¡refused!” ¡

The ¡remote ¡server ¡on ¡which ¡the ¡image ¡resides ¡has ¡ports ¡22,80 ¡ and ¡3306 ¡open ¡

slide-16
SLIDE 16

Applica:on ¡displays ¡verbose ¡errors ¡for ¡failed ¡socket ¡ connec:ons, ¡receives ¡fixed ¡length ¡responses ¡or ¡delays ¡response ¡ for ¡a ¡fixed ¡length ¡of ¡:me ¡ Applica:on ¡does ¡not ¡verify ¡received ¡data ¡from ¡the ¡remote ¡ server, ¡if ¡the ¡connec:on ¡was ¡successful ¡ Applica:on ¡does ¡not ¡blacklist ¡internal ¡IP ¡addresses/URLs ¡

export ¡vulnerability='XSPA' ¡

XSPA ¡– ¡Cross ¡Site ¡Port ¡AWacks ¡

slide-17
SLIDE 17

Déjà ¡vu ¡

slide-18
SLIDE 18
slide-19
SLIDE 19
slide-20
SLIDE 20

S ¡ S ¡ R ¡ F ¡ erver ¡ ide ¡ equest ¡

  • rgery ¡
slide-21
SLIDE 21

Deral ¡Heiland ¡-­‑ ¡Shmoocon ¡2008 ¡

comm ¡/riyaz/xspa ¡/deral/ssrf ¡

Was ¡able ¡to ¡aWack ¡internal ¡network ¡using ¡web ¡portlets ¡ SSRF ¡via ¡URL ¡parameters ¡– ¡GET ¡& ¡POSTs ¡(mostly ¡GETs) ¡

Alexander ¡Polyakov ¡-­‑ ¡2012 ¡

AWacking ¡internal ¡networks ¡using ¡SAP ¡applica:ons ¡

OWASP ¡-­‑ ¡??? ¡

No ¡men:on ¡of ¡SSRF, ¡although ¡contains ¡references ¡to ¡XXE ¡ SSRF ¡via ¡XML ¡eXternal ¡En:ty ¡(XXE) ¡aWacks ¡

slide-22
SLIDE 22

An ¡aWacker ¡generates ¡an ¡HTTP ¡request ¡of ¡the ¡form ¡ ¡ hJp://vulnerable/geNmage.php?img=hJp://internet/image.png

HTTP ¡GET ¡

The ¡vulnerable ¡server ¡then ¡on ¡behalf ¡of ¡the ¡aWacker ¡makes ¡a ¡GET ¡ request ¡to ¡the ¡internet ¡server ¡for ¡the ¡image.png

HTTP ¡GET ¡

The ¡image ¡is ¡downloaded ¡to ¡the ¡web ¡server ¡and ¡then ¡a ¡local ¡link ¡ to ¡it ¡is ¡sent ¡to ¡the ¡aWacker

Image ¡ (Response) ¡ Page ¡ (Response) ¡

slide-23
SLIDE 23

An ¡aWacker ¡generates ¡an ¡HTTP ¡request ¡of ¡the ¡form ¡ ¡ hJp://vulnerable/geNmage.php?img=hJp://LANIP:22/img.png

HTTP ¡GET ¡

The ¡vulnerable ¡server ¡then ¡on ¡behalf ¡of ¡the ¡aWacker ¡makes ¡a ¡GET ¡ request ¡to ¡the ¡locally ¡accessible ¡server ¡for ¡the ¡img.png

HTTP ¡GET ¡ SSH ¡Banner ¡ (Response) ¡ Error ¡ (Response) ¡

Since ¡a ¡GET ¡is ¡made ¡to ¡a ¡non ¡HTTP ¡service, ¡the ¡service ¡returns ¡any ¡ banners ¡and/or ¡errors The ¡web ¡applica:on ¡may ¡then ¡generate ¡specific ¡errors ¡or ¡may ¡ display ¡raw ¡errors ¡received ¡– ¡banners ¡for ¡example

slide-24
SLIDE 24

find ¡. ¡-­‑print ¡| ¡xargs ¡grep ¡'logic' ¡ ¡

slide-25
SLIDE 25

cat ¡vulnfile.php ¡| ¡more ¡

slide-26
SLIDE 26

cat ¡vulnfile2.php ¡| ¡more ¡

slide-27
SLIDE 27

sudo ¡demo ¡& ¡

slide-28
SLIDE 28

cat ¡/xspa/other_aWacks ¡

AWackers ¡can ¡access ¡internal ¡applica:ons ¡and ¡perform ¡URL ¡ based ¡aWacks ¡(SQLi, ¡Parameter ¡manipula:on ¡etc.) ¡ Since ¡the ¡GET ¡/<data> ¡part ¡is ¡controlled ¡by ¡the ¡aWacker, ¡it ¡ would ¡be ¡possible ¡to ¡aWack ¡services ¡and ¡execute ¡code ¡on ¡ internal ¡systems ¡ Denial ¡of ¡service ¡aWacks ¡on ¡internal ¡services ¡

slide-29
SLIDE 29

sudo ¡demo ¡& ¡

slide-30
SLIDE 30

cat ¡popular_servers ¡| ¡./poke ¡

Found ¡XSPA/SSRF ¡in ¡

slide-31
SLIDE 31

cat ¡facebook ¡

The ¡first ¡finding ¡

Applica:on ¡specific ¡response ¡for ¡open ¡port ¡above ¡1024 ¡

slide-32
SLIDE 32

cat ¡facebook ¡

The ¡first ¡finding ¡

Applica:on ¡specific ¡response ¡for ¡open ¡port ¡below ¡1024 ¡

slide-33
SLIDE 33

cat ¡facebook ¡

The ¡first ¡finding ¡

Applica:on ¡specific ¡response ¡for ¡closed ¡port ¡

slide-34
SLIDE 34

cat ¡Google ¡

Google ¡Webmasters ¡– ¡XSPA/SSRF ¡

Applica:on ¡specific ¡response ¡for ¡open ¡HTTP ¡Port ¡

slide-35
SLIDE 35

cat ¡Google ¡

Google ¡Webmasters ¡– ¡XSPA/SSRF ¡

Applica:on ¡specific ¡response ¡for ¡open ¡non-­‑HTTP ¡Port ¡

slide-36
SLIDE 36

cat ¡Google ¡

Google ¡Webmasters ¡– ¡XSPA/SSRF ¡

Applica:on ¡specific ¡response ¡for ¡closed ¡port ¡

slide-37
SLIDE 37

cat ¡mozilla_marketplace ¡

Applica:on ¡specific ¡response ¡for ¡open ¡HTTP ¡port ¡

slide-38
SLIDE 38

cat ¡mozilla_marketplace ¡

Applica:on ¡specific ¡response ¡for ¡open ¡non ¡HTTP ¡port ¡

slide-39
SLIDE 39

cat ¡mozilla_marketplace ¡

Applica:on ¡specific ¡response ¡for ¡closed ¡port ¡

slide-40
SLIDE 40

cat ¡yahoo_developer_network ¡

HTML ¡Page ¡content ¡received ¡from ¡remote ¡server ¡on ¡Open ¡HTTP ¡Port ¡

slide-41
SLIDE 41

cat ¡yahoo_developer_network ¡

Non ¡HTTP ¡Service ¡responds ¡with ¡banner ¡– ¡Open ¡non ¡HTTP ¡Port ¡

slide-42
SLIDE 42

cat ¡yahoo_developer_network ¡

Non ¡HTTP ¡Service ¡responds ¡with ¡banner ¡– ¡Open ¡non ¡HTTP ¡Port ¡

slide-43
SLIDE 43

ls ¡adobe*.flv ¡| ¡xargs ¡vlc ¡

slide-44
SLIDE 44

patch ¡-­‑p1 ¡< ¡/var/xspa/fixes ¡

Response ¡Handling ¡-­‑ ¡implement ¡server ¡side ¡valida:on ¡of ¡ responses ¡received ¡from ¡remote ¡resources ¡ Error ¡handling ¡and ¡messages ¡-­‑ ¡Display ¡generic ¡error ¡messages ¡ to ¡the ¡client ¡in ¡case ¡something ¡goes ¡wrong. ¡ Restrict ¡connecNvity ¡to ¡HTTP ¡based ¡ports ¡-­‑ ¡restrict ¡connec:ons ¡ to ¡HTTP ¡ports ¡on ¡the ¡server ¡ ¡ Blacklist ¡IP ¡addresses ¡-­‑ ¡Internal ¡IP ¡addresses, ¡localhost ¡ specifica:ons ¡and ¡internal ¡hostnames ¡should ¡be ¡blacklisted ¡

slide-45
SLIDE 45

cat ¡/xspa/reading ¡

  • hWp://spl0it.wordpress.com/2010/12/02/internal-­‑port-­‑scanning-­‑via-­‑

crystal-­‑reports/ ¡

  • hWp://www.shmoocon.org/2008/presenta:ons/Web%20portals,

%20gateway%20to%20informa:on.ppt ¡

  • hWp://media.blackhat.com/bh-­‑us-­‑12/Briefings/Polyakov/

BH_US_12_Polyakov_SSRF_Business_WP.pdf ¡

  • hWps://www.corelan.be/index.php/2009/07/19/exploit-­‑wri:ng-­‑

tutorial-­‑part-­‑1-­‑stack-­‑based-­‑overflows/ ¡

  • hWp://anantshri.info/ar:cles/web_app_finger_prin:ng.html ¡
  • hWp://www.nruns.com/_downloads/Whitepaper-­‑Hacking-­‑jBoss-­‑using-­‑

a-­‑Browser.pdf ¡

  • hWp://www.sectheory.com/intranet-­‑hacking.htm ¡
  • hWp://ha.ckers.org/weird/xhr-­‑ping-­‑sweep.html ¡
  • hWp://www.w3.org/Protocols/rfc2616/rfc2616.html ¡

All ¡images ¡are ¡the ¡property ¡of ¡their ¡respec:ve ¡creators. ¡

slide-46
SLIDE 46

cat ¡/xspa/special_thanks ¡

A ¡big ¡thanks ¡to ¡Jeremiah, ¡@makash, ¡@w3bd3vil, ¡@abh1sek, ¡ @prajalkulkarni, ¡Alexander ¡Polyakov ¡and ¡everybody ¡at ¡the ¡ @null0x00 ¡community ¡for ¡their ¡help ¡with ¡tes:ng, ¡verifying, ¡ building ¡exploits ¡and ¡just ¡being ¡so ¡cool! ¡

slide-47
SLIDE 47
slide-48
SLIDE 48

Riyaz ¡Ahemed ¡Walikar ¡ @riyazwalikar ¡ hWp://www.riyazwalikar.com ¡ ¡