how to rob an online bank (and get away with it)

49
Session ID: Session Classification: Mitja Kolsek ACROS Security How to Rob an Online Bank (and get away with it) HT-108 Intermediate

Upload: others

Post on 12-Sep-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: How to Rob an Online Bank (and get away with it)

Session ID:

Session Classification:

Mitja Kolsek ACROS Security

How to Rob an Online Bank

(and get away with it)

HT-108

Intermediate

Page 2: How to Rob an Online Bank (and get away with it)

2

Page 3: How to Rob an Online Bank (and get away with it)

3

Page 4: How to Rob an Online Bank (and get away with it)

Evolution Of E-banking Attacks

4

PAST-PRESENT

PRESENT

FUTURE

FUTURE 2.0

Online Banking Server

Back-End Server

Page 5: How to Rob an Online Bank (and get away with it)

E-Banking Server

Back-End Server

Attacks Against Individual Users

5

Goal: Identity Theft

Methods Phishing, Fake security alerts

XSS, CSRF

Malware (man in the browser, extraction of certs and private keys)

Problems User awareness

2-factor authentication

OOB transaction confirmations

Additional passwords/PINs

“Known good” target accounts

Page 6: How to Rob an Online Bank (and get away with it)

Online Banking Server

Back-End Server

Attacks Against Corporate Users

6

Goal: Identity Theft

Methods Same as with individual users

Advantages

More money

Large transactions not unusual

Targets can be found in public certificate directories

Page 7: How to Rob an Online Bank (and get away with it)

LDAP Explorer – Online Bank Robber’s Google

7

Page 8: How to Rob an Online Bank (and get away with it)

Example: Published Corporate Certificate

8

ldap://ldap.halcom.si:389/eidCertificateSerialNumber=382631

E-Mail Address

Personal Name

Company Name

Page 9: How to Rob an Online Bank (and get away with it)

Attacks Against Online Banking Servers

9

Online Banking Server

Goal: Exploiting Applications

Methods Hacking

Problems

Getting noticed while looking for flaws

Advantages

Unlimited amount of money

No user interaction (social engineering)

Possible creation of new money

Page 10: How to Rob an Online Bank (and get away with it)

10

Direct Resource Access

Page 11: How to Rob an Online Bank (and get away with it)

Direct Resource Access – URL Cleartext ID

11

https://bank/balance?uid=7728356 (my account balance data)

https://bank/balance?uid=7728355 (another user’s account balance data)

Page 12: How to Rob an Online Bank (and get away with it)

Direct Resource Access – URL Base64 encoding

12

https://bank/balance?dWlkPTc3MjgzNTY= (my account balance data)

https://bank/balance?dWlkPTc3MjgzNTU= (another user’s account balance data)

Base64decode(“dWlkPTc3MjgzNTY=”)

“uid=7728356”

Base64encode(“uid=7728355”)

Page 13: How to Rob an Online Bank (and get away with it)

Direct Resource Access – URL Encryption

13

/balance?Ko7hIGJJ2GqfhSZ9... (Base64)

/balance?AF86B301008AEF5... (Hex)

enc_params = AES_encrypt(params, key)

path = "/balance?" + base64(enc_params)

params = "uid=7728356"

params += "&salt=nobodywillguessthis"

params += "&rand=" + random()

Page 14: How to Rob an Online Bank (and get away with it)

Taking Money From Other People’s Accounts

14

/transfer? src=1 & dest=2 & amount=100 (from my account)

/transfer? src=42 & dest=2 & amount=100 (from another user’s account)

Page 15: How to Rob an Online Bank (and get away with it)

Transaction Creation Process

15

I want to transfer some money

Empty transaction form

Filled-out transaction form src=1,dst=2, amount=100

Read-only confirmation form src=1,dst=2, amount=100

Transaction confirmation src=1,dst=2, amount=100

Validation #2

Validation #1

Validation #3

Page 16: How to Rob an Online Bank (and get away with it)

16

Negative Numbers

Page 17: How to Rob an Online Bank (and get away with it)

Negative Numbers – A Devastating Oversight

17

IF RequestedAmount > DisposableAmount

THEN ERROR();

IF -100 > 2,000

THEN ERROR(); // No Error Here

IF 3,000 > 2,000

THEN ERROR(); // Error – Insufficient Funds

Page 18: How to Rob an Online Bank (and get away with it)

“Here’s minus hundred bucks for you”

18

Attacker: Victim:

0 $ 100 $

Attacker: Victim:

100 $ 0 $

(Transfer -100 $ to Victim)

Page 19: How to Rob an Online Bank (and get away with it)

Creating Money Out Of Thin Air

19

Normal Account: Savings Account:

0 $ 0 $

Normal Account: Savings Account:

100 $ 0 $

(Transfer -100 $ to Savings Account)

Page 20: How to Rob an Online Bank (and get away with it)

20

Bypassing Limit Checks

Page 21: How to Rob an Online Bank (and get away with it)

Normal Overdraft

21

Account #1: Account #2:

100 $ 0 $

Account #1: Account #2:

-900 $ 1,000 $

(Transfer 1,000 $ from #1 to #2)

Page 22: How to Rob an Online Bank (and get away with it)

“Over-Overdraft”

22

Account #1: Account #2:

100 $ 0 $

Account #1: Account #2:

-999,900 $ 1,000,000 $

(Transfer 1,000,000 $ from #1 to #2)

Page 23: How to Rob an Online Bank (and get away with it)

23

HTTP Parameter Pollution

Luca Carettoni & Stefano di Paola http://www.slideshare.net/Wisec/http-parameter-pollution-a-new-category-of-web-attacks

Page 24: How to Rob an Online Bank (and get away with it)

Request Flow

24

POST /transfer source=1 & dest=2 & amount=100

source = request.getParameter(“source”) // 1

amount = request.getParameter(“amount”) // 100

IF NOT user_authorized_for(source) THEN ERROR()

IF disposable(source) < amount THEN ERROR()

Call BackEndTransaction(request)

source = $_POST[“source”] // 1

dest = $_POST[“dest”] // 2

amount = $_POST[“amount”] // 100

POST /BackEndTransaction source=1 & dest=2 & amount=100

PHP

JSP

Page 25: How to Rob an Online Bank (and get away with it)

HTTP Parameter Pollution (Source Account)

25

POST /transfer source=1 & dest=2 & amount=100 & source=42

source = request.getParameter(“source”) // 1

amount = request.getParameter(“amount”) // 100

IF NOT user_authorized_for(source) THEN ERROR()

IF disposable(source) < amount THEN ERROR()

Call BackEndTransaction(request)

source = $_POST[“source”] // 42

dest = $_POST[“dest”] // 2

amount = $_POST[“amount”] // 100

POST /BackEndTransaction source=1 & dest=2 & amount=100 & source=42

PHP

JSP

IF NOT user_authorized_for(source) THEN ERROR()

Page 26: How to Rob an Online Bank (and get away with it)

HTTP Parameter Pollution (Transfer Amount)

26

POST /transfer source=1 & dest=2 & amount=100 & amount=100000

source = request.getParameter(“source”) // 1

amount = request.getParameter(“amount”) // 100

IF NOT user_authorized_for(source) THEN ERROR()

IF disposable(source) < amount THEN ERROR()

Call BackEndTransaction(request)

source = $_POST[“source”] // 1

dest = $_POST[“dest”] // 2

amount = $_POST[“amount”] // 100000

POST /BackEndTransaction source=1 & dest=2 & amount=100 & amount=100000

PHP

JSP

IF NOT user_authorized_for(source) THEN ERROR()

Page 27: How to Rob an Online Bank (and get away with it)

27

SQL Injection

Page 28: How to Rob an Online Bank (and get away with it)

SQL Injection – Data Theft

28

”SELECT rate FROM exch_rates WHERE currency = ’”.$currency. ”’”

”SELECT rate FROM exch_rates WHERE currency = ’’ UNION SELECT balance FROM accounts WHERE account_id = ’887296’”

Page 29: How to Rob an Online Bank (and get away with it)

SQL Injection – Messing With Transactions

29

”UPDATE accounts SET balance = 0 WHERE account_id = ’”.$acctid1.”’”

”UPDATE accounts SET balance = 100 WHERE account_id = ’”.$acctid2.”’”

”COMMIT TRANSACTION”

”BEGIN TRANSACTION”

Page 30: How to Rob an Online Bank (and get away with it)

SQL Injection – Messing With Transactions

30

”UPDATE accounts SET balance = 0 WHERE account_id = ’123’”

”UPDATE accounts SET balance = 100 WHERE account_id = ’456’”

”COMMIT TRANSACTION”

”BEGIN TRANSACTION”

Page 31: How to Rob an Online Bank (and get away with it)

SQL Injection – Messing With Transactions

31

”UPDATE accounts SET balance = 0 WHERE account_id = ’123’”

”UPDATE accounts SET balance = 100 WHERE account_id = ’456’ OR account_id = ’123’”

”COMMIT TRANSACTION”

”BEGIN TRANSACTION”

Page 32: How to Rob an Online Bank (and get away with it)

32

Forging Bank’s Digital Signatures

Page 33: How to Rob an Online Bank (and get away with it)

Automated Signing Of Deposit Agreement

33

Deposit request: 100€, 31 days

Deposit agreement for signing (Legal text, interest rate)

Bank’s Signing key

User’s Signing key

Signed MODIFIED deposit agreement

Counter-signed MODIFIED deposit agreement

Page 34: How to Rob an Online Bank (and get away with it)

34

Server-Side Code Execution

Page 35: How to Rob an Online Bank (and get away with it)

Server-Side Code Execution

35

Examples

Java code injection (JBoss bug in 2010)

PHP code injection (eval, system, includes...)

Shell argument injection (command1&command2)

Buffer overflows

Impact

Change e-banking application code

Obtain database/WS credentials, issue direct requests to DB or back-end WS

Page 36: How to Rob an Online Bank (and get away with it)

36

The List Goes On...

Page 37: How to Rob an Online Bank (and get away with it)

Other Attacks

37

Session Puzzling

Insecure Mass Assignment

Numerical Magic: Overflows, Underflows, Exponential Notation, Reserved words (Corsaire whitepaper)

“Stale” Currency Exchange

Race Conditions

...

New functionalities: automated deposits, loans, investment portfolio management, ...

Page 38: How to Rob an Online Bank (and get away with it)

38

Getting Rich Without Breaking The Law

http://blog.acrossecurity.com/2012/01/is-your-online-bank-vulnerable-to.html

Page 39: How to Rob an Online Bank (and get away with it)

Rounding And Currency Exchange

39

Loss : -0,00364 $ = -27%

Profit : +0,00266 € = +36%

1 € 1,364 $

0,01 € 0,01364 $

0,01 € 0,01 $

Page 40: How to Rob an Online Bank (and get away with it)

40

Asymmetric Currency Rounding

by M'Raïhi, Naccache and Tunstall

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.91.8055&rep=rep1&type=pdf

Known at least since

2001

Page 41: How to Rob an Online Bank (and get away with it)

Currency Rounding Attack: Algorithm

41

2:

1:

goto 1 3:

for i = 1 to 13640

Convert 100€ to $

Convert 0,01$ to 0,01€

// Now we have 136,40€

// We have 136,40$

Page 42: How to Rob an Online Bank (and get away with it)

Currency Rounding Attacks

42

The Speed Of Getting Rich

Assume: 10 exchanges / second

1 day = 86.400 seconds

Daily profit: 2.300 €

Monthly profit: ~ 70.000 €

Improvements

Optimal exchange rate (getting as close to 0,005 as possible)

Corporate banking: packets (1000s of exchanges in one packet)

Does it really work?

My personal e-banking: YES

My company’s corporate e-banking: YES

Countermeasures

Limit minimum amount to 1 whole unit, exchange fee

Page 43: How to Rob an Online Bank (and get away with it)

43

Phases Of Online Bank Robbery

http://blog.acrossecurity.com/2012/05/anatomy-of-online-bank-robbery.html

Page 44: How to Rob an Online Bank (and get away with it)

4 Phases Of Online Bank Robbery

44

Phase 1 Vulnerability Finding

Source code or black box, “user-in-the-middle”

Phase 2 Vulnerability Exploitation

“Creation” of money on attacker’s account, “user-in-the-middle”

Phase 3 Buying Time

Passing the money across borders, borrowing corporate accounts

Phase 4 Extraction

Classic methods, also borrowing user accounts for transfers

Page 45: How to Rob an Online Bank (and get away with it)

45

Apply

Page 46: How to Rob an Online Bank (and get away with it)

Apply: Bankers – Short Term

Currency conversion attacks

Set minimum amount or fee

“Phase 1”: Disallow vulnerability tests

Terms of service: suspend user account if vuln-testing

46

Page 47: How to Rob an Online Bank (and get away with it)

Apply: Bankers – Long Term

“Phase 1”: Detect vulnerability tests

OWASP AppSensor*

Terminate user session if testing is detected

Many server-side errors caused by single user

“Phase 2”: Find and fix vulnerabilities

Review your code (tools don’t find logical bugs)

Get help from those who break into banks

Use external pentest for designing and testing “Phase 1” detection

47

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

Page 48: How to Rob an Online Bank (and get away with it)

Apply: Penetration Testers

Staging != Production

Authentication, back-end processing, scheduled jobs

Find bugs in staging, verify in production

Successful tests in production may be hard to undo (therefore test with small amounts)

Vulnerabilities

Use HTTP proxy* to “eliminate” client user interface

Be really thorough with negative numbers

Base64 encoding is often mere obfuscation

Banks are focused on authentication, not authorization

48

* https://www.owasp.org/index.php/Phoenix/Tools#HTTP_proxying_.2F_editing

Page 49: How to Rob an Online Bank (and get away with it)

49

Mitja Kolsek

ACROS d.o.o.

www.acrossecurity.com

[email protected]

Twitter: @acrossecurity, @mkolsek

Thanks: Mikko H. Hypponen, René Pfeiffer, Claudio Criscione, Stefan Ortloff and Candi Carrera for help with gathering information on national digital certificate usage