Skip to content

Commit 7616ae5

Browse files
committed
Added S-27
1 parent dd3cf1e commit 7616ae5

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ S.No. | Topic
4545
**24** | [Vulnerable Code Snippet - 12](/resources/vulnerable-code-12.md)
4646
**25** | [Vulnerable Code Snippet - 13](/resources/vulnerable-code-13.md)
4747
**26** | [Vulnerable Code Snippet - 14](/resources/vulnerable-code-14.md)
48+
**27** | [Vulnerable Code Snippet - 15](/resources/vulnerable-code-15.md)
4849

4950

5051
# SecurityExplained NewsLetter

media/code-15.jpg

129 KB
Loading

resources/vulnerable-code-15.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
### SecurityExplained S-27: Vulnerable Code Snippet - 15
2+
3+
#### Vulnerable Code:
4+
5+
![Vulnerable Code](../media/code-15.jpg)
6+
7+
8+
#### Solution:
9+
10+
As per SonarSource, There is a ToCToU (Time of Check - Time of Use) bug: if the file does not exist at the time of the checks, they will be skipped. Attackers could create a symlink at /tmp/logs.txt right before the call to fopen(), and write to an unintended destination! It's very common to find file checks vulnerable to such ToCToU bugs. The best ways to avoid it is to perform these operations in folders with restrictive permissions and prefer file descriptors to paths (fstat, etc).
11+
12+
##### Code Credits: SonarSource

0 commit comments

Comments
 (0)