SlideShare uma empresa Scribd logo
1 de 16
Baixar para ler offline
Race Condition
WTF is Race Condition?
• It's a logical vulnerability
• It's very easy to miss in source code
• Can be anywhere, in web apps too
• Can be a critical vulnerability in some cases
• Easy to find and reproduce
How it works?
Thread 1
i = 0 i = 1
+1 +1
Thread 2 +1
i = 2
i = 2
WEB and Race Condition:
Temp Files
Race Condition in WEB #1
1. Receive file from user
2. Write file to temp dir
3. Read and check file from temp dir
4. Delete file, if check function return False
5. Print results
Race Condition in WEB #1
1. Receive file from user
2. Write file to temp dir
3. Read and check file from temp dir
4. Delete file, if check function return False
5. Print results
Any our file is on server's FS!
Race Condition in WEB #1
Example from real life #1
WEB and Race Condition:
Money Transfer
Race Condition in WEB #2
1. Get user1 balance
2. Get user2 balance
3. Check, if user has available money to transfer
4. Calculate new balances for accounts
5. Update balance at DB
$user1 = 100
$user2 = 0
$transfer = 10
$user2 = $user2 + $transfer
$user1 = $user1 - $transfer
$user1 >= $transfer
...
user1 now has 90
Get values from DB:
user1 has 100
user2 has 0
Thread 1:
$user1 = 100
$user2 = 10
$transfer = 10
$user2 = $user2 + $transfer
$user1 = $user1 - $transfer
$user1 >= $transfer
Update values from DB:
user2 has 20
user1 now has 90
Get values from DB:
user1 has 100
user2 has 10
Thread 2:
Update values from DB:
user2 has 10
Race Condition in WEB #2
$user1 = 100
$user2 = 0
$transfer = 10
$user2 = $user2 + $transfer
$user1 = $user1 - $transfer
$user1 >= $transfer
...
user1 now has 90
Get values from DB:
user1 has 100
user2 has 0
Thread 1:
$user1 = 100
$user2 = 10
$transfer = 10
$user2 = $user2 + $transfer
$user1 = $user1 - $transfer
$user1 >= $transfer
Update values from DB:
user2 has 20
user1 now has 90
Get values from DB:
user1 has 100
user2 has 10
Thread 2:
Update values from DB:
user2 has 10
Race Condition in WEB #2
Result:
user1 - 90
user2 - 20
Race Condition in WEB #2
Example from real life #2
Conclusion
• It's not a bug, it is a security vulnerability!
• Make your multithreading application safe
• Lock or sync vars, files, etc to avoid it
• Never forget about Race Condition!
46.101.105.58:8282
or
github.com/cyberpunkych/ph2016

Mais conteúdo relacionado

Mais procurados (20)

Macro-processor
Macro-processorMacro-processor
Macro-processor
 
Http request and http response
Http request and http responseHttp request and http response
Http request and http response
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Servlet
Servlet Servlet
Servlet
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)
 
Servlets
ServletsServlets
Servlets
 
GUI programming
GUI programmingGUI programming
GUI programming
 
Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0
 
Macro Processor
Macro ProcessorMacro Processor
Macro Processor
 
Assembler
AssemblerAssembler
Assembler
 
Android notification
Android notificationAndroid notification
Android notification
 
Socket programming in Java (PPTX)
Socket programming in Java (PPTX)Socket programming in Java (PPTX)
Socket programming in Java (PPTX)
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Android intents
Android intentsAndroid intents
Android intents
 
Html Form Controls
Html Form ControlsHtml Form Controls
Html Form Controls
 
java token
java tokenjava token
java token
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 

Destaque

Race condition
Race conditionRace condition
Race conditionhama7230
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Ravindra Raju Kolahalam
 
CTFでアレコレ
CTFでアレコレCTFでアレコレ
CTFでアレコレhama7230
 
Final race-condition-in-the-web
Final race-condition-in-the-webFinal race-condition-in-the-web
Final race-condition-in-the-webXchym Hiệp
 
NoSQL атакует: JSON функции в MySQL сервере.
NoSQL атакует: JSON функции в MySQL сервере.NoSQL атакует: JSON функции в MySQL сервере.
NoSQL атакует: JSON функции в MySQL сервере.Sveta Smirnova
 
04 ос взаимодействие_процессов_1
04 ос взаимодействие_процессов_104 ос взаимодействие_процессов_1
04 ос взаимодействие_процессов_1921519
 
Uncommon MiTM in uncommon conditions
Uncommon MiTM in uncommon conditionsUncommon MiTM in uncommon conditions
Uncommon MiTM in uncommon conditionsHeadLightSecurity
 
Defcon Moscow #0x0A - Mikhail Firstov "Hacking routers as Web Hacker"
Defcon Moscow #0x0A - Mikhail Firstov "Hacking routers as Web Hacker"Defcon Moscow #0x0A - Mikhail Firstov "Hacking routers as Web Hacker"
Defcon Moscow #0x0A - Mikhail Firstov "Hacking routers as Web Hacker"Defcon Moscow
 
Hacking routers as Web Hacker
Hacking routers as Web HackerHacking routers as Web Hacker
Hacking routers as Web HackerHeadLightSecurity
 
анализ кода: от проверки стиля до автоматического тестирования
анализ кода: от проверки стиля до автоматического тестированияанализ кода: от проверки стиля до автоматического тестирования
анализ кода: от проверки стиля до автоматического тестированияRuslan Shevchenko
 
4.3. Rat races conditions
4.3. Rat races conditions4.3. Rat races conditions
4.3. Rat races conditionsdefconmoscow
 

Destaque (20)

Sql-Injection
Sql-InjectionSql-Injection
Sql-Injection
 
LFI
LFILFI
LFI
 
Client side
Client sideClient side
Client side
 
Race condition
Race conditionRace condition
Race condition
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
Race condition
Race conditionRace condition
Race condition
 
CTFでアレコレ
CTFでアレコレCTFでアレコレ
CTFでアレコレ
 
Hacking routers as Web Hacker
Hacking routers as Web HackerHacking routers as Web Hacker
Hacking routers as Web Hacker
 
Final race-condition-in-the-web
Final race-condition-in-the-webFinal race-condition-in-the-web
Final race-condition-in-the-web
 
NoSQL атакует: JSON функции в MySQL сервере.
NoSQL атакует: JSON функции в MySQL сервере.NoSQL атакует: JSON функции в MySQL сервере.
NoSQL атакует: JSON функции в MySQL сервере.
 
04 ос взаимодействие_процессов_1
04 ос взаимодействие_процессов_104 ос взаимодействие_процессов_1
04 ос взаимодействие_процессов_1
 
IT Race 2014
IT Race 2014IT Race 2014
IT Race 2014
 
Attacking MongoDB
Attacking MongoDBAttacking MongoDB
Attacking MongoDB
 
penetest VS. APT
penetest VS. APTpenetest VS. APT
penetest VS. APT
 
Uncommon MiTM in uncommon conditions
Uncommon MiTM in uncommon conditionsUncommon MiTM in uncommon conditions
Uncommon MiTM in uncommon conditions
 
Defcon Moscow #0x0A - Mikhail Firstov "Hacking routers as Web Hacker"
Defcon Moscow #0x0A - Mikhail Firstov "Hacking routers as Web Hacker"Defcon Moscow #0x0A - Mikhail Firstov "Hacking routers as Web Hacker"
Defcon Moscow #0x0A - Mikhail Firstov "Hacking routers as Web Hacker"
 
Hacking routers as Web Hacker
Hacking routers as Web HackerHacking routers as Web Hacker
Hacking routers as Web Hacker
 
анализ кода: от проверки стиля до автоматического тестирования
анализ кода: от проверки стиля до автоматического тестированияанализ кода: от проверки стиля до автоматического тестирования
анализ кода: от проверки стиля до автоматического тестирования
 
4.3. Rat races conditions
4.3. Rat races conditions4.3. Rat races conditions
4.3. Rat races conditions
 
Mongo db eng
Mongo db engMongo db eng
Mongo db eng
 

Semelhante a Race condition

Migrating from PostgreSQL to MySQL Without Downtime
Migrating from PostgreSQL to MySQL Without DowntimeMigrating from PostgreSQL to MySQL Without Downtime
Migrating from PostgreSQL to MySQL Without DowntimeMatt Graham
 
Scaling Twitter 12758
Scaling Twitter 12758Scaling Twitter 12758
Scaling Twitter 12758davidblum
 
Scaling Twitter
Scaling TwitterScaling Twitter
Scaling TwitterBlaine
 
Aprendendo solid com exemplos
Aprendendo solid com exemplosAprendendo solid com exemplos
Aprendendo solid com exemplosvinibaggio
 
초보자를 위한 분산 캐시 이야기
초보자를 위한 분산 캐시 이야기초보자를 위한 분산 캐시 이야기
초보자를 위한 분산 캐시 이야기OnGameServer
 
Socket applications
Socket applicationsSocket applications
Socket applicationsJoão Moura
 
BADCamp 2008 DB Sync
BADCamp 2008 DB SyncBADCamp 2008 DB Sync
BADCamp 2008 DB SyncShaun Haber
 
Streaming Apps and Poison Pills: handle the unexpected with Kafka Streams (Lo...
Streaming Apps and Poison Pills: handle the unexpected with Kafka Streams (Lo...Streaming Apps and Poison Pills: handle the unexpected with Kafka Streams (Lo...
Streaming Apps and Poison Pills: handle the unexpected with Kafka Streams (Lo...confluent
 
Connect 2016-Move Your XPages Applications to the Fast Lane
Connect 2016-Move Your XPages Applications to the Fast LaneConnect 2016-Move Your XPages Applications to the Fast Lane
Connect 2016-Move Your XPages Applications to the Fast LaneHoward Greenberg
 
Capistrano
CapistranoCapistrano
Capistranobetacube
 
Rails Concurrency Gotchas
Rails Concurrency GotchasRails Concurrency Gotchas
Rails Concurrency Gotchasmarcostoledo
 
"Deploying Multi-OS Applications with Docker Swarm" with Docker's David Yu
"Deploying Multi-OS Applications with Docker Swarm" with Docker's David Yu"Deploying Multi-OS Applications with Docker Swarm" with Docker's David Yu
"Deploying Multi-OS Applications with Docker Swarm" with Docker's David YuSteven Puroll
 
Troubleshooting Tips from a Docker Support Engineer
Troubleshooting Tips from a Docker Support EngineerTroubleshooting Tips from a Docker Support Engineer
Troubleshooting Tips from a Docker Support EngineerJeff Anderson
 
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, DockerTroubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, DockerDocker, Inc.
 
WebPerformance: Why and How? – Stefan Wintermeyer
WebPerformance: Why and How? – Stefan WintermeyerWebPerformance: Why and How? – Stefan Wintermeyer
WebPerformance: Why and How? – Stefan WintermeyerElixir Club
 
Fixing Growing Pains With Puppet Data Patterns
Fixing Growing Pains With Puppet Data PatternsFixing Growing Pains With Puppet Data Patterns
Fixing Growing Pains With Puppet Data PatternsMartin Jackson
 
Move Your XPages Applications to the Fast Lane
Move Your XPages Applications to the Fast LaneMove Your XPages Applications to the Fast Lane
Move Your XPages Applications to the Fast LaneTeamstudio
 
Scaling your apps with Kubernetes and Docker - TheConf 2018
Scaling your apps with Kubernetes and Docker - TheConf 2018Scaling your apps with Kubernetes and Docker - TheConf 2018
Scaling your apps with Kubernetes and Docker - TheConf 2018Erick Wendel
 
Как сделать высоконагруженный сервис, не зная количество нагрузки / Олег Обле...
Как сделать высоконагруженный сервис, не зная количество нагрузки / Олег Обле...Как сделать высоконагруженный сервис, не зная количество нагрузки / Олег Обле...
Как сделать высоконагруженный сервис, не зная количество нагрузки / Олег Обле...Ontico
 

Semelhante a Race condition (20)

Migrating from PostgreSQL to MySQL Without Downtime
Migrating from PostgreSQL to MySQL Without DowntimeMigrating from PostgreSQL to MySQL Without Downtime
Migrating from PostgreSQL to MySQL Without Downtime
 
Scaling Twitter 12758
Scaling Twitter 12758Scaling Twitter 12758
Scaling Twitter 12758
 
Scaling Twitter
Scaling TwitterScaling Twitter
Scaling Twitter
 
Aprendendo solid com exemplos
Aprendendo solid com exemplosAprendendo solid com exemplos
Aprendendo solid com exemplos
 
초보자를 위한 분산 캐시 이야기
초보자를 위한 분산 캐시 이야기초보자를 위한 분산 캐시 이야기
초보자를 위한 분산 캐시 이야기
 
Socket applications
Socket applicationsSocket applications
Socket applications
 
BADCamp 2008 DB Sync
BADCamp 2008 DB SyncBADCamp 2008 DB Sync
BADCamp 2008 DB Sync
 
Streaming Apps and Poison Pills: handle the unexpected with Kafka Streams (Lo...
Streaming Apps and Poison Pills: handle the unexpected with Kafka Streams (Lo...Streaming Apps and Poison Pills: handle the unexpected with Kafka Streams (Lo...
Streaming Apps and Poison Pills: handle the unexpected with Kafka Streams (Lo...
 
Connect 2016-Move Your XPages Applications to the Fast Lane
Connect 2016-Move Your XPages Applications to the Fast LaneConnect 2016-Move Your XPages Applications to the Fast Lane
Connect 2016-Move Your XPages Applications to the Fast Lane
 
Capistrano
CapistranoCapistrano
Capistrano
 
Rails Concurrency Gotchas
Rails Concurrency GotchasRails Concurrency Gotchas
Rails Concurrency Gotchas
 
Ruby For Startups
Ruby For StartupsRuby For Startups
Ruby For Startups
 
"Deploying Multi-OS Applications with Docker Swarm" with Docker's David Yu
"Deploying Multi-OS Applications with Docker Swarm" with Docker's David Yu"Deploying Multi-OS Applications with Docker Swarm" with Docker's David Yu
"Deploying Multi-OS Applications with Docker Swarm" with Docker's David Yu
 
Troubleshooting Tips from a Docker Support Engineer
Troubleshooting Tips from a Docker Support EngineerTroubleshooting Tips from a Docker Support Engineer
Troubleshooting Tips from a Docker Support Engineer
 
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, DockerTroubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
 
WebPerformance: Why and How? – Stefan Wintermeyer
WebPerformance: Why and How? – Stefan WintermeyerWebPerformance: Why and How? – Stefan Wintermeyer
WebPerformance: Why and How? – Stefan Wintermeyer
 
Fixing Growing Pains With Puppet Data Patterns
Fixing Growing Pains With Puppet Data PatternsFixing Growing Pains With Puppet Data Patterns
Fixing Growing Pains With Puppet Data Patterns
 
Move Your XPages Applications to the Fast Lane
Move Your XPages Applications to the Fast LaneMove Your XPages Applications to the Fast Lane
Move Your XPages Applications to the Fast Lane
 
Scaling your apps with Kubernetes and Docker - TheConf 2018
Scaling your apps with Kubernetes and Docker - TheConf 2018Scaling your apps with Kubernetes and Docker - TheConf 2018
Scaling your apps with Kubernetes and Docker - TheConf 2018
 
Как сделать высоконагруженный сервис, не зная количество нагрузки / Олег Обле...
Как сделать высоконагруженный сервис, не зная количество нагрузки / Олег Обле...Как сделать высоконагруженный сервис, не зная количество нагрузки / Олег Обле...
Как сделать высоконагруженный сервис, не зная количество нагрузки / Олег Обле...
 

Último

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 

Último (20)

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 

Race condition

  • 2. WTF is Race Condition? • It's a logical vulnerability • It's very easy to miss in source code • Can be anywhere, in web apps too • Can be a critical vulnerability in some cases • Easy to find and reproduce
  • 3. How it works? Thread 1 i = 0 i = 1 +1 +1 Thread 2 +1 i = 2 i = 2
  • 4. WEB and Race Condition: Temp Files
  • 5. Race Condition in WEB #1 1. Receive file from user 2. Write file to temp dir 3. Read and check file from temp dir 4. Delete file, if check function return False 5. Print results
  • 6. Race Condition in WEB #1 1. Receive file from user 2. Write file to temp dir 3. Read and check file from temp dir 4. Delete file, if check function return False 5. Print results Any our file is on server's FS!
  • 9. WEB and Race Condition: Money Transfer
  • 10. Race Condition in WEB #2 1. Get user1 balance 2. Get user2 balance 3. Check, if user has available money to transfer 4. Calculate new balances for accounts 5. Update balance at DB
  • 11. $user1 = 100 $user2 = 0 $transfer = 10 $user2 = $user2 + $transfer $user1 = $user1 - $transfer $user1 >= $transfer ... user1 now has 90 Get values from DB: user1 has 100 user2 has 0 Thread 1: $user1 = 100 $user2 = 10 $transfer = 10 $user2 = $user2 + $transfer $user1 = $user1 - $transfer $user1 >= $transfer Update values from DB: user2 has 20 user1 now has 90 Get values from DB: user1 has 100 user2 has 10 Thread 2: Update values from DB: user2 has 10 Race Condition in WEB #2
  • 12. $user1 = 100 $user2 = 0 $transfer = 10 $user2 = $user2 + $transfer $user1 = $user1 - $transfer $user1 >= $transfer ... user1 now has 90 Get values from DB: user1 has 100 user2 has 0 Thread 1: $user1 = 100 $user2 = 10 $transfer = 10 $user2 = $user2 + $transfer $user1 = $user1 - $transfer $user1 >= $transfer Update values from DB: user2 has 20 user1 now has 90 Get values from DB: user1 has 100 user2 has 10 Thread 2: Update values from DB: user2 has 10 Race Condition in WEB #2 Result: user1 - 90 user2 - 20
  • 14. Example from real life #2
  • 15. Conclusion • It's not a bug, it is a security vulnerability! • Make your multithreading application safe • Lock or sync vars, files, etc to avoid it • Never forget about Race Condition!