SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

[143] Modern C++ 무조건 써야 해?
[143] Modern C++ 무조건 써야 해?[143] Modern C++ 무조건 써야 해?
[143] Modern C++ 무조건 써야 해?NAVER D2
 
Http Parameter Pollution, a new category of web attacks
Http Parameter Pollution, a new category of web attacksHttp Parameter Pollution, a new category of web attacks
Http Parameter Pollution, a new category of web attacksStefano Di Paola
 
Midi technique - présentation docker
Midi technique - présentation dockerMidi technique - présentation docker
Midi technique - présentation dockerOlivier Eeckhoutte
 
Shell and its types in LINUX
Shell and its types in LINUXShell and its types in LINUX
Shell and its types in LINUXSHUBHA CHATURVEDI
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)Prakhar Maurya
 
Threads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess CommunicationThreads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess CommunicationShivam Mitra
 
Sql injection
Sql injectionSql injection
Sql injectionZidh
 
Sql injection in cybersecurity
Sql injection in cybersecuritySql injection in cybersecurity
Sql injection in cybersecuritySanad Bhowmik
 
Introduction to java
Introduction to  javaIntroduction to  java
Introduction to javaKalai Selvi
 
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...Sam Bowne
 
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 EditionGoing Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 EditionSoroush Dalili
 
DDoS Attack Preparation and Mitigation
DDoS Attack Preparation and MitigationDDoS Attack Preparation and Mitigation
DDoS Attack Preparation and MitigationJerod Brennen
 
Topics in network security
Topics in network securityTopics in network security
Topics in network securityNasir Bhutta
 
Installation eclipse
Installation eclipseInstallation eclipse
Installation eclipsesrbhthkr
 
Secure Code Warrior - CRLF injection
Secure Code Warrior - CRLF injectionSecure Code Warrior - CRLF injection
Secure Code Warrior - CRLF injectionSecure Code Warrior
 

Tendances (20)

[143] Modern C++ 무조건 써야 해?
[143] Modern C++ 무조건 써야 해?[143] Modern C++ 무조건 써야 해?
[143] Modern C++ 무조건 써야 해?
 
Http Parameter Pollution, a new category of web attacks
Http Parameter Pollution, a new category of web attacksHttp Parameter Pollution, a new category of web attacks
Http Parameter Pollution, a new category of web attacks
 
Subroutines
SubroutinesSubroutines
Subroutines
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
Midi technique - présentation docker
Midi technique - présentation dockerMidi technique - présentation docker
Midi technique - présentation docker
 
Shell and its types in LINUX
Shell and its types in LINUXShell and its types in LINUX
Shell and its types in LINUX
 
Présentation Docker
Présentation DockerPrésentation Docker
Présentation Docker
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
Threads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess CommunicationThreads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess Communication
 
Sql injection
Sql injectionSql injection
Sql injection
 
Sql injection in cybersecurity
Sql injection in cybersecuritySql injection in cybersecurity
Sql injection in cybersecurity
 
Introduction to java
Introduction to  javaIntroduction to  java
Introduction to java
 
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Sql injection
Sql injectionSql injection
Sql injection
 
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 EditionGoing Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
 
DDoS Attack Preparation and Mitigation
DDoS Attack Preparation and MitigationDDoS Attack Preparation and Mitigation
DDoS Attack Preparation and Mitigation
 
Topics in network security
Topics in network securityTopics in network security
Topics in network security
 
Installation eclipse
Installation eclipseInstallation eclipse
Installation eclipse
 
Secure Code Warrior - CRLF injection
Secure Code Warrior - CRLF injectionSecure Code Warrior - CRLF injection
Secure Code Warrior - CRLF injection
 

En vedette

Race conditions
Race conditionsRace conditions
Race conditionsMohd Arif
 
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
 

En vedette (20)

Race conditions
Race conditionsRace conditions
Race conditions
 
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
 

Similaire à 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
 

Similaire à 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
 
Как сделать высоконагруженный сервис, не зная количество нагрузки / Олег Обле...
Как сделать высоконагруженный сервис, не зная количество нагрузки / Олег Обле...Как сделать высоконагруженный сервис, не зная количество нагрузки / Олег Обле...
Как сделать высоконагруженный сервис, не зная количество нагрузки / Олег Обле...
 

Dernier

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
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
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
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
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
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
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
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
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
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
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
 

Dernier (20)

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
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
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...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
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
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
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
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 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)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
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
 

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!