Skip navigation
This is how the lack of atomic operations and proper database locks can allow an attacker to…
0:00 / 4:11

This is how the lack of atomic operations and proper database locks can allow an attacker to…

Ghost St Badmus

@commando_skiipz15K followers

Visit on X
568 likesDownloadOriginal post

133,411 views

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 idempotency keys - Re-validate state just before final commit - Limit concurrency per user - Use queues for critical operations - Add rate limiting with strict thresholds You're welcome.

26 Comments

Comments from the original post on X (Twitter)

  • Ghost St Badmus's profile picture

    @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

  • Ambrose Bako's profile picture

    @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

  • Ghost St Badmus's profile picture

    @commando_skiipz

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

    2 likes

  • Icon - The Fintech Architect's profile picture

    @_manlikeicon

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

    1 like

  • Ghost St Badmus's profile picture

    @commando_skiipz

    It fixes it

    1 like

  • tofunmi's profile picture

    @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

  • TheVeloper's profile picture

    @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

  • ムフィド @ RubyKaigi 2026's profile picture

    @mufid

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

  • Agbero From PhilaDEVia's profile picture

    @0xAgbero

    The King!!! Thank you for this chief

  • AGK (Ejike)'s profile picture

    @dom000_dev

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

  • Ghost St Badmus's profile picture

    @commando_skiipz

    Yeahh

  • Harmony's profile picture

    @pouncetwice

    Rate limiting can go a long way in fixing this

  • Rotimi Best's profile picture

    @rotimi_best

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

  • Ghost St Badmus's profile picture

    @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's profile picture

    @rotimi_best

    Yeah that makes sense. 🫡

  • Adedoyin Emmanuel Adeniyi 🚀's profile picture

    @Emmysoft_Tm

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

  • Ghost St Badmus's profile picture

    @commando_skiipz

    You’re welcome chief! 🙌🏾

    1 like

  • Xerxes's profile picture

    @XerxesCodes54

    That's scary

  • bheky.dev's profile picture

    @bhekydotdev

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

  • Bob Bui's profile picture

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