Video yükleniyor...
Video Yüklenemedi
This is how the lack of atomic operations and proper database locks can allow an attacker to withdraw more funds than they actually have, all through a race-condition exploit. How to prevent vulnerabilities like this one: - Use atomic DB transactions - Enable row-level or advisory locks - Implement... show more
133,411 görüntüleme • 10 ay önce •via X (Twitter)
26 Yorum

I was really impressed with the number of people who knew that the code needs to be shitty for such scenario to happen. But it also doesn’t need to be too shitty. I have exploited this bug in several real world applications to bypass double spending, even 2FA and daily transfer limit

One of my fear of working with financial system, you must be 99.9% ready for almost all scenario. 😂 I believe laravel has something call ->lockForUpdate(), this makes sure the model you are working with is locked to prevents being modified/selected from another call

Twitter and reducing video quality🙂↔️. It’s cleaner on LinkedIn sha

Does rate limiting and db transaction locking on these operations not fix this?

It fixes it

DB locks at SCALE can be a problem though, for power users doing like 200txns/second it creates a bottleneck everyone has to wait. To avoid race conditions - Use atomic DB transactions - pessimistic locks(not row locks, this is vital) - Implement idempotency keys - Limit concurrency per user - Using queues for debit and credit operations(most important) - Add rate limiting with strict thresholds

ACID! Seen papers of flaws in real financial systems where this was an after thought.. of course they lost a lot of money.

I specifically had a talk on this topic for those who interested

The King!!! Thank you for this chief

Very correct, additional layer of unique idempotency key for each payment request will help too

Yeahh

Rate limiting can go a long way in fixing this

thanks for sharing these videos bro. > Add rate limiting with strict thresholds can you expand on this?

You’re welcome chief! Yeah, you shouldn’t allow multiple requests in milliseconds, or seconds on critical endpoints like /transfer, /order etc..

Yeah that makes sense. 🫡

Things I love to see on my TL. Great video, thanks for sharing.

You’re welcome chief! 🙌🏾

That's scary

Do I understand all the terminology yet nah but I enjoy learning new things from you broski

The classic `SELECT ... FOR UPDATE` vs optimistic locking debate.Pesimistic locking is simple and safe, but can crush throughput. Optimistic locking is faster, but now your app layer is on the hook for handling conflicts and retries. Pick your poison.

Pick your poison indeed 😅😅

Everybody talks fraud prevention but the real threat model is devs shipping concurrency without a rollback plan.

Race conditions vulnerability is everywhere these day

Woow,this is eye opening

lol, them no born you well to hack me this way. pessimistic locking locking plus idempotency check

Thanks chief, this practical scenario showcase mistakes that happen in real life.
