This is how the lack of atomic operations and proper database locks can allow an attacker to…
@commando_skiipz15K followers
133,411 views
26 Comments
Comments from the original post on X (Twitter)

@commando_skiipz
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
13 likes

@BakoAmbrose
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
5 likes

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

@_manlikeicon
Does rate limiting and db transaction locking on these operations not fix this?
1 like

@commando_skiipz
It fixes it
1 like

@tofunmi_ai
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
1 like

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

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

@0xAgbero
The King!!! Thank you for this chief

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

@commando_skiipz
Yeahh

@pouncetwice
Rate limiting can go a long way in fixing this

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

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

@rotimi_best
Yeah that makes sense. 🫡

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

@commando_skiipz
You’re welcome chief! 🙌🏾
1 like

@XerxesCodes54
That's scary

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

@bobbuitech
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.




